balatro-mods/smods-main/lovely/seal.toml

222 lines
6.1 KiB
TOML

[manifest]
version = "1.0.0"
dump_lua = true
priority = -10
### Seal API
# Card:open()
[[patches]]
[patches.regex]
target = 'card.lua'
pattern = '''
(?<indent>[\t ]*)local seal_rate = 10
[\n\t ]*local seal_poll = pseudorandom\(pseudoseed\('stdseal'..G.GAME.round_resets.ante\)\)
[\n\t ]*if seal_poll > 1 - 0.02\*seal_rate then
[\n\t ]*local seal_type = pseudorandom\(pseudoseed\('stdsealtype'..G.GAME.round_resets.ante\)\)
[\n\t ]*if seal_type > 0.75 then card:set_seal\('Red'\)
[\n\t ]*elseif seal_type > 0.5 then card:set_seal\('Blue'\)
[\n\t ]*elseif seal_type > 0.25 then card:set_seal\('Gold'\)
[\n\t ]*else card:set_seal\('Purple'\)
[\n\t ]*end
[\n\t ]*end'''
position = 'at'
line_prepend = '$indent'
payload = '''
card:set_seal(SMODS.poll_seal({mod = 10}))'''
# Card:calculate_joker()
[[patches]]
[patches.regex]
target = 'card.lua'
pattern = '''
(?<indent>[\t ]*)local seal_type = pseudorandom\(pseudoseed\('certsl'\)\)
[\n\t ]*if seal_type > 0.75 then _card:set_seal\('Red', true\)
[\n\t ]*elseif seal_type > 0.5 then _card:set_seal\('Blue', true\)
[\n\t ]*elseif seal_type > 0.25 then _card:set_seal\('Gold', true\)
[\n\t ]*else _card:set_seal\('Purple', true\)
[\n\t ]*end'''
position = 'at'
line_prepend = '$indent'
payload = '''_card:set_seal(SMODS.poll_seal({guaranteed = true, type_key = 'certsl'}))'''
# get_badge_colour()
[[patches]]
[patches.pattern]
target = 'functions/UI_definitions.lua'
pattern = 'return G.BADGE_COL[key] or {1, 0, 0, 1}'
position = 'before'
match_indent = true
payload = '''
for k, v in pairs(SMODS.Seals) do
G.BADGE_COL[k:lower()..'_seal'] = v.badge_colour
end'''
# Card:calculate_seal()
[[patches]]
[patches.regex]
target = "card.lua"
pattern = 'function Card:calculate_seal\(context\)\n(?<indent>[\t ]*)if self.debuff then return nil end'
position = 'after'
line_prepend = '$indent'
payload = '''
local obj = G.P_SEALS[self.seal] or {}
if obj.calculate and type(obj.calculate) == 'function' then
local o = obj:calculate(self, context)
if o then
if not o.card then o.card = self end
return o
end
end'''
# Card:update()
[[patches]]
[patches.pattern]
target = "card.lua"
pattern = 'if G.STAGE == G.STAGES.RUN then'
position = 'before'
match_indent = true
payload = '''
local obj = G.P_SEALS[self.seal] or {}
if obj.update and type(obj.update) == 'function' then
obj:update(self, dt)
end'''
# Card:get_p_dollars()
[[patches]]
[patches.regex]
target = "card.lua"
pattern = '''(?<indent>[\t ]*)if (?<cond>self\.seal == 'Gold' then\n)'''
position = 'at'
line_prepend = '$indent'
payload = '''
local obj = G.P_SEALS[self.seal] or {}
if obj.get_p_dollars and type(obj.get_p_dollars) == 'function' then
ret = ret + obj:get_p_dollars(self)
elseif $cond'''
# generate_card_ui()
[[patches]]
[patches.pattern]
target = 'functions/common_events.lua'
pattern = "if v == 'gold_seal'*"
match_indent = true
position = 'before'
payload = '''
local seal = G.P_SEALS[v] or G.P_SEALS[SMODS.Seal.badge_to_key[v] or '']
if seal then
info_queue[#info_queue+1] = seal
else'''
[[patches]]
[patches.pattern]
target = 'functions/common_events.lua'
pattern = "if v == 'purple_seal'*"
match_indent = true
position = 'after'
payload = 'end'
[[patches]]
[patches.regex]
target = 'functions/common_events.lua'
position = 'at'
pattern = '''\{key = (?<badge>'.*?_seal'), set = 'Other'\}'''
payload = '''G.P_SEALS[$badge] or G.P_SEALS[SMODS.Seal.badge_to_key[$badge] or '']'''
# Card:update_alert()
[[patches]]
[patches.pattern]
target = 'card.lua'
pattern = "function Card:update_alert()"
match_indent = true
position = 'after'
payload = '''
if self.ability.set == 'Default' and self.config.center and self.config.center.key == 'c_base' and self.seal then
if G.P_SEALS[self.seal].alerted and self.children.alert then
self.children.alert:remove()
self.children.alert = nil
elseif not G.P_SEALS[self.seal].alerted and not self.children.alert and G.P_SEALS[self.seal].discovered then
self.children.alert = UIBox{
definition = create_UIBox_card_alert(),
config = {align="tli",
offset = {x = 0.1, y = 0.1},
parent = self}
}
end
end'''
# Card:hover()
[[patches]]
[patches.pattern]
target = 'card.lua'
pattern = "G:save_progress()"
match_indent = false
position = "after"
payload = '''
elseif self.children.alert and self.seal and not G.P_SEALS[self.seal].alerted then
G.P_SEALS[self.seal].alerted = true
G:save_progress()'''
# Game:init_item_prototypes()
[[patches]]
[patches.regex]
target = 'game.lua'
pattern = '''(?<indent>[\t ]*)Gold =[ {A-z=1-4,"}\n]*},[\n\t ]*}'''
position = 'at'
line_prepend = '$indent'
payload = '''
Red = {order = 1, discovered = false, set = "Seal"},
Blue = {order = 2, discovered = false, set = "Seal"},
Gold = {order = 3, discovered = false, set = "Seal"},
Purple = {order = 4, discovered = false, set = "Seal"},
}
'''
# Card:set_seal()
[[patches]]
[patches.pattern]
target = 'card.lua'
pattern = '''G.CONTROLLER.locks.seal = true'''
position = 'after'
match_indent = true
payload = '''local sound = G.P_SEALS[_seal].sound or {sound = 'gold_seal', per = 1.2, vol = 0.4}'''
[[patches]]
[patches.pattern]
target = 'card.lua'
pattern = '''play_sound('gold_seal', 1.2, 0.4)'''
position = 'at'
match_indent = true
payload = '''play_sound(sound.sound, sound.per, sound.vol)'''
## Populate Seal Ability Table
[[patches]]
[patches.pattern]
target = 'card.lua'
pattern = '''self.seal = _seal'''
position = 'after'
match_indent = true
payload = '''
self.ability.seal = {}
for k, v in pairs(G.P_SEALS[_seal].config or {}) do
if type(v) == 'table' then
self.ability.seal[k] = copy_table(v)
else
self.ability.seal[k] = v
end
end
'''
[[patches]]
[patches.pattern]
target = 'functions/common_events.lua'
pattern = '''new_card:set_seal(other.seal, true)'''
position = 'after'
match_indent = true
payload = '''
if other.seal then
for k, v in pairs(other.ability.seal or {}) do
if type(v) == 'table' then
new_card.ability.seal[k] = copy_table(v)
else
new_card.ability.seal[k] = v
end
end
end
'''