diff --git a/tools/deck/gen-slaydeck.mjs b/tools/deck/gen-slaydeck.mjs index ae0e23a..58cdd18 100644 --- a/tools/deck/gen-slaydeck.mjs +++ b/tools/deck/gen-slaydeck.mjs @@ -65,6 +65,7 @@ function luaCardsTable(cards) { const fields = [`name = ${luaStr(c.name)}`, `cost = ${c.cost}`, `desc = ${luaStr(c.desc)}`, `kind = ${luaStr(c.kind)}`]; if (c.damage != null) fields.push(`damage = ${c.damage}`); if (c.block != null) fields.push(`block = ${c.block}`); + if (c.image != null) fields.push(`image = ${luaStr(c.image)}`); return `\t${id} = { ${fields.join(', ')} },`; }); return `self.Cards = {\n${lines.join('\n')}\n}`; @@ -2111,24 +2112,7 @@ end`, [ { Type: 'any', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'pile' }, { Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'title' }, ]), - method('ApplyInspectCardVisual', `local c = self.Cards[cardId] -if c == nil then - c = { name = cardId, cost = 0, desc = "", kind = "Skill" } -end -local base = "/ui/DefaultGroup/DeckInspectHud/Grid/Card" .. tostring(slot) -self:SetText(base .. "/Cost", tostring(c.cost)) -self:SetText(base .. "/Name", c.name) -self:SetText(base .. "/Desc", c.desc) -local e = _EntityService:GetEntityByPath(base) -if e ~= nil and e.SpriteGUIRendererComponent ~= nil then - if c.kind == "Attack" then - e.SpriteGUIRendererComponent.Color = Color(0.86, 0.42, 0.38, 1) - elseif c.kind == "Skill" then - e.SpriteGUIRendererComponent.Color = Color(0.42, 0.55, 0.85, 1) - else - e.SpriteGUIRendererComponent.Color = Color(0.46, 0.68, 0.52, 1) - end -end`, [ + method('ApplyInspectCardVisual', `self:ApplyCardFace("/ui/DefaultGroup/DeckInspectHud/Grid/Card" .. tostring(slot), cardId)`, [ { Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'slot' }, { Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'cardId' }, ]), @@ -2167,25 +2151,7 @@ for i = 1, 120 do end end end`), - method('ApplyAllDeckCardVisual', `local cards = self.Cards or {} -local c = cards[cardId] -if c == nil then - c = { name = cardId, cost = 0, desc = "", kind = "Skill" } -end -local base = "/ui/DefaultGroup/DeckAllHud/Grid/Card" .. tostring(slot) -self:SetText(base .. "/Cost", tostring(c.cost)) -self:SetText(base .. "/Name", c.name) -self:SetText(base .. "/Desc", c.desc) -local e = _EntityService:GetEntityByPath(base) -if e ~= nil and e.SpriteGUIRendererComponent ~= nil then - if c.kind == "Attack" then - e.SpriteGUIRendererComponent.Color = Color(0.86, 0.42, 0.38, 1) - elseif c.kind == "Skill" then - e.SpriteGUIRendererComponent.Color = Color(0.42, 0.55, 0.85, 1) - else - e.SpriteGUIRendererComponent.Color = Color(0.46, 0.68, 0.52, 1) - end -end`, [ + method('ApplyAllDeckCardVisual', `self:ApplyCardFace("/ui/DefaultGroup/DeckAllHud/Grid/Card" .. tostring(slot), cardId)`, [ { Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'slot' }, { Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'cardId' }, ]), @@ -2206,23 +2172,38 @@ for i = 1, 5 do \tend end self:RenderPiles()`, [{ Type: 'boolean', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'animate' }]), - method('ApplyCardVisual', `local c = self.Cards[cardId] + method('ApplyCardFace', `local c = self.Cards[cardId] if c == nil then c = { name = cardId, cost = 0, desc = "", kind = "Skill" } end -self:SetText("/ui/DefaultGroup/CardHand/Card" .. tostring(slot) .. "/Cost", tostring(c.cost)) -self:SetText("/ui/DefaultGroup/CardHand/Card" .. tostring(slot) .. "/Name", c.name) -self:SetText("/ui/DefaultGroup/CardHand/Card" .. tostring(slot) .. "/Desc", c.desc) -local cardEntity = _EntityService:GetEntityByPath("/ui/DefaultGroup/CardHand/Card" .. tostring(slot)) -if cardEntity ~= nil and cardEntity.SpriteGUIRendererComponent ~= nil then +local e = _EntityService:GetEntityByPath(base) +if e ~= nil and e.SpriteGUIRendererComponent ~= nil then if c.kind == "Attack" then - cardEntity.SpriteGUIRendererComponent.Color = Color(0.86, 0.42, 0.38, 1) + e.SpriteGUIRendererComponent.Color = Color(0.86, 0.42, 0.38, 1) elseif c.kind == "Skill" then - cardEntity.SpriteGUIRendererComponent.Color = Color(0.42, 0.55, 0.85, 1) + e.SpriteGUIRendererComponent.Color = Color(0.42, 0.55, 0.85, 1) else - cardEntity.SpriteGUIRendererComponent.Color = Color(0.46, 0.68, 0.52, 1) + e.SpriteGUIRendererComponent.Color = Color(0.46, 0.68, 0.52, 1) + end +end +self:SetText(base .. "/Cost", string.format("%d", c.cost)) +self:SetText(base .. "/Name", c.name) +self:SetText(base .. "/Desc", c.desc) +local art = _EntityService:GetEntityByPath(base .. "/Art") +if art ~= nil then + if c.image ~= nil and c.image ~= "" then + art.Enable = true + if art.SpriteGUIRendererComponent ~= nil then + art.SpriteGUIRendererComponent.ImageRUID = c.image + end + else + art.Enable = false end end`, [ + { Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'base' }, + { Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'cardId' }, + ]), + method('ApplyCardVisual', `self:ApplyCardFace("/ui/DefaultGroup/CardHand/Card" .. tostring(slot), cardId)`, [ { Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'slot' }, { Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'cardId' }, ]), @@ -2473,24 +2454,7 @@ local hud = _EntityService:GetEntityByPath("/ui/DefaultGroup/RewardHud") if hud ~= nil then hud.Enable = true end`), - method('ApplyRewardVisual', `local c = self.Cards[cardId] -if c == nil then - return -end -local base = "/ui/DefaultGroup/RewardHud/Reward" .. tostring(slot) -self:SetText(base .. "/Name", c.name) -self:SetText(base .. "/Cost", tostring(c.cost)) -self:SetText(base .. "/Desc", c.desc) -local e = _EntityService:GetEntityByPath(base) -if e ~= nil and e.SpriteGUIRendererComponent ~= nil then - if c.kind == "Attack" then - e.SpriteGUIRendererComponent.Color = Color(0.86, 0.42, 0.38, 1) - elseif c.kind == "Skill" then - e.SpriteGUIRendererComponent.Color = Color(0.42, 0.55, 0.85, 1) - else - e.SpriteGUIRendererComponent.Color = Color(0.46, 0.68, 0.52, 1) - end -end`, [ + method('ApplyRewardVisual', `self:ApplyCardFace("/ui/DefaultGroup/RewardHud/Reward" .. tostring(slot), cardId)`, [ { Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'slot' }, { Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'cardId' }, ]), @@ -2623,20 +2587,12 @@ for i = 1, 3 do local c = self.Cards[cid] local base = "/ui/DefaultGroup/ShopHud/Card" .. tostring(i) if c ~= nil then - self:SetText(base .. "/Name", c.name) - self:SetText(base .. "/Cost", tostring(c.cost)) - self:SetText(base .. "/Desc", c.desc) + self:ApplyCardFace(base, cid) self:SetText(base .. "/Price", string.format("%d", ${CARD_PRICE}) .. " 골드") local e = _EntityService:GetEntityByPath(base) if e ~= nil and e.SpriteGUIRendererComponent ~= nil then if self.ShopBought[i] == true then e.SpriteGUIRendererComponent.Color = Color(0.2, 0.22, 0.26, 0.6) - elseif c.kind == "Attack" then - e.SpriteGUIRendererComponent.Color = Color(0.86, 0.42, 0.38, 1) - elseif c.kind == "Skill" then - e.SpriteGUIRendererComponent.Color = Color(0.42, 0.55, 0.85, 1) - else - e.SpriteGUIRendererComponent.Color = Color(0.46, 0.68, 0.52, 1) end end end