added discard top card of deck hotkey

This commit is contained in:
dscarpac 2023-12-07 18:26:13 -06:00
parent 6cc877069c
commit 07594b4597

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()