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

# The Tax effect
[[patches]]
[patches.pattern]
target = "functions/state_events.lua"
pattern = "func = (function()  update_hand_text({delay = 0, immediate = true}, {mult = 0, chips = 0, chip_total = math.floor(hand_chips*mult), level = '', handname = ''});play_sound('button', 0.9, 0.6);return true end)"
position = "at"
payload = "func = (function()  update_hand_text({delay = 0, immediate = true}, {mult = 0, chips = 0, chip_total = G.GAME.blind.cry_cap_score and G.GAME.blind:cry_cap_score(math.floor(hand_chips*mult)) or math.floor(hand_chips*mult), level = '', handname = ''});play_sound('button', 0.9, 0.6);return true end)"
match_indent = true

[[patches]]
[patches.pattern]
target = "functions/state_events.lua"
pattern = "ease_to = G.GAME.chips + math.floor(hand_chips*mult),"
position = "at"
payload = "ease_to = G.GAME.chips + (G.GAME.blind.cry_cap_score and G.GAME.blind:cry_cap_score(math.floor(hand_chips*mult)) or math.floor(hand_chips*mult)),"
match_indent = true

# Bunco (Magenta Dagger) and Cryptid (The Tax) compat
[[patches]]
[patches.pattern]
target = 'functions/state_events.lua'
pattern = "ease_to = G.GAME.chips + math.floor(hand_chips * mult) * (e and e.antiscore and -1 or 1),"
position = 'at'
match_indent = true
payload = '''ease_to = G.GAME.chips + (G.GAME.blind.cry_cap_score and G.GAME.blind:cry_cap_score(math.floor(hand_chips*mult)) or math.floor(hand_chips*mult)) * (e and e.antiscore and -1 or 1),'''

# Fix a crash related to undebuffing Jokers at end of round
[[patches]]
[patches.pattern]
target = "card.lua"
pattern = "if not G.P_CENTERS['e_'..(self.edition.type)].discovered then"
position = "at"
payload = "if self.edition.type and G.P_CENTERS['e_'..(self.edition.type)] and not G.P_CENTERS['e_'..(self.edition.type)].discovered then"
match_indent = true

# Blocks hands with more than 5 cards with Psychic
[[patches]]
[patches.pattern]
target = "blind.lua"
pattern = "if self.debuff.h_size_ge and #cards < self.debuff.h_size_ge then"
position = "before"
payload = '''
	if self.name == "The Psychic" and #cards > 5 then
		self.triggered = true
     		return true
	end
'''
match_indent = true

# Shut the up plz and ty
[[patches]]
[patches.pattern]
target = "blind.lua"
pattern = '''sendWarnMessage(("Blind object %s has debuff_card function, recalc_debuff is preferred"):format(obj.key), obj.set)'''
position = "at"
payload = '''
-- sendWarnMessage(("Blind object %s has debuff_card function, recalc_debuff is preferred"):format(obj.key), obj.set)
'''
match_indent = true

# track game overs by blinds on profiles
[[patches]]
[patches.pattern]
target = "functions/UI_definitions.lua"
pattern = '''local blind_choice = {config = G.GAME.blind.config.blind or G.P_BLINDS.bl_small}'''
position = "after"
payload = '''
local cry_defeated_by = blind_choice.config.name or "Small Blind"
if not G.PROFILES[G.SETTINGS.profile].cry_defeated_by_blind then G.PROFILES[G.SETTINGS.profile].cry_defeated_by_blind = {} end
G.PROFILES[G.SETTINGS.profile].cry_defeated_by_blind[cry_defeated_by] = (G.PROFILES[G.SETTINGS.profile].cry_defeated_by_blind[cry_defeated_by] or 0) + 1
check_for_unlock({ type = "lose_to_specific_blind", blind = cry_defeated_by, amount = G.PROFILES[G.SETTINGS.profile].cry_defeated_by_blind[cry_defeated_by] })
'''
match_indent = true


