diff --git a/lovely/pool.toml b/lovely/pool.toml index c21ea79ea..8a3a73eb2 100644 --- a/lovely/pool.toml +++ b/lovely/pool.toml @@ -135,7 +135,15 @@ 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 SMODS.showman(v.key)) and''' +payload = '''elseif not (G.GAME.used_jokers[v.key] and not pool_opts.allow_duplicates and not SMODS.showman(v.key) and not (v.set == "Voucher" and SMODS.voucherman(v.key))) and''' + +[[patches]] +[patches.pattern] +target = 'functions/common_events.lua' +pattern = 'if not G.GAME.used_vouchers[v.key] then ' +match_indent = true +position = 'at' +payload = '''if not (G.GAME.used_vouchers[v.key] and not pool_opts.allow_duplicates and not SMODS.voucherman(v.key) then''' [[patches]] [patches.pattern] diff --git a/lovely/voucher.toml b/lovely/voucher.toml new file mode 100644 index 000000000..7b546052a --- /dev/null +++ b/lovely/voucher.toml @@ -0,0 +1,74 @@ +[manifest] +version = "1.0.0" +dump_lua = true +priority = -4 #latest priority, since lovely dump was used as reference for patch targets. + +## used_vouchers entry should be a number to allow for checking voucher count easily +# back.lua +[[patches]] +[patches.pattern] +target = "back.lua" +pattern = "G.GAME.used_vouchers[self.effect.config.voucher] = true" +position = "at" +payload = "G.GAME.used_vouchers[self.effect.config.voucher] = (G.GAME.used_vouchers[self.effect.config.voucher] or 0) + 1" +match_indent = true + +[[patches]] +[patches.pattern] +target = "back.lua" +pattern = "G.GAME.used_vouchers[v ] = true" +position = "at" +payload = "G.GAME.used_vouchers[v] = (G.GAME.used_vouchers[v] or 0) + 1" +match_indent = true + +# card.lua +[[patches]] +[patches.pattern] +target = "card.lua" +pattern = "G.GAME.used_vouchers[self.config.center_key] = true" +position = "at" +payload = "G.GAME.used_vouchers[self.config.center_key] = (G.GAME.used_vouchers[self.config.center.key] or 0) + 1" +match_indent = true + +# game.lua +[[patches]] +[patches.pattern] +target = "game.lua" +pattern = "G.GAME.used_vouchers[v.id] = true" +position = "at" +payload = "G.GAME.used_vouchers[v.id] = (G.GAME.used_vouchers[v.id] or 0) + 1" +match_indent = true + +## unlocks should count duplicate vouchers +# common_events.lua +[[patches]] +[patches.pattern] +target = "functions/common_events.lua" +pattern = ''' +for k, v in pairs(G.GAME.used_vouchers) do + _v = _v + 1 +end +''' +position = "at" +payload = ''' +for k, v in pairs(G.GAME.used_vouchers) do + _v = _v + (type(v) == "number" and v or 1) +end +''' +match_indent = true + +[[patches]] +[patches.pattern] +target = "functions/common_events.lua" +pattern = ''' +for k, v in pairs(G.GAME.used_vouchers) do + vouchers_redeemed = vouchers_redeemed + 1 +end +''' +position = "at" +payload = ''' +for k, v in pairs(G.GAME.used_vouchers) do + vouchers_redeemed = vouchers_redeemed + (type(v) == "number" and v or 1) +end +''' +match_indent = true \ No newline at end of file diff --git a/lsp_def/utils.lua b/lsp_def/utils.lua index da02e216f..e81607798 100644 --- a/lsp_def/utils.lua +++ b/lsp_def/utils.lua @@ -768,4 +768,10 @@ function SMODS.challenge_is_unlocked(challenge, k) end --- a custom `func` to modify the values in specific ways. `hands` and `parameters` can --- be limited to specific ones, or default to using all of `G.GAME.hands` and `SMODS.Scoring_Parameters`. --- Use `level_up` to control whether the level of the hand is upgraded. - function SMODS.upgrade_poker_hands(args) end \ No newline at end of file + function SMODS.upgrade_poker_hands(args) end + +---@param voucher_key string The key of the voucher being checked +---@return boolean +--- Similar to SMODS.showman, but works for duplicate voucher spawning. +--- Returns `true` if duplicates of the voucher with the given key should spawn. +function SMODS.voucherman(voucher_key) end \ No newline at end of file diff --git a/src/utils.lua b/src/utils.lua index 0ff3f3ad2..abfd8b3ff 100644 --- a/src/utils.lua +++ b/src/utils.lua @@ -2678,6 +2678,13 @@ function SMODS.showman(card_key) return false end +function SMODS.voucherman(voucher_key) + if SMODS.create_card_allow_duplicates then + return true + end + return false +end + function SMODS.four_fingers(hand_type) if next(SMODS.find_card('j_four_fingers')) then return 4