[manifest]
version = "1.0.0"
dump_lua = true
priority = -5

# Listed pseudorandom probabilities in cards
[[patches]]
[patches.regex]
target = 'card.lua'
pattern = '''pseudorandom\((.*?)\) ?< ?G\.GAME\.probabilities\.normal ?\/ ?(.*?)( |\)|$)'''
position = 'at'
payload = "SMODS.pseudorandom_probability(self, $1, 1, $2)$3"

# The Wheel
# Don't have to modify loc_debuff_text since that's already done via override
# Also don't have for HUD_blind_debuff_prefix since SMODS makes it unused
[[patches]]
[patches.pattern]
target = "blind.lua"
pattern = '''if self.name == 'The Wheel' and pseudorandom(pseudoseed('wheel')) < G.GAME.probabilities.normal/7 then'''
position = "at"
match_indent = true
payload = '''if self.name == 'The Wheel' and SMODS.pseudorandom_probability(self, pseudoseed('wheel'), 1, 7, 'wheel') then'''

# Space Joker prob vars
[[patches]]
[patches.pattern]
target = 'card.lua'
pattern = '''elseif self.ability.name == 'Space Joker' then loc_vars = {''..(G.GAME and G.GAME.probabilities.normal or 1), self.ability.extra}'''
position = 'at'
payload = '''elseif self.ability.name == 'Space Joker' then loc_vars = {SMODS.get_probability_vars(self, 1, self.ability.extra, 'space')}'''
match_indent = true

# 8 ball prob vars
[[patches]]
[patches.pattern]
target = 'card.lua'
pattern = '''elseif self.ability.name == '8 Ball' then loc_vars = {''..(G.GAME and G.GAME.probabilities.normal or 1),self.ability.extra}'''
position = 'at'
payload = '''elseif self.ability.name == '8 Ball' then loc_vars = {SMODS.get_probability_vars(self, 1, self.ability.extra, '8ball')}'''
match_indent = true

# Gros michel prob vars
[[patches]]
[patches.pattern]
target = 'card.lua'
pattern = '''elseif self.ability.name == 'Gros Michel' then loc_vars = {self.ability.extra.mult, ''..(G.GAME and G.GAME.probabilities.normal or 1), self.ability.extra.odds}'''
position = 'at'
payload = '''elseif self.ability.name == 'Gros Michel' then loc_vars = {self.ability.extra.mult, SMODS.get_probability_vars(self, 1, self.ability.extra.odds, 'gros_michel')}'''
match_indent = true

# Business card prob vars
[[patches]]
[patches.pattern]
target = 'card.lua'
pattern = '''elseif self.ability.name == 'Business Card' then loc_vars = {''..(G.GAME and G.GAME.probabilities.normal or 1), self.ability.extra}'''
position = 'at'
payload = '''elseif self.ability.name == 'Business Card' then loc_vars = {SMODS.get_probability_vars(self, 1, self.ability.extra, 'business')}'''
match_indent = true

# Bloodstone prob vars
[[patches]]
[patches.pattern]
target = 'card.lua'
pattern = '''elseif self.ability.name == 'Bloodstone' then loc_vars = {''..(G.GAME and G.GAME.probabilities.normal or 1), self.ability.extra.odds, self.ability.extra.Xmult}'''
position = 'at'
payload = '''elseif self.ability.name == 'Bloodstone' then 
    local a, b = SMODS.get_probability_vars(self, 1, self.ability.extra.odds, 'bloodstone')
    loc_vars = {a, b, self.ability.extra.Xmult}'''
match_indent = true

# Cavendish prob vars
[[patches]]
[patches.pattern]
target = 'card.lua'
pattern = '''elseif self.ability.name == 'Cavendish' then loc_vars = {self.ability.extra.Xmult, ''..(G.GAME and G.GAME.probabilities.normal or 1), self.ability.extra.odds}'''
position = 'at'
payload = '''elseif self.ability.name == 'Cavendish' then loc_vars = {self.ability.extra.Xmult, SMODS.get_probability_vars(self, 1, self.ability.extra.odds, 'cavendish')}'''
match_indent = true

# Reserved parking prob vars
[[patches]]
[patches.pattern]
target = 'card.lua'
pattern = '''elseif self.ability.name == 'Reserved Parking' then loc_vars = {self.ability.extra.dollars, ''..(G.GAME and G.GAME.probabilities.normal or 1), self.ability.extra.odds}'''
position = 'at'
payload = '''elseif self.ability.name == 'Reserved Parking' then loc_vars = {self.ability.extra.dollars, SMODS.get_probability_vars(self, 1, self.ability.extra.odds, 'parking')}'''
match_indent = true

# Hallucination prob vars
[[patches]]
[patches.pattern]
target = 'card.lua'
pattern = '''elseif self.ability.name == 'Hallucination' then loc_vars = {G.GAME.probabilities.normal, self.ability.extra}'''
position = 'at'
payload = '''elseif self.ability.name == 'Hallucination' then loc_vars = {SMODS.get_probability_vars(self, 1, self.ability.extra, 'halu'..G.GAME.round_resets.ante)}'''
match_indent = true

# Glass card prob vars
[[patches]]
[patches.pattern]
target = 'functions/common_events.lua'
pattern = '''elseif _c.effect == 'Glass Card' then loc_vars = {cfg.Xmult, G.GAME.probabilities.normal, cfg.extra}'''
position = 'at'
payload = '''elseif _c.effect == 'Glass Card' then loc_vars = {cfg.Xmult, SMODS.get_probability_vars(card, 1, cfg.extra, 'glass')}'''
match_indent = true

# Wheel prob vars
[[patches]]
[patches.pattern]
target = 'functions/common_events.lua'
pattern = '''elseif _c.name == "The Wheel of Fortune" then loc_vars = {G.GAME.probabilities.normal, cfg.extra};  info_queue[#info_queue+1] = G.P_CENTERS.e_foil; info_queue[#info_queue+1] = G.P_CENTERS.e_holo; info_queue[#info_queue+1] = G.P_CENTERS.e_polychrome;'''
position = 'at'
payload = '''elseif _c.name == "The Wheel of Fortune" then 
    loc_vars = {SMODS.get_probability_vars(card, 1, cfg.extra, 'wheel_of_fortune')}
    info_queue[#info_queue+1] = G.P_CENTERS.e_foil
    info_queue[#info_queue+1] = G.P_CENTERS.e_holo
    info_queue[#info_queue+1] = G.P_CENTERS.e_polychrome'''
match_indent = true

# Modify Oops All 6s! behaviour - removed for back compat for now
# [[patches]]
# [patches.pattern]
# target = 'card.lua'
# match_indent = true
# position = 'at'
# pattern = '''
# for k, v in pairs(G.GAME.probabilities) do 
#     G.GAME.probabilities[k] = v*2
# end
# '''
# payload = '''
# -- removed by smods
# '''
# [[patches]]
# [patches.pattern]
# target = 'card.lua'
# match_indent = true
# position = 'at'
# pattern = '''
# for k, v in pairs(G.GAME.probabilities) do 
#     G.GAME.probabilities[k] = v/2
# end
# '''
# payload = '''
# -- removed by smods
# '''
# Add Opps All 6s! calculation
[[patches]]
[patches.pattern]
target = 'card.lua'
match_indent = true
position = 'after'
pattern = '''
elseif context.buying_card then
'''
payload = '''
elseif context.mod_probability and not context.blueprint and self.config.center_key == 'j_oops' then
    return {
        numerator = context.numerator * 2
    }
'''
