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
21 changes: 21 additions & 0 deletions lovely/better_calc.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1927,6 +1927,27 @@ payload = '''
self.from_load = true
'''

# context.set_cost
[[patches]]
[patches.pattern]
target = 'card.lua'
match_indent = true
position = 'at'
pattern = '''
self.sell_cost = math.max(1, math.floor(self.cost/2)) + (self.ability.extra_value or 0)
'''
payload = '''
if not loading then
local cost_flags = SMODS.calculate_context({set_cost = true, cost = self.cost, card = self}) or {}
if cost_flags.cost then self.cost = cost_flags.cost end
end
self.sell_cost = math.max(1, math.floor(self.cost/2)) + (self.ability.extra_value or 0)
if not loading then
local sell_flags = SMODS.calculate_context({set_sell_cost = true, sell_cost = self.sell_cost, card = self}) or {}
if sell_flags.sell_cost then self.sell_cost = sell_flags.sell_cost end
end
'''

# Fix Campfire 'upgrading' when it is sold
[[patches]]
[patches.pattern]
Expand Down
8 changes: 6 additions & 2 deletions src/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@ SMODS.calculate_individual_effect = function(effect, scored_card, key, amount, f
return key
end

if key == 'remove' or key == 'debuff_text' or key == 'cards_to_draw' or key == 'numerator' or key == 'denominator' or key == 'no_destroy' or
if key == 'remove' or key == 'debuff_text' or key == 'cards_to_draw' or key == 'numerator' or key == 'denominator' or key == 'no_destroy' or key == 'cost' or key == 'sell_cost' or
key == 'replace_scoring_name' or key == 'replace_display_name' or key == 'replace_poker_hands' or key == 'modify' or key == 'shop_create_flags' then
return { [key] = amount }
end
Expand Down Expand Up @@ -1465,6 +1465,7 @@ SMODS.other_calculation_keys = {
'numerator', 'denominator',
'modify',
'no_destroy', 'prevent_trigger',
'cost', 'sell_cost',
'replace_scoring_name', 'replace_display_name', 'replace_poker_hands',
'shop_create_flags',
'extra',
Expand All @@ -1477,7 +1478,8 @@ SMODS.silent_calculation = {
cards_to_draw = true,
func = true, extra = true,
numerator = true, denominator = true,
no_destroy = true
no_destroy = true,
cost = true, sell_cost = true,
}

SMODS.insert_repetitions = function(ret, eval, effect_card, _type)
Expand Down Expand Up @@ -1818,6 +1820,8 @@ function SMODS.update_context_flags(context, flags)
if flags.numerator then context.numerator = flags.numerator end
if flags.denominator then context.denominator = flags.denominator end
if flags.cards_to_draw then context.amount = flags.cards_to_draw end
if flags.cost then context.cost = flags.cost end
if flags.sell_cost then context.sell_cost = flags.sell_cost end
if flags.saved then context.game_over = false end
if flags.modify then
-- insert general modified value updating here
Expand Down