Merge pull request #739 from dscarpac/faceup

Misc additions (incl to game keys)
This commit is contained in:
Chr1Z 2024-07-03 11:53:36 +02:00 committed by GitHub
commit ce2a301d56
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 50 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()
local 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,18 @@ 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 i = count, 1, -1 do
Wait.time(function()
if (selectedObjects[i].type == "Card" or selectedObjects[i].type ~= "Deck" or selectedObjects[i].type == "Tile") then
performDiscard(playerColor, selectedObjects[i])
end
end, (count - i + 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
@ -244,6 +249,18 @@ function onPlayerConnect()
Wait.time(function() playermatApi.redrawSlotSymbols("All") end, 0.2)
end
function onPlayerAction(player, action, targets)
if action == Player.Action.Delete and player.admin == false then
for _, target in ipairs(targets) do
local matColor = playermatApi.getMatColorByPosition(target.getPosition())
local trash = guidReferenceApi.getObjectByOwnerAndType(matColor, "Trash")
trash.putObject(target)
end
return false
end
return true
end
---------------------------------------------------------
-- chaos token drawing
---------------------------------------------------------