diff --git a/tools/deck/gen-slaydeck.mjs b/tools/deck/gen-slaydeck.mjs index c2846c8..341960c 100644 --- a/tools/deck/gen-slaydeck.mjs +++ b/tools/deck/gen-slaydeck.mjs @@ -3111,6 +3111,119 @@ if #pool == 0 then return "" end return pool[math.random(1, #pool)]`, [], 0, 'string'), + method('AddPotion', `if self.RunPotions == nil then + self.RunPotions = {} +end +if #self.RunPotions >= self.PotionSlots then + self:Toast("물약 슬롯이 가득 찼습니다") + return false +end +table.insert(self.RunPotions, pid) +self:RenderPotions() +return true`, [{ Type: 'string', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'pid' }], 0, 'boolean'), + method('MaybeDropPotion', `if math.random() > ${POTIONS.dropChance} then + return +end +local keys = {} +for pid, _ in pairs(self.Potions) do + table.insert(keys, pid) +end +table.sort(keys) +local pid = keys[math.random(1, #keys)] +if self:AddPotion(pid) == true then + local p = self.Potions[pid] + self:Toast("물약 획득: " .. p.name) +end`), + method('RenderPotions', `for i = 1, 5 do + local base = "/ui/DefaultGroup/CombatHud/TopBar/PotionSlot" .. tostring(i) + local e = _EntityService:GetEntityByPath(base) + if e ~= nil and e.SpriteGUIRendererComponent ~= nil then + local pid = nil + if self.RunPotions ~= nil then + pid = self.RunPotions[i] + end + if pid ~= nil and self.Potions[pid] ~= nil then + e.SpriteGUIRendererComponent.ImageRUID = self.Potions[pid].icon + e.SpriteGUIRendererComponent.Color = Color(1, 1, 1, 1) + elseif i > self.PotionSlots then + e.SpriteGUIRendererComponent.ImageRUID = "" + e.SpriteGUIRendererComponent.Color = Color(0.1, 0.1, 0.12, 0.85) + else + e.SpriteGUIRendererComponent.ImageRUID = "" + e.SpriteGUIRendererComponent.Color = Color(0.22, 0.25, 0.3, 0.9) + end + end +end`), + method('OpenPotionMenu', `if self.RunPotions == nil or self.RunPotions[slot] == nil then + return +end +self.PotionMenuSlot = slot +local pid = self.RunPotions[slot] +local p = self.Potions[pid] +if p ~= nil then + self:SetText("/ui/DefaultGroup/CombatHud/PotionMenu/Title", p.name .. " — " .. p.desc) +end +self:SetEntityEnabled("/ui/DefaultGroup/CombatHud/PotionMenu", true)`, [{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'slot' }]), + method('ClosePotionMenu', `self.PotionMenuSlot = 0 +self:SetEntityEnabled("/ui/DefaultGroup/CombatHud/PotionMenu", false)`), + method('UsePotion', `if self.PotionMenuSlot <= 0 then + return +end +if self.CombatOver == true or self.TurnBusy == true or self.FxBusy == true then + self:Toast("지금은 사용할 수 없습니다") + return +end +local combat = _EntityService:GetEntityByPath("/ui/DefaultGroup/CombatHud") +local hand = _EntityService:GetEntityByPath("/ui/DefaultGroup/CardHand") +if combat == nil or combat.Enable ~= true or hand == nil or hand.Enable ~= true then + self:Toast("전투 중에만 사용할 수 있습니다") + return +end +local pid = self.RunPotions[self.PotionMenuSlot] +if pid == nil then + return +end +local p = self.Potions[pid] +if p == nil then + return +end +if p.effect == "heal" then + self.PlayerHp = math.min(self.PlayerHp + p.value, self.PlayerMaxHp) +elseif p.effect == "damage" then + self:DealDamageToTarget(p.value) + self:ShowDmgPop(self.TargetIndex, p.value) +elseif p.effect == "strength" then + self.PlayerStr = self.PlayerStr + p.value +elseif p.effect == "block" then + self.PlayerBlock = self.PlayerBlock + p.value +elseif p.effect == "energy" then + self.Energy = self.Energy + p.value +elseif p.effect == "weak" then + local tm = self.Monsters[self.TargetIndex] + if tm ~= nil and tm.alive == true then + tm.weak = tm.weak + p.value + end +end +table.remove(self.RunPotions, self.PotionMenuSlot) +self:Toast("물약 사용: " .. p.name) +self:ClosePotionMenu() +self:RenderPotions() +self:RenderPiles() +self:RenderCombat() +self:CheckCombatEnd()`), + method('TossPotion', `if self.PotionMenuSlot <= 0 then + return +end +local pid = self.RunPotions[self.PotionMenuSlot] +if pid ~= nil then + local p = self.Potions[pid] + table.remove(self.RunPotions, self.PotionMenuSlot) + if p ~= nil then + self:Toast("물약 버림: " .. p.name) + end +end +self:ClosePotionMenu() +self:RenderPotions()`), method('RenderRelics', `local names = "" if self.RunRelics ~= nil then for i = 1, #self.RunRelics do @@ -3193,6 +3306,13 @@ for i = 1, 3 do end self.ShopRelic = self.RelicPool[math.random(1, #self.RelicPool)] self.ShopRelicBought = false +local pkeys = {} +for pid, _ in pairs(self.Potions) do + table.insert(pkeys, pid) +end +table.sort(pkeys) +self.ShopPotion = pkeys[math.random(1, #pkeys)] +self.ShopPotionBought = false self:RenderShop() self:ShowState("shop")`), method('RenderShop', `self:SetText("/ui/DefaultGroup/ShopHud/Gold", "골드 " .. string.format("%d", self.Gold)) @@ -3223,6 +3343,19 @@ if rr ~= nil then re.SpriteGUIRendererComponent.Color = Color(0.7, 0.55, 0.85, 1) end end +end +local pp = self.Potions[self.ShopPotion] +if pp ~= nil then + self:SetText("/ui/DefaultGroup/ShopHud/Potion/Label", pp.name .. " — " .. pp.desc) + self:SetText("/ui/DefaultGroup/ShopHud/Potion/Price", string.format("%d", ${POTIONS.shopPrice}) .. " 골드") + local pe = _EntityService:GetEntityByPath("/ui/DefaultGroup/ShopHud/Potion") + if pe ~= nil and pe.SpriteGUIRendererComponent ~= nil then + if self.ShopPotionBought == true then + pe.SpriteGUIRendererComponent.Color = Color(0.2, 0.22, 0.26, 0.6) + else + pe.SpriteGUIRendererComponent.Color = Color(0.45, 0.7, 0.55, 1) + end + end end`), method('BuyRelic', `if self.ShopRelicBought == true then return @@ -3234,6 +3367,22 @@ self.Gold = self.Gold - ${RELIC_PRICE} self:AddRelic(self.ShopRelic) self.ShopRelicBought = true self:RenderShop() +self:RenderRun()`), + method('BuyPotion', `if self.ShopPotionBought == true then + return +end +if self.Gold < ${POTIONS.shopPrice} then + return +end +if self.RunPotions ~= nil and #self.RunPotions >= self.PotionSlots then + self:Toast("물약 슬롯이 가득 찼습니다") + return +end +if self:AddPotion(self.ShopPotion) == true then + self.Gold = self.Gold - ${POTIONS.shopPrice} + self.ShopPotionBought = true +end +self:RenderShop() self:RenderRun()`), method('BuyCard', `if self.ShopBought == nil or self.ShopBought[slot] == true then return