local ____lualib = require("lualib_bundle") local __TS__Number = ____lualib.__TS__Number local __TS__NumberIsFinite = ____lualib.__TS__NumberIsFinite local __TS__Class = ____lualib.__TS__Class local __TS__ClassExtends = ____lualib.__TS__ClassExtends local __TS__Decorate = ____lualib.__TS__Decorate local ____exports = {} local ____CardSystem = require("cards.CardSystem") local AddCardToPlayerPool = ____CardSystem.AddCardToPlayerPool local CardBase = ____CardSystem.CardBase local RegisterCard = ____CardSystem.RegisterCard local ____card_value_resolver = require("cards.card_value_resolver") local getCardValueByLevel = ____card_value_resolver.getCardValueByLevel local ____card_slag = require("cards.card_slag") local isSlagCardId = ____card_slag.isSlagCardId local ____modifier_card_cursed = require("cards.modifier_card_cursed") local addCursedStack = ____modifier_card_cursed.addCursedStack local isCursedPoolCardId = ____modifier_card_cursed.isCursedPoolCardId ____exports.CARD_68_ID = 68 local CARD_ID = ____exports.CARD_68_ID ____exports.CARD_68_OPTION_SLOTS = 3 local function shuffleInPlace(self, ids) do local i = #ids - 1 while i > 0 do local j = RandomInt(0, i) local tmp = ids[i + 1] ids[i + 1] = ids[j + 1] ids[j + 1] = tmp i = i - 1 end end end local function buildOfferIdsFromPool(self, poolCardIds, optionSlots, excludeIds, includeCardId) local slots = math.max( 1, math.floor(optionSlots) ) --- Сама «Три долга» в свой бонусный выбор не попадает (иначе бесконечный цикл). local alwaysExclude = {[____exports.CARD_68_ID] = true} local previousScreenExclude = {} for ____, raw in ipairs(excludeIds) do local id = math.floor(__TS__Number(raw)) if __TS__NumberIsFinite(id) and id > 0 and id ~= 404 and not isSlagCardId(nil, id) and id ~= ____exports.CARD_68_ID then previousScreenExclude[id] = true end end local function collectUnique(____, respectPreviousScreen) local unique = {} local seen = {} for ____, raw in ipairs(poolCardIds) do do local id = math.floor(__TS__Number(raw)) if not __TS__NumberIsFinite(id) or id <= 0 or id == 404 or isSlagCardId(nil, id) then goto __continue9 end if not includeCardId(nil, id) then goto __continue9 end if alwaysExclude[id] then goto __continue9 end if respectPreviousScreen and previousScreenExclude[id] then goto __continue9 end if seen[id] then goto __continue9 end seen[id] = true unique[#unique + 1] = id end ::__continue9:: end return unique end local unique = collectUnique(nil, true) if #unique < slots then unique = collectUnique(nil, false) end if #unique == 0 then return {} end shuffleInPlace(nil, unique) local out = {} do local i = 0 while i < slots do out[#out + 1] = i < #unique and unique[i + 1] or 404 i = i + 1 end end shuffleInPlace(nil, out) return out end --- До optionSlots id для экрана выбора: проклятые карты из пула колоды. -- excludeIds — варианты только что закрытого окна выбора (чтобы не повторять тот же экран). function ____exports.buildCursedOfferIdsFromPool(self, poolCardIds, optionSlots, excludeIds) if optionSlots == nil then optionSlots = ____exports.CARD_68_OPTION_SLOTS end if excludeIds == nil then excludeIds = {} end return buildOfferIdsFromPool( nil, poolCardIds, optionSlots, excludeIds, isCursedPoolCardId ) end --- С картой 69: любые карты из пула колоды (не только проклятые). function ____exports.buildAnyOfferIdsFromPool(self, poolCardIds, optionSlots, excludeIds) if optionSlots == nil then optionSlots = ____exports.CARD_68_OPTION_SLOTS end if excludeIds == nil then excludeIds = {} end return buildOfferIdsFromPool( nil, poolCardIds, optionSlots, excludeIds, function() return true end ) end ____exports.card_68 = __TS__Class() local card_68 = ____exports.card_68 card_68.name = "card_68" card_68.____file_path = "scripts/vscripts/cards/examples/card_68.lua" __TS__ClassExtends(card_68, CardBase) function card_68.prototype.OnCreated(self) if not IsServer() then return end local hero = self:GetHero() if not hero or not IsValidEntity(hero) or not hero:IsRealHero() then return end local playerId = hero:GetPlayerOwnerID() if playerId == nil or playerId == nil or playerId < 0 then return end local curseStacks = math.max( 1, math.floor(getCardValueByLevel( nil, CARD_ID, hero, "curse_stacks", 1 )) ) do local i = 0 while i < curseStacks do addCursedStack(nil, hero) i = i + 1 end end AddCardToPlayerPool( nil, playerId, CARD_ID, 1, 1, "card_68_shuffle_back" ) end function card_68.prototype.GetModifierName(self) return nil end function card_68.prototype.IsHidden(self) return true end card_68 = __TS__Decorate(card_68, card_68, {RegisterCard}, {kind = "class", name = "card_68"}) ____exports.card_68 = card_68 return ____exports