Merge pull request #763 from argonui/hand-helpers

Updated hand zone handling for helpers
This commit is contained in:
Chr1Z 2024-07-08 18:06:01 +02:00 committed by GitHub
commit 905bbb9f5c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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