misc additions

This commit is contained in:
dscarpac 2024-07-03 01:02:12 -05:00
parent 40fe5c0fae
commit 9c789e2643
2 changed files with 35 additions and 10 deletions

View File

@ -1,5 +1,6 @@
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
local guidReferenceApi = require("core/GUIDReferenceApi")
local mythosAreaApi = require("core/MythosAreaApi")
local navigationOverlayApi = require("core/NavigationOverlayApi")
local optionPanelApi = require("core/OptionPanelApi")
local playermatApi = require("playermat/PlayermatApi")
@ -15,6 +16,7 @@ function onLoad()
addHotkey("Move card to Victory Display", moveCardToVictoryDisplay)
addHotkey("Place card into threat area", takeCardIntoThreatArea)
addHotkey("Remove a use", removeOneUse)
addHotkey("Reshuffle encounter deck", mythosAreaApi.reshuffleEncounterDeck)
addHotkey("Switch seat clockwise", switchSeatClockwise)
addHotkey("Switch seat counter-clockwise", switchSeatCounterClockwise)
addHotkey("Take clue from location", takeClueFromLocation)
@ -122,10 +124,15 @@ function takeCardIntoThreatArea(playerColor, hoveredObject)
end
end
-- discard the hovered object to the respective trashcan and discard tokens on it if it was a card
-- discard the hovered or selected objects to the respective trashcan and discard tokens on it if it was a card
function discardObject(playerColor, hoveredObject)
-- if more than one object is selected, discard them all, one at a time
local selectedObjects = Player[playerColor].getSelectedObjects()
if #selectedObjects > 0 then
discardGroup(playerColor, selectedObjects)
return
-- only continue if an unlocked card, deck or tile was hovered
if hoveredObject == nil
elseif hoveredObject == nil
or (hoveredObject.type ~= "Card" and hoveredObject.type ~= "Deck" and hoveredObject.type ~= "Tile")
or hoveredObject.locked then
broadcastToColor("Hover a token/tile or a card/deck and try again.", playerColor, "Yellow")
@ -133,11 +140,15 @@ function discardObject(playerColor, hoveredObject)
end
-- 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
local tokenData = mythosAreaApi.returnTokenData()
scenarioName = tokenData.currentScenario
if scenarioName ~= "Lost in Time and Space" and scenarioName ~= "The Secret Name" then
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
end
performDiscard(playerColor, hoveredObject)
@ -159,6 +170,15 @@ function performDiscard(playerColor, hoveredObject)
playermatApi.discardListOfObjects(discardForMatColor, discardTheseObjects)
end
function discardGroup(playerColor, selectedObjects)
local count = #selectedObjects
-- discarding one at a time avoids an error with cards in the discard pile losing the 'hands' toggle and uses multiple mats
for j = count, 1, -1 do
Wait.time(function() performDiscard(playerColor, selectedObjects[j]) end,
(count - j + 1) * 0.1)
end
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

View File

@ -199,9 +199,14 @@ function onObjectEnterZone(zone, object)
local matcolor = playermatApi.getMatColorByPosition(object.getPosition())
local trash = guidReferenceApi.getObjectByOwnerAndType(matcolor, "Trash")
trash.putObject(object)
elseif zone.type == "Hand" and object.hasTag("CardWithHelper") then
object.clearContextMenu()
object.call("shutOff")
elseif zone.type == "Hand" and object.type == "Card" then
if object.is_face_down then
object.flip()
end
if object.hasTag("CardWithHelper") then
object.clearContextMenu()
object.call("shutOff")
end
end
end