Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lovely/better_calc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2038,6 +2038,24 @@ if ret then
end
'''

# Add context.modify_final_cashout
[[patches]]
[patches.pattern]
target = "functions/state_events.lua"
pattern = '''
dollars = dollars + G.GAME.interest_amount*math.min(math.floor(G.GAME.dollars/5), G.GAME.interest_cap/5)
end
'''
position = "after"
payload = '''

SMODS.cashout_pitch = pitch; SMODS.cashout_index = i; SMODS.cashout_dollars = dollars
SMODS.calculate_context({modify_final_cashout = true, dollars = dollars})
dollars = SMODS.cashout_dollars
SMODS.cashout_pitch = nil; SMODS.cashout_index = nil; SMODS.cashout_dollars = nil
'''
match_indent = false

# Reload SMODS.last_hand
[[patches]]
[patches.pattern]
Expand All @@ -2061,3 +2079,4 @@ if saveTable then
end
end
'''
match_indent = false
15 changes: 13 additions & 2 deletions src/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,11 @@ SMODS.calculate_individual_effect = function(effect, scored_card, key, amount, f
end
end

if key == 'cashout_mod' then
add_round_eval_row({dollars = amount, bonus = true, name='joker'..SMODS.cashout_index, pitch = SMODS.cashout_pitch, card = scored_card})
return { [key] = amount }
end

if key == 'debuff' then
return { [key] = amount, debuff_source = scored_card }
end
Expand Down Expand Up @@ -1475,7 +1480,7 @@ SMODS.other_calculation_keys = {
'message',
'level_up', 'func',
'numerator', 'denominator',
'modify',
'modify', 'cashout_mod',
'no_destroy', 'prevent_trigger',
'replace_scoring_name', 'replace_display_name', 'replace_poker_hands',
'shop_create_flags',
Expand All @@ -1489,7 +1494,7 @@ SMODS.silent_calculation = {
cards_to_draw = true,
func = true, extra = true,
numerator = true, denominator = true,
no_destroy = true
no_destroy = true, cashout_mod = true
}

SMODS.insert_repetitions = function(ret, eval, effect_card, _type)
Expand Down Expand Up @@ -1831,6 +1836,12 @@ function SMODS.update_context_flags(context, flags)
if flags.denominator then context.denominator = flags.denominator end
if flags.cards_to_draw then context.amount = flags.cards_to_draw end
if flags.saved then context.game_over = false end
if flags.cashout_mod then
context.dollars = context.dollars + flags.cashout_mod
SMODS.cashout_dollars = context.dollars
SMODS.cashout_index = SMODS.cashout_index + 1
SMODS.cashout_pitch = SMODS.cashout_pitch + 0.06
end
if flags.modify then
-- insert general modified value updating here
if context.modify_ante then context.modify_ante = flags.modify end
Expand Down