diff --git a/lovely/interest_changes.toml b/lovely/interest_changes.toml new file mode 100644 index 000000000..ccfb6b431 --- /dev/null +++ b/lovely/interest_changes.toml @@ -0,0 +1,32 @@ +[manifest] +version = "1.0.0" +dump_lua = true +priority = 0 + +[[patches]] +[patches.regex] +target = 'functions/common_events.lua' +pattern = 'G\.GAME\.interest_cap/5' +position = 'at' +payload = 'SMODS.get_interest()["interest_cap"]' + +[[patches]] +[patches.regex] +target = 'functions/common_events.lua' +pattern = 'vars = \{G\.GAME\.interest_amount, 5' +position = 'at' +payload = 'vars = {G.GAME.interest_amount, SMODS.get_interest()["per_interest"]' + +[[patches]] +[patches.regex] +target = 'functions/state_events.lua' +pattern = 'G\.GAME\.interest_cap/5' +position = 'at' +payload = 'SMODS.get_interest()["interest_cap"]' + +[[patches]] +[patches.regex] +target = 'functions/state_events.lua' +pattern = 'G\.GAME\.dollars/5' +position = 'at' +payload = 'G.GAME.dollars/SMODS.get_interest()["per_interest"]' diff --git a/src/utils.lua b/src/utils.lua index fdeb63132..21d8ce228 100644 --- a/src/utils.lua +++ b/src/utils.lua @@ -2868,4 +2868,35 @@ function ease_dollars(mod, instant) from_consumeable = (G.STATE == G.STATES.PLAY_TAROT) or nil, from_scoring = (G.STATE == G.STATES.HAND_PLAYED) or nil, }) -end \ No newline at end of file +end + +function SMODS.get_interest() + local add_interest_cap = 0 + local add_per_interest = 0 + for _, area in ipairs(SMODS.get_card_areas('jokers')) do + for _, _card in ipairs(area.cards) do + local ret = _card:calculate_interest() + + -- TARGET: calc_interest per card + if ret then + if ret then + if ret.add_cap then + add_interest_cap = add_interest_cap + ret.add_cap + end + if ret.add_per_interest then + add_per_interest = add_per_interest + ret.add_per_interest + end + end + end + end + end + return {interest_cap = add_interest_cap + (G.GAME.extra_interest_cap or 0) + G.GAME.interest_cap/5, per_interest = add_per_interest + (G.GAME.extra_per_interest or 0) + 5} +end + +function Card:calculate_interest() + if not self:can_calculate() then return end + local obj = self.config.center + if obj.calc_interest and type(obj.calc_interest) == 'function' then + return obj:calc_interest(self) + end +end