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

# This is sacrilegious
[[patches]]
[patches.pattern]
target = "game.lua"
pattern = "self.GAME.starting_deck_size = #G.playing_cards"
position = "before"
payload = '''
if G.GAME.modifiers.cry_ccd then
    for k, v in pairs(G.playing_cards) do
        v:set_ability(get_random_consumable('cry_ccd',{"no_doe", "no_grc"}, nil, nil, true), true, nil)
    end
end
'''
match_indent = true

# Aura use conditions
[[patches]]
[patches.pattern]
target = "card.lua"
pattern = "if G.hand and (#G.hand.highlighted == 1) and G.hand.highlighted[1] and (not G.hand.highlighted[1].edition) then return true end"
position = "at"
payload = '''
if self.area ~= G.hand then
    return G.hand and (#G.hand.highlighted == 1) and G.hand.highlighted[1] and (not G.hand.highlighted[1].edition)
else
    local idx = 1
    if G.hand.highlighted[1] == self then
        local idx = 2
    end
    return (#G.hand.highlighted == 2) and (not G.hand.highlighted[idx].edition)
end
'''
match_indent = true

# Prevent counting CCD consumables for pack uses
[[patches]]
[patches.pattern]
target = "functions/button_callbacks.lua"
pattern = "if area == G.consumeables then"
position = "at"
payload = "if area == G.consumeables or area == G.hand then"
match_indent = true

# Fix bugs from removing CCD
# This really shouldn't be in the card drawing code, but it doesn't really matter since that's where it crashes anyway lol
[[patches]]
[patches.pattern]
target = "card.lua"
pattern = "if not self.config.center.discovered and (self.ability.consumeable or self.config.center.unlocked) and not self.config.center.demo and not self.bypass_discovery_center then"
position = "before"
payload = "if self.ability.set == 'Enhanced' then self.ability.consumeable = nil end"
match_indent = true
