Skip to content

Commit

Permalink
added discard top card of deck hotkey
Browse files Browse the repository at this point in the history
  • Loading branch information
dscarpac committed Dec 8, 2023
1 parent 6cc8770 commit 07594b4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/core/GameKeyHandler.ttslua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 07594b4

Please sign in to comment.