Skip to content
Draft
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
10 changes: 9 additions & 1 deletion lovely/pool.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
74 changes: 74 additions & 0 deletions lovely/voucher.toml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 7 additions & 1 deletion lsp_def/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
7 changes: 7 additions & 0 deletions src/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down