Merge pull request #500 from dscarpac/DiscardTopCard

added discard top card of deck hotkey
This commit is contained in:
Chr1Z 2023-12-09 17:25:34 +01:00 committed by GitHub
commit 4743fc00e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,7 @@ function onLoad()
addHotkey("Add Doom to Agenda", addDoomToAgenda)
addHotkey("Bless/Curse Status", showBlessCurseStatus)
addHotkey("Discard Object", discardObject)
addHotkey("Discard top card", discardTopDeck)
addHotkey("Move card to Victory Display", moveCardToVictoryDisplay)
addHotkey("Remove a use", removeOneUse)
addHotkey("Take clue from location", takeClueFromLocation)
@ -79,6 +80,23 @@ function discardObject(playerColor, hoveredObject)
playmatApi.discardListOfObjects(discardForMatColor, discardTheseObjects)
end
-- discard the top card of hovered deck, calling discardObject function
function discardTopDeck(playerColor, hoveredObject)
-- only continue if an unlocked card or deck was hovered
if hoveredObject == nil
or (hoveredObject.type ~= "Card" and hoveredObject.type ~= "Deck")
or hoveredObject.locked then
broadcastToColor("Hover a deck/card and try again.", playerColor, "Yellow")
return
end
if hoveredObject.type == "Deck" then
takenCard = hoveredObject.takeObject({index = 0})
else
takenCard = hoveredObject
end
Wait.frames(function() discardObject(playerColor, takenCard) end, 1)
end
-- helper function to get the player to trigger the discard function for
function getColorToDiscardFor(hoveredObject, playerColor)
local pos = hoveredObject.getPosition()