Merge pull request #700 from Whimsical-Cloudheart/patch-1

Added confirmation dialog to discard hotkey
This commit is contained in:
Chr1Z 2024-05-28 13:56:22 +02:00 committed by GitHub
commit 33c8b1377a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -135,11 +135,17 @@ function discardObject(playerColor, hoveredObject)
return
end
-- warning for locations since these are usually not meant to be discarded
if hoveredObject.hasTag("Location") then
broadcastToAll("Watch out: A location was discarded.", "Yellow")
-- These should probably not be discarded normally. Ask player for confirmation.
if (hoveredObject.type == "Deck") or hoveredObject.hasTag("Location") then
local suspect = (hoveredObject.type == "Deck") and "Deck" or "Location"
Player[playerColor].showConfirmDialog("Discard " .. suspect .. "?", function () performDiscard(playerColor, hoveredObject) end)
return
end
performDiscard(playerColor, hoveredObject)
end
function performDiscard(playerColor, hoveredObject)
-- initialize list of objects to discard
local discardTheseObjects = { hoveredObject }
@ -168,7 +174,7 @@ function discardTopDeck(playerColor, hoveredObject)
else
takenCard = hoveredObject
end
Wait.frames(function() discardObject(playerColor, takenCard) end, 1)
Wait.frames(function() performDiscard(playerColor, takenCard) end, 1)
end
-- helper function to get the player to trigger the discard function for