Completely redesign coca cola phone

This commit is contained in:
Emik 2026-02-20 18:54:48 +01:00
parent b57d52a2ae
commit 671af56191
Signed by: emik
GPG key ID: 6B0CD72A5E503BDF
2 changed files with 59 additions and 6 deletions

View file

@ -28,7 +28,7 @@ return {
BakeryCharm = {
BakeryCharm_Roland_cocacola = {
name = "coca cola phone",
text = {"Cards cannot", "be {C:attention}debuffed"},
text = {"Values on consumables", "increase by {C:attention}1"},
},
BakeryCharm_Roland_fat = {
name = "fat i phone",

View file

@ -1,4 +1,4 @@
local _, q = unpack(... or require "lib.shared")
local f, q = unpack(... or require "lib.shared")
local mod = SMODS.current_mod
SMODS.Atlas {
@ -33,6 +33,49 @@ local charm = (function()
end
end)()
local function add_to_consumable_ability_by(n)
local function new(v)
return type(v) == "number" and v + n or type(v) == "table" and f(v):map(new):table() or v
end
---@param card Card
return function(card)
local ability = card.ability or {}
local function go(key)
---@type { [string]: number }|number
local value = ability[key]
--print(key)
if not value then
return
end
if type(value) == "number" then
ability[key] = value + n
return
end
if type(value) ~= "table" then
return
end
local new_value = f(value):map(new):table()
f(new_value):each(function(v, k)
ability[k] = v
end)
ability[key] = new_value
end
local center_key = (card.config or {}).center_key
if center_key and center_key:sub(1, 2) == "c_" then
f {"extra", "consumeable"}:each(go)
end
end
end
charm {
key = "wii",
pronouns = "they_them",
@ -119,15 +162,25 @@ end
charm {
key = "cocacola",
pronouns = "he_they",
equip = function()
f(G.consumeables.cards):each(add_to_consumable_ability_by(1))
end,
unequip = function()
f(G.consumeables.cards):each(add_to_consumable_ability_by(-1))
end,
}
local orig_debuff_card = SMODS.debuff_card
local orig_set_ability = Card.set_ability
---@diagnostic disable-next-line: duplicate-set-field
function SMODS.debuff_card(...)
if G.GAME.Bakery_charm ~= "BakeryCharm_Roland_cocacola" then
return orig_debuff_card(...)
function Card:set_ability(center, initial, delay_sprites, ...)
local ret = orig_set_ability(self, center, initial, delay_sprites, ...)
if G.GAME.Bakery_charm == "BakeryCharm_Roland_cocacola" then
add_to_consumable_ability_by(1)(self)
end
return ret
end
charm {