덱창(카드 picker)의 카드가 표시·클릭되지 않던 두 버그를 근본 수정.
표시 버그: 덱뷰 render(RenderAllDeck/RenderClassDeckTabs/RenderDeckInspect)가
비-DefaultGroup(DeckUIGroup) 카드를 직접 e.Enable로 켰는데, 깊게 중첩된
ExecSpace 6 호출이라 .Enable 토글이 스코프 상실로 무효(문서화된 afac34d 버그).
Maker 저작 DeckAllHud 카드는 기본 enable=false라 안 보였음. → SetEntityEnabled
(ExecSpace 2 ClientOnly, 인라인 실행) 경유로 변경(전투 HUD와 동일 패턴).
클릭 버그: Maker 저작 DeckAllHud 카드 120장의 SpriteGUIRendererComponent.
RaycastTarget=false라 클릭 레이를 못 받아 런타임 부착 ButtonComponent에 클릭이
도달 못함(같은 패널 탭/Close는 raycast=true라 정상이던 게 결정적 단서). →
BindButtons 카드 루프에서 RaycastTarget=true 런타임 주입.
README: 디버그 단축키 섹션 추가(Ctrl+Shift+C 카드 picker / Ctrl+Shift+E 에너지).
Maker UI 저작(메이커 편집분 동반): 6개 UIGroup GroupOrder 재배치
(DeckUIGroup 최상단 4→6 등) + DeckUIGroup 카드 그리드 위치 조정(180장).
산출물 재생성: SlayDeckController.codeblock.
검증: cbgap GAP 0, JS 미러 41/41, 인게임 클릭 동작 확인.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
397 lines
18 KiB
JavaScript
397 lines
18 KiB
JavaScript
import { method, RUN_LENGTH, GOLD_PER_WIN, CARD_PRICE, REST_HEAL, RELIC_PRICE, ACT_COUNT, ACT_MAPS, LOBBY_MAP, LOBBY_SPAWN } from '../lib/codeblock.mjs';
|
|
import { CARDS, ENEMIES, CLASSES, JOBS, SOUL_UNLOCKS, CARDFRAMES, RARITIES, MAP_ROWS, MAP_COLS, CHEST_CLOSED_RUID, CHEST_OPEN_RUID, NODEICONS, CHARS, CAM, RELICS, POTIONS, luaSoulShopTable, frameRuid, luaFramesTable, luaNodeIconsTable, luaRelicsTable, luaPotionsTable, luaIntentsArray, luaEnemiesTable, luaStr, luaJobsTable, luaCardsTable, luaDeckTable } from '../lib/data.mjs';
|
|
import { UI_FILE, COMMON_FILE, UI_ROOT, GENERATED_UI_SECTIONS, UI_APPEND_ORDER, DISABLED_STOCK_CONTROLS, TRANSPARENT, DARK, GOLD, ATTACK, DEFEND, SKILL, DAMAGE_DIGIT_RUIDS, DAMAGE_POP_MAX_DIGITS, DAMAGE_POP_DIGIT_W, DAMAGE_POP_DIGIT_H, DAMAGE_POP_DIGIT_SPACING, MAX_MONSTERS, HEAD_OFFSET_Y, HP_BAR_W, WHITE, CARD_NAME_TEXT, CARD_DESC_TEXT, cardFaceLayout, CARD_W, CARD_H, CARD_SPACING, CARD_XS, ALIGN_CENTER, ALIGN_BOTTOM_CENTER, guid, transform, sprite, button, text, scrollLayoutGroup, popupLayerFor, uiOrderFor, displayOrderFor, applySortingOverride, entity, uiPath, sectionRoot, isGeneratedUiEntity, appendUiSection } from '../lib/ui-helpers.mjs';
|
|
|
|
export const deckTurnMethods = [
|
|
method('Shuffle', `if list == nil then
|
|
\treturn
|
|
end
|
|
for i = #list, 2, -1 do
|
|
\tlocal j = math.random(1, i)
|
|
\tlist[i], list[j] = list[j], list[i]
|
|
end`, [{ Type: 'any', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'list' }]),
|
|
method('BindButtons', `local endTurn = _EntityService:GetEntityByPath("/ui/RunUIGroup/DeckHud/EndTurnButton")
|
|
if endTurn ~= nil and (endTurn.ButtonComponent ~= nil or endTurn:AddComponent("ButtonComponent") ~= nil) then
|
|
if self.EndTurnHandler ~= nil then
|
|
endTurn:DisconnectEvent(ButtonClickEvent, self.EndTurnHandler)
|
|
self.EndTurnHandler = nil
|
|
end
|
|
self.EndTurnHandler = endTurn:ConnectEvent(ButtonClickEvent, function() self:EndPlayerTurn() end)
|
|
end
|
|
local drawPile = _EntityService:GetEntityByPath("/ui/RunUIGroup/DeckHud/DrawPile")
|
|
if drawPile ~= nil and (drawPile.ButtonComponent ~= nil or drawPile:AddComponent("ButtonComponent") ~= nil) then
|
|
if self.DrawPileHandler ~= nil then
|
|
drawPile:DisconnectEvent(ButtonClickEvent, self.DrawPileHandler)
|
|
self.DrawPileHandler = nil
|
|
end
|
|
self.DrawPileHandler = drawPile:ConnectEvent(ButtonClickEvent, function() self:OpenDeckInspect("draw") end)
|
|
end
|
|
local discardPile = _EntityService:GetEntityByPath("/ui/RunUIGroup/DeckHud/DiscardPile")
|
|
if discardPile ~= nil and (discardPile.ButtonComponent ~= nil or discardPile:AddComponent("ButtonComponent") ~= nil) then
|
|
if self.DiscardPileHandler ~= nil then
|
|
discardPile:DisconnectEvent(ButtonClickEvent, self.DiscardPileHandler)
|
|
self.DiscardPileHandler = nil
|
|
end
|
|
self.DiscardPileHandler = discardPile:ConnectEvent(ButtonClickEvent, function() self:OpenDeckInspect("discard") end)
|
|
end
|
|
local exhaustPile = _EntityService:GetEntityByPath("/ui/RunUIGroup/DeckHud/ExhaustPile")
|
|
if exhaustPile ~= nil and (exhaustPile.ButtonComponent ~= nil or exhaustPile:AddComponent("ButtonComponent") ~= nil) then
|
|
if self.ExhaustPileHandler ~= nil then
|
|
exhaustPile:DisconnectEvent(ButtonClickEvent, self.ExhaustPileHandler)
|
|
self.ExhaustPileHandler = nil
|
|
end
|
|
self.ExhaustPileHandler = exhaustPile:ConnectEvent(ButtonClickEvent, function() self:OpenDeckInspect("exhaust") end)
|
|
end
|
|
local inspectClose = _EntityService:GetEntityByPath("/ui/DeckUIGroup/DeckInspectHud/Close")
|
|
if inspectClose ~= nil and (inspectClose.ButtonComponent ~= nil or inspectClose:AddComponent("ButtonComponent") ~= nil) then
|
|
if self.DeckInspectCloseHandler ~= nil then
|
|
inspectClose:DisconnectEvent(ButtonClickEvent, self.DeckInspectCloseHandler)
|
|
self.DeckInspectCloseHandler = nil
|
|
end
|
|
self.DeckInspectCloseHandler = inspectClose:ConnectEvent(ButtonClickEvent, function() self:CloseDeckInspect() end)
|
|
end
|
|
local allDeckButton = _EntityService:GetEntityByPath("/ui/RunUIGroup/CombatHud/TopBar/AllDeckButton")
|
|
if allDeckButton ~= nil and (allDeckButton.ButtonComponent ~= nil or allDeckButton:AddComponent("ButtonComponent") ~= nil) then
|
|
if self.AllDeckHandler ~= nil then
|
|
allDeckButton:DisconnectEvent(ButtonClickEvent, self.AllDeckHandler)
|
|
self.AllDeckHandler = nil
|
|
end
|
|
self.AllDeckHandler = allDeckButton:ConnectEvent(ButtonClickEvent, function() self:OpenAllDeck() end)
|
|
end
|
|
local allDeckClose = _EntityService:GetEntityByPath("/ui/DeckUIGroup/DeckAllHud/Close")
|
|
if allDeckClose ~= nil and (allDeckClose.ButtonComponent ~= nil or allDeckClose:AddComponent("ButtonComponent") ~= nil) then
|
|
if self.AllDeckCloseHandler ~= nil then
|
|
allDeckClose:DisconnectEvent(ButtonClickEvent, self.AllDeckCloseHandler)
|
|
self.AllDeckCloseHandler = nil
|
|
end
|
|
self.AllDeckCloseHandler = allDeckClose:ConnectEvent(ButtonClickEvent, function() self:CloseAllDeck() end)
|
|
end
|
|
self:BindClassDeckTabs()
|
|
for i = 1, 120 do
|
|
local allCard = _EntityService:GetEntityByPath("/ui/DeckUIGroup/DeckAllHud/Grid/Card" .. tostring(i))
|
|
if allCard ~= nil and (allCard.ButtonComponent ~= nil or allCard:AddComponent("ButtonComponent") ~= nil) then
|
|
if allCard.SpriteGUIRendererComponent ~= nil then
|
|
allCard.SpriteGUIRendererComponent.RaycastTarget = true
|
|
end
|
|
local slot = i
|
|
allCard:ConnectEvent(ButtonClickEvent, function() self:OnAllDeckCardButton(slot) end)
|
|
end
|
|
end
|
|
for i = 1, 10 do
|
|
local cardEntity = _EntityService:GetEntityByPath("/ui/RunUIGroup/CardHand/Card" .. tostring(i))
|
|
if cardEntity ~= nil and cardEntity.UITouchReceiveComponent ~= nil then
|
|
local cardPath = "/ui/RunUIGroup/CardHand/Card" .. tostring(i)
|
|
cardEntity:ConnectEvent(UITouchEnterEvent, function() self:SetCardHover(cardPath, true) end)
|
|
cardEntity:ConnectEvent(UITouchExitEvent, function() self:SetCardHover(cardPath, false) end)
|
|
cardEntity:ConnectEvent(UITouchBeginDragEvent, function(ev) self:OnCardDragBegin(i) end)
|
|
cardEntity:ConnectEvent(UITouchDragEvent, function(ev) self:OnCardDrag(i, ev.TouchPoint) end)
|
|
cardEntity:ConnectEvent(UITouchEndDragEvent, function(ev) self:OnCardDragEnd(i, ev.TouchPoint) end)
|
|
cardEntity:ConnectEvent(UITouchEnterEvent, function() self:HoverCard(i) end)
|
|
cardEntity:ConnectEvent(UITouchExitEvent, function() self:UnhoverCard(i) end)
|
|
if (cardEntity.ButtonComponent ~= nil or cardEntity:AddComponent("ButtonComponent") ~= nil) then
|
|
cardEntity:ConnectEvent(ButtonClickEvent, function() self:OnCardButton(i) end)
|
|
end
|
|
end
|
|
end
|
|
for i = 1, 3 do
|
|
local rc = _EntityService:GetEntityByPath("/ui/RunUIGroup/RewardHud/Reward" .. tostring(i))
|
|
if rc ~= nil and (rc.ButtonComponent ~= nil or rc:AddComponent("ButtonComponent") ~= nil) then
|
|
rc:ConnectEvent(ButtonClickEvent, function() self:PickReward(i) end)
|
|
if rc.UITouchReceiveComponent ~= nil then
|
|
local cardPath = "/ui/RunUIGroup/RewardHud/Reward" .. tostring(i)
|
|
rc:ConnectEvent(UITouchEnterEvent, function() self:SetCardHover(cardPath, true) end)
|
|
rc:ConnectEvent(UITouchExitEvent, function() self:SetCardHover(cardPath, false) end)
|
|
end
|
|
end
|
|
end
|
|
local skip = _EntityService:GetEntityByPath("/ui/RunUIGroup/RewardHud/Skip")
|
|
if skip ~= nil and (skip.ButtonComponent ~= nil or skip:AddComponent("ButtonComponent") ~= nil) then
|
|
skip:ConnectEvent(ButtonClickEvent, function() self:PickReward(0) end)
|
|
end
|
|
local mapNodeIds = {}
|
|
for r = 1, ${MAP_ROWS} do
|
|
for c = 1, ${MAP_COLS} do
|
|
table.insert(mapNodeIds, "r" .. tostring(r) .. "c" .. tostring(c))
|
|
end
|
|
end
|
|
table.insert(mapNodeIds, "boss")
|
|
for i = 1, #mapNodeIds do
|
|
local nid = mapNodeIds[i]
|
|
local mn = _EntityService:GetEntityByPath("/ui/RunUIGroup/MapHud/Node_" .. nid)
|
|
if mn ~= nil and (mn.ButtonComponent ~= nil or mn:AddComponent("ButtonComponent") ~= nil) then
|
|
mn:ConnectEvent(ButtonClickEvent, function() self:PickNode(nid) end)
|
|
end
|
|
end
|
|
for i = 1, 3 do
|
|
local sc = _EntityService:GetEntityByPath("/ui/RunUIGroup/ShopHud/Card" .. tostring(i))
|
|
if sc ~= nil and (sc.ButtonComponent ~= nil or sc:AddComponent("ButtonComponent") ~= nil) then
|
|
sc:ConnectEvent(ButtonClickEvent, function() self:BuyCard(i) end)
|
|
if sc.UITouchReceiveComponent ~= nil then
|
|
local cardPath = "/ui/RunUIGroup/ShopHud/Card" .. tostring(i)
|
|
sc:ConnectEvent(UITouchEnterEvent, function() self:SetCardHover(cardPath, true) end)
|
|
sc:ConnectEvent(UITouchExitEvent, function() self:SetCardHover(cardPath, false) end)
|
|
end
|
|
end
|
|
end
|
|
local shopLeave = _EntityService:GetEntityByPath("/ui/RunUIGroup/ShopHud/Leave")
|
|
if shopLeave ~= nil and (shopLeave.ButtonComponent ~= nil or shopLeave:AddComponent("ButtonComponent") ~= nil) then
|
|
shopLeave:ConnectEvent(ButtonClickEvent, function() self:LeaveNode() end)
|
|
end
|
|
local shopRelic = _EntityService:GetEntityByPath("/ui/RunUIGroup/ShopHud/Relic")
|
|
if shopRelic ~= nil and (shopRelic.ButtonComponent ~= nil or shopRelic:AddComponent("ButtonComponent") ~= nil) then
|
|
shopRelic:ConnectEvent(ButtonClickEvent, function() self:BuyRelic() end)
|
|
end
|
|
local restLeave = _EntityService:GetEntityByPath("/ui/RunUIGroup/RestHud/Leave")
|
|
if restLeave ~= nil and (restLeave.ButtonComponent ~= nil or restLeave:AddComponent("ButtonComponent") ~= nil) then
|
|
restLeave:ConnectEvent(ButtonClickEvent, function() self:LeaveNode() end)
|
|
end
|
|
for i = 1, ${MAX_MONSTERS} do
|
|
local ms = _EntityService:GetEntityByPath("/ui/RunUIGroup/CombatHud/MonsterStatus" .. tostring(i))
|
|
if ms ~= nil and (ms.ButtonComponent ~= nil or ms:AddComponent("ButtonComponent") ~= nil) then
|
|
ms:ConnectEvent(ButtonClickEvent, function() self:SetTarget(i) end)
|
|
end
|
|
end
|
|
for i = 1, 10 do
|
|
local rs = _EntityService:GetEntityByPath("/ui/RunUIGroup/CombatHud/TopBar/RelicSlot" .. tostring(i))
|
|
if rs ~= nil and rs.UITouchReceiveComponent ~= nil then
|
|
local idx = i
|
|
rs:ConnectEvent(UITouchEnterEvent, function()
|
|
local rid = nil
|
|
if self.RunRelics ~= nil then rid = self.RunRelics[idx] end
|
|
if rid ~= nil and self.Relics[rid] ~= nil then
|
|
self:ShowTooltip(self.Relics[rid].name, self.Relics[rid].desc, -240 + (idx - 1) * 48)
|
|
end
|
|
end)
|
|
rs:ConnectEvent(UITouchExitEvent, function() self:HideTooltip() end)
|
|
end
|
|
end
|
|
for i = 1, 5 do
|
|
local ps = _EntityService:GetEntityByPath("/ui/RunUIGroup/CombatHud/TopBar/PotionSlot" .. tostring(i))
|
|
if ps ~= nil and ps.UITouchReceiveComponent ~= nil then
|
|
local idx = i
|
|
ps:ConnectEvent(UITouchEnterEvent, function()
|
|
local pid = nil
|
|
if self.RunPotions ~= nil then pid = self.RunPotions[idx] end
|
|
if pid ~= nil and self.Potions[pid] ~= nil then
|
|
self:ShowTooltip(self.Potions[pid].name, self.Potions[pid].desc, 240 + (idx - 1) * 44)
|
|
end
|
|
end)
|
|
ps:ConnectEvent(UITouchExitEvent, function() self:HideTooltip() end)
|
|
ps:ConnectEvent(UITouchDownEvent, function() self:OpenPotionMenu(idx) end)
|
|
end
|
|
end
|
|
local pmUse = _EntityService:GetEntityByPath("/ui/RunUIGroup/CombatHud/PotionMenu/Use")
|
|
if pmUse ~= nil and (pmUse.ButtonComponent ~= nil or pmUse:AddComponent("ButtonComponent") ~= nil) then
|
|
pmUse:ConnectEvent(ButtonClickEvent, function() self:UsePotion() end)
|
|
end
|
|
local pmToss = _EntityService:GetEntityByPath("/ui/RunUIGroup/CombatHud/PotionMenu/Toss")
|
|
if pmToss ~= nil and (pmToss.ButtonComponent ~= nil or pmToss:AddComponent("ButtonComponent") ~= nil) then
|
|
pmToss:ConnectEvent(ButtonClickEvent, function() self:TossPotion() end)
|
|
end
|
|
local pmClose = _EntityService:GetEntityByPath("/ui/RunUIGroup/CombatHud/PotionMenu/Close")
|
|
if pmClose ~= nil and (pmClose.ButtonComponent ~= nil or pmClose:AddComponent("ButtonComponent") ~= nil) then
|
|
pmClose:ConnectEvent(ButtonClickEvent, function() self:ClosePotionMenu() end)
|
|
end
|
|
local shopPotion = _EntityService:GetEntityByPath("/ui/RunUIGroup/ShopHud/Potion")
|
|
if shopPotion ~= nil and (shopPotion.ButtonComponent ~= nil or shopPotion:AddComponent("ButtonComponent") ~= nil) then
|
|
shopPotion:ConnectEvent(ButtonClickEvent, function() self:BuyPotion() end)
|
|
end
|
|
local chest = _EntityService:GetEntityByPath("/ui/RunUIGroup/TreasureHud/Chest")
|
|
if chest ~= nil and (chest.ButtonComponent ~= nil or chest:AddComponent("ButtonComponent") ~= nil) then
|
|
chest:ConnectEvent(ButtonClickEvent, function() self:OpenChest() end)
|
|
end
|
|
local treasureLeave = _EntityService:GetEntityByPath("/ui/RunUIGroup/TreasureHud/Leave")
|
|
if treasureLeave ~= nil and (treasureLeave.ButtonComponent ~= nil or treasureLeave:AddComponent("ButtonComponent") ~= nil) then
|
|
treasureLeave:ConnectEvent(ButtonClickEvent, function() self:LeaveNode() end)
|
|
end
|
|
local jcRelic = _EntityService:GetEntityByPath("/ui/SelectUIGroup/JobChoiceHud/RelicButton")
|
|
if jcRelic ~= nil and (jcRelic.ButtonComponent ~= nil or jcRelic:AddComponent("ButtonComponent") ~= nil) then
|
|
jcRelic:ConnectEvent(ButtonClickEvent, function() self:PickJobReward("relic") end)
|
|
end
|
|
local jcJob = _EntityService:GetEntityByPath("/ui/SelectUIGroup/JobChoiceHud/JobButton")
|
|
if jcJob ~= nil and (jcJob.ButtonComponent ~= nil or jcJob:AddComponent("ButtonComponent") ~= nil) then
|
|
jcJob:ConnectEvent(ButtonClickEvent, function() self:PickJobReward("job") end)
|
|
end
|
|
for i = 1, 3 do
|
|
local slotIdx = i
|
|
local jb = _EntityService:GetEntityByPath("/ui/SelectUIGroup/JobSelectHud/Job_slot" .. tostring(i))
|
|
if jb ~= nil and (jb.ButtonComponent ~= nil or jb:AddComponent("ButtonComponent") ~= nil) then
|
|
jb:ConnectEvent(ButtonClickEvent, function()
|
|
if self.JobOpts ~= nil and self.JobOpts[slotIdx] ~= nil then
|
|
self:SetJob(self.JobOpts[slotIdx].id)
|
|
end
|
|
end)
|
|
end
|
|
end`),
|
|
method('StartPlayerTurn', `self.Turn = self.Turn + 1
|
|
self.RetainSelectActive = false
|
|
self:UpdateDiscardPrompt()
|
|
self.Energy = self.MaxEnergy
|
|
self:ApplyRelics("turnStart")
|
|
self.PlayerBlock = 0
|
|
if self.ClayBlockNext > 0 then
|
|
self.PlayerBlock = self.PlayerBlock + self.ClayBlockNext
|
|
self.ClayBlockNext = 0
|
|
end
|
|
if self.PlayerPowers ~= nil then
|
|
for i = 1, #self.PlayerPowers do
|
|
local pc = self.Cards[self.PlayerPowers[i]]
|
|
if pc ~= nil then
|
|
if pc.powerEffect == "strengthPerTurn" then
|
|
self.PlayerStr = self.PlayerStr + pc.value
|
|
elseif pc.powerEffect == "energyPerTurn" then
|
|
self.Energy = self.Energy + pc.value
|
|
elseif pc.powerEffect == "blockPerTurn" then
|
|
self.PlayerBlock = self.PlayerBlock + pc.value
|
|
end
|
|
if pc.turnStartShiv ~= nil then
|
|
self:AddCardsToHand("Shiv", pc.turnStartShiv)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
self:DrawCards(5)
|
|
self:RenderHand(true)
|
|
self:RenderCombat()`),
|
|
method('HasPowerEffect', `if self.PlayerPowers == nil then
|
|
return false
|
|
end
|
|
for i = 1, #self.PlayerPowers do
|
|
local pc = self.Cards[self.PlayerPowers[i]]
|
|
if pc ~= nil and pc.powerEffect == effect then
|
|
return true
|
|
end
|
|
end
|
|
return false`, [{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'effect' }], 0, 'boolean'),
|
|
method('ShouldOfferRetain', `if self:HasPowerEffect("retainOne") ~= true then
|
|
return false
|
|
end
|
|
if self.Hand == nil or #self.Hand <= 0 then
|
|
return false
|
|
end
|
|
for i = 1, #self.Hand do
|
|
local c = self.Cards[self.Hand[i]]
|
|
if c ~= nil and c.retain ~= true then
|
|
return true
|
|
end
|
|
end
|
|
return false`, [], 0, 'boolean'),
|
|
method('BeginRetainSelection', `self.RetainSelectActive = true
|
|
self:UpdateDiscardPrompt()
|
|
self:Toast("보존할 카드를 선택하세요")
|
|
self:RenderHand(false)`, []),
|
|
method('EndPlayerTurn', `if self.CombatOver == true or self.FxBusy == true or self.TurnBusy == true then
|
|
return
|
|
end
|
|
if self:IsDiscardSelecting() == true then
|
|
self:Toast("버릴 카드를 먼저 선택하세요")
|
|
return
|
|
end
|
|
if self:IsRetainSelecting() == true then
|
|
self:FinishPlayerTurn(0)
|
|
return
|
|
end
|
|
if self:ShouldOfferRetain() == true then
|
|
self:BeginRetainSelection()
|
|
return
|
|
end
|
|
self:FinishPlayerTurn(0)`),
|
|
method('FinishPlayerTurn', `self.RetainSelectActive = false
|
|
self:UpdateDiscardPrompt()
|
|
local burn = 0
|
|
for bi = 1, #self.Hand do
|
|
\tlocal hc = self.Cards[self.Hand[bi]]
|
|
\tif hc ~= nil and hc.endTurnDamage ~= nil then burn = burn + hc.endTurnDamage end
|
|
end
|
|
if burn > 0 then
|
|
\tself.PlayerHp = self.PlayerHp - burn
|
|
\tif self.PlayerHp < 0 then self.PlayerHp = 0 end
|
|
\tself:ShowPlayerDmgPop(burn)
|
|
\tself:RenderCombat()
|
|
end
|
|
local kept = {}
|
|
for i = 1, #self.Hand do
|
|
\tlocal cardId = self.Hand[i]
|
|
\tlocal c = self.Cards[cardId]
|
|
\tif c ~= nil and (c.retain == true or i == retainSlot) then
|
|
\t\ttable.insert(kept, cardId)
|
|
\telse
|
|
\t\ttable.insert(self.DiscardPile, cardId)
|
|
\tend
|
|
end
|
|
self.Hand = kept
|
|
if self.PlayerWeak > 0 then self.PlayerWeak = self.PlayerWeak - 1 end
|
|
if self.PlayerVuln > 0 then self.PlayerVuln = self.PlayerVuln - 1 end
|
|
self:RenderHand(false)
|
|
self:RenderPiles()
|
|
self:EnemyTurn()`, [{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'retainSlot' }]),
|
|
method('DrawCards', `local drawnSlots = {}
|
|
local drewAny = false
|
|
for i = 1, amount do
|
|
\tif #self.DrawPile <= 0 then
|
|
\t\tself:RecycleDiscardIntoDraw()
|
|
\tend
|
|
\tif #self.DrawPile <= 0 then
|
|
\t\tbreak
|
|
\tend
|
|
\tlocal cardId = table.remove(self.DrawPile)
|
|
\tif #self.Hand >= 10 then
|
|
\t\ttable.insert(self.DiscardPile, cardId)
|
|
\t\tself:TriggerSly(cardId)
|
|
\telse
|
|
\t\ttable.insert(self.Hand, cardId)
|
|
\t\tdrewAny = true
|
|
\t\ttable.insert(drawnSlots, #self.Hand)
|
|
\tend
|
|
end
|
|
self:RenderPiles()
|
|
if drewAny == true then
|
|
\tself:RenderHand(false)
|
|
end
|
|
if animate == true and #drawnSlots > 0 then
|
|
\tlocal drawStart = Vector2(-590, 8)
|
|
\tfor i = 1, #drawnSlots do
|
|
\t\tlocal slot = drawnSlots[i]
|
|
\t\tself:AnimateCardFrom(slot, drawStart, Vector2(self:GetHandSlotX(slot), 0), 0.08 + i * 0.045)
|
|
\tend
|
|
end`, [
|
|
{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'amount' },
|
|
{ Type: 'boolean', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'animate' },
|
|
]),
|
|
method('AddCardsToHand', `if self.Hand == nil then
|
|
self.Hand = {}
|
|
end
|
|
if self.DiscardPile == nil then
|
|
self.DiscardPile = {}
|
|
end
|
|
for i = 1, amount do
|
|
if #self.Hand >= 10 then
|
|
table.insert(self.DiscardPile, cardId)
|
|
else
|
|
table.insert(self.Hand, cardId)
|
|
end
|
|
end
|
|
self:RenderHand(false)
|
|
self:RenderPiles()`, [
|
|
{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'cardId' },
|
|
{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'amount' },
|
|
]),
|
|
method('RecycleDiscardIntoDraw', `if self.DiscardPile == nil or #self.DiscardPile <= 0 then
|
|
\treturn
|
|
end
|
|
self.DrawPile = {}
|
|
for i = 1, #self.DiscardPile do
|
|
\tself.DrawPile[i] = self.DiscardPile[i]
|
|
end
|
|
self.DiscardPile = {}
|
|
self:Shuffle(self.DrawPile)`),
|
|
method('RenderPiles', `self:SetText("/ui/RunUIGroup/DeckHud/DrawPile/Count", self:FormatNumber(#self.DrawPile))
|
|
self:SetText("/ui/RunUIGroup/DeckHud/DiscardPile/Count", self:FormatNumber(#self.DiscardPile))
|
|
self:SetText("/ui/RunUIGroup/DeckHud/ExhaustPile/Count", self:FormatNumber(#(self.ExhaustPile or {})))
|
|
self:SetText("/ui/RunUIGroup/DeckHud/EnergyOrb/Value", string.format("%d", self.Energy) .. "/" .. string.format("%d", self.MaxEnergy))
|
|
local inspect = _EntityService:GetEntityByPath("/ui/DeckUIGroup/DeckInspectHud")
|
|
if inspect ~= nil and inspect.Enable == true and self.DeckInspectKind ~= "" then
|
|
self:OpenDeckInspect(self.DeckInspectKind)
|
|
end`),
|
|
];
|