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

# Lapio softlock mechanic
[[patches]]
[patches.pattern]
target = "functions/common_events.lua"
pattern = "if (not v.config.softlock or G.GAME.hands[v.config.hand_type].played > 0) then"
position = "at"
payload = '''
local softlocked = true
if not v.config.softlock then
    softlocked = false
elseif v.config.hand_type then
    softlocked = G.GAME.hands[v.config.hand_type].played == 0
elseif v.config.hand_types then
    for _, h in pairs(v.config.hand_types) do
        if (G.GAME.hands[h].played or 0) > 0 then
            softlocked = false
        end
    end
end
if not softlocked then
'''
match_indent = true

# context.cry_observatory
[[patches]]
[patches.pattern]
target = '=[SMODS _ "src/game_object.lua"]'
pattern = '''if
    context.other_consumeable and'''
position = "at"
payload = '''
if context.other_consumeable then
    local ctx = SMODS.shallow_copy(context)
    ctx.cry_observatory = card
    ctx.other_consumeable = nil
    local ret = context.other_consumeable:calculate_joker(ctx)
    if ret then SMODS.calculate_effect(ret, context.other_consumeable) end
elseif context.other_consumeable and
    not ret and
'''
match_indent = true
