updated hand zone handling for heleprs

This commit is contained in:
Chr1Z93 2024-07-08 17:55:18 +02:00
parent 7f9e6292fd
commit 2d828ee4db

View File

@ -201,15 +201,19 @@ function onObjectEnterZone(zone, object)
local trash = guidReferenceApi.getObjectByOwnerAndType(matcolor, "Trash") local trash = guidReferenceApi.getObjectByOwnerAndType(matcolor, "Trash")
trash.putObject(object) trash.putObject(object)
elseif zone.type == "Hand" and object.type == "Card" then elseif zone.type == "Hand" and object.type == "Card" then
-- make sure the card is face-up
if object.is_face_down then if object.is_face_down then
object.flip() object.flip()
end end
-- disable any helpers on the card
if object.hasTag("CardWithHelper") then if object.hasTag("CardWithHelper") then
object.clearContextMenu() object.call("setHelperState", false)
object.call("shutOff")
end end
-- maybe reset data about sealed tokens (if that function exists)
if object.hasTag("CardThatSeals") then if object.hasTag("CardThatSeals") then
local func = object.getVar("resetSealedTokens") -- check if function exists (it won't for older custom content) local func = object.getVar("resetSealedTokens")
if func ~= nil then if func ~= nil then
object.call("resetSealedTokens") object.call("resetSealedTokens")
end end
@ -222,9 +226,12 @@ function onObjectLeaveZone(zone, object)
-- 1 frame delay to avoid error messages when exiting the game -- 1 frame delay to avoid error messages when exiting the game
Wait.frames( Wait.frames(
function() function()
-- end here if one of the objects doesn't exist
if zone.isDestroyed() or object.isDestroyed() then return end if zone.isDestroyed() or object.isDestroyed() then return end
-- resync the state of the helper on the card with the option panel
if zone.type == "Hand" and object.hasTag("CardWithHelper") then if zone.type == "Hand" and object.hasTag("CardWithHelper") then
object.call("updateDisplay") object.call("syncDisplayWithOptionPanel")
end end
end, 1) end, 1)
end end