From 671af56191f4c2580a24d03d622ee531073c6570 Mon Sep 17 00:00:00 2001 From: Emik Date: Fri, 20 Feb 2026 18:54:48 +0100 Subject: [PATCH] Completely redesign coca cola phone --- localization/en-us.lua | 2 +- src/charm.lua | 63 ++++++++++++++++++++++++++++++++++++++---- 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/localization/en-us.lua b/localization/en-us.lua index 00acc17..57b08bd 100644 --- a/localization/en-us.lua +++ b/localization/en-us.lua @@ -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", diff --git a/src/charm.lua b/src/charm.lua index 7512309..3b22f5c 100644 --- a/src/charm.lua +++ b/src/charm.lua @@ -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 {