balatro-mods/smods-old-calc/lovely/pool.toml

186 lines
5.5 KiB
TOML

[manifest]
version = "1.0.0"
dump_lua = true
priority = -10
### Functions that affect random selection from pools
# pseudorandom_element()
# TODO special cases for now
[[patches]]
[patches.pattern]
target = "functions/misc_functions.lua"
pattern = "function pseudorandom_element(_t, seed)"
position = "at"
payload = """function pseudorandom_element(_t, seed, args)
-- TODO special cases for now
-- Preserves reverse nominal order for Suits, nominal+face_nominal order for Ranks
-- for vanilla RNG
if _t == SMODS.Suits then
_t = SMODS.Suit:obj_list(true)
end
if _t == SMODS.Ranks then
_t = SMODS.Rank:obj_list()
end
"""
match_indent = true
[[patches]]
[patches.pattern]
target = "functions/misc_functions.lua"
pattern = "keys[#keys+1] = {k = k,v = v}"
position = "at"
payload = """
local keep = true
local in_pool_func =
args and args.in_pool
or type(v) == 'table' and type(v.in_pool) == 'function' and v.in_pool
or _t == G.P_CARDS and function(c)
--Handles special case for Erratic Deck
local initial_deck = args and args.starting_deck or false
return not (
type(SMODS.Ranks[c.value].in_pool) == 'function' and not SMODS.Ranks[c.value]:in_pool({initial_deck = initial_deck, suit = c.suit})
or type(SMODS.Suits[c.suit].in_pool) == 'function' and not SMODS.Suits[c.suit]:in_pool({initial_deck = initial_deck, rank = c.value})
)
end
if in_pool_func then
keep = in_pool_func(v, args)
end
if keep then
keys[#keys+1] = {k = k,v = v}
end"""
match_indent = true
# fixes pseudorandom_element on an empty list
# nil, nil is returned in that case
[[patches]]
[patches.pattern]
target = "functions/misc_functions.lua"
pattern = "local key = keys[math.random(#keys)].k"
position = "before"
payload = "if #keys == 0 then return nil, nil end"
match_indent = true
## get_current_pool()
# Centers
[[patches]]
[patches.pattern]
target = 'functions/common_events.lua'
pattern = "else _starting_pool, _pool_key = G.P_CENTER_POOLS[_type], _type..(_append or '')"
match_indent = true
position = 'before'
payload = '''
elseif SMODS.ObjectTypes[_type] and SMODS.ObjectTypes[_type].rarities then
local rarities = SMODS.ObjectTypes[_type].rarities
local rarity
if _legendary and rarities.legendary then
rarity = rarities.legendary.key
else
rarity = _rarity or SMODS.poll_rarity(_type, 'rarity_'.._type..G.GAME.round_resets.ante..(_append or ''))
end
_starting_pool, _pool_key = SMODS.ObjectTypes[_type].rarity_pools[rarity], _type..rarity..(_append or '')'''
[[patches]]
[patches.pattern]
target = 'functions/common_events.lua'
pattern = "if _type == 'Tarot' or _type == 'Tarot_Planet' then _pool[#_pool + 1] = \"c_strength\""
match_indent = true
position = 'at'
payload = '''
if SMODS.ObjectTypes[_type] and SMODS.ObjectTypes[_type].default and G.P_CENTERS[SMODS.ObjectTypes[_type].default] then
_pool[#_pool+1] = SMODS.ObjectTypes[_type].default
elseif _type == 'Tarot' or _type == 'Tarot_Planet' then _pool[#_pool + 1] = "c_strength"'''
[[patches]]
[patches.pattern]
target = 'functions/common_events.lua'
pattern = "if v.name == 'Black Hole' or v.name == 'The Soul' then"
match_indent = true
position = 'at'
payload = "if v.name == 'Black Hole' or v.name == 'The Soul' or v.hidden then"
[[patches]]
[patches.pattern]
target = 'functions/common_events.lua'
pattern = "if _type == 'Enhanced' then"
match_indent = true
position = 'before'
payload = '''
local in_pool, pool_opts
if v.in_pool and type(v.in_pool) == 'function' then
in_pool, pool_opts = v:in_pool({ source = _append })
end
pool_opts = pool_opts or {}
'''
[[patches]]
[patches.pattern]
target = 'functions/common_events.lua'
pattern = 'elseif not (G.GAME.used_jokers[v.key] and not next(find_joker("Showman"))) and'
match_indent = true
position = 'at'
payload = '''elseif not (G.GAME.used_jokers[v.key] and not pool_opts.allow_duplicates and not next(find_joker("Showman"))) and'''
[[patches]]
[patches.pattern]
target = 'functions/common_events.lua'
pattern = "if add and not G.GAME.banned_keys[v.key] then"
match_indent = true
position = 'before'
payload = '''
if v.in_pool and type(v.in_pool) == 'function' then
add = in_pool and (add or pool_opts.override_base_checks)
end
'''
## G.GAME.used_jokers now checks keys, not names
# Card:set_ability()
# Remove the old center from `used_jokers` if set_ability overrides
[[patches]]
[patches.pattern]
target = "card.lua"
pattern = "local old_center = self.config.center"
position = 'after'
payload = '''
if old_center and not next(SMODS.find_card(old_center.key, true)) then
G.GAME.used_jokers[old_center.key] = nil
end'''
match_indent = true
[[patches]]
[patches.regex]
target = "card.lua"
pattern = '''
(?<indent>[\t ]*)for k, v in pairs\(G\.P_CENTERS\) do
[\t ]*if v\.name == self\.ability\.name then
[\t ]*G\.GAME\.used_jokers\[k\] = true
[\t ]*end
[\t ]*end'''
position = "at"
payload = '''
if self.config.center.key then
G.GAME.used_jokers[self.config.center.key] = true
end
'''
line_prepend = "$indent"
# Card:remove()
[[patches]]
[patches.regex]
target = "card.lua"
pattern = '''
(?<indent>[\t ]*)for k, v in pairs\(G\.P_CENTERS\) do
[\t ]*if v\.name == self\.ability\.name then
[\t ]*if not next\(find_joker\(self\.ability\.name, true\)\) then
[\t ]*G\.GAME\.used_jokers\[k\] = nil
[\t ]*end
[\t ]*end
[\t ]*end'''
position = "at"
payload = '''
if not next(SMODS.find_card(self.config.center.key, true)) then
G.GAME.used_jokers[self.config.center.key] = nil
end'''
line_prepend = "$indent"