new hotkey to take cards into threat area
This commit is contained in:
parent
7e14a51ffa
commit
e0a1ea3898
@ -13,6 +13,7 @@ function onLoad()
|
||||
addHotkey("Discard top card", discardTopDeck)
|
||||
addHotkey("Display Bless/Curse status", showBlessCurseStatus)
|
||||
addHotkey("Move card to Victory Display", moveCardToVictoryDisplay)
|
||||
addHotkey("Place card into threat area", takeCardIntoThreatArea)
|
||||
addHotkey("Remove a use", removeOneUse)
|
||||
addHotkey("Switch seat clockwise", switchSeatClockwise)
|
||||
addHotkey("Switch seat counter-clockwise", switchSeatCounterClockwise)
|
||||
@ -57,6 +58,80 @@ function addDoomToAgenda()
|
||||
doomCounter.call("addVal", 1)
|
||||
end
|
||||
|
||||
-- move the hovered object to the nearest empty slot on the playermat
|
||||
function takeCardIntoThreatArea(playerColor, hoveredObject)
|
||||
-- only continue if an unlocked card
|
||||
if hoveredObject == nil
|
||||
or hoveredObject.type ~= "Card"
|
||||
or hoveredObject.hasTag("Location")
|
||||
or hoveredObject.locked then
|
||||
broadcastToColor("Hover a non-location and try again.", playerColor, "Yellow")
|
||||
return
|
||||
end
|
||||
|
||||
local matColor = playmatApi.getMatColor(playerColor)
|
||||
local mat = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat")
|
||||
-- do not continue if the threat area is already full
|
||||
if playmatApi.getEncounterCardDrawPosition(matColor, false) == playmatApi.getEncounterCardDrawPosition(matColor, true) then
|
||||
broadcastToColor("Threat area is full.", playerColor,"Yellow")
|
||||
return
|
||||
end
|
||||
local pos = playmatApi.getEncounterCardDrawPosition(matColor, false)
|
||||
|
||||
-- initialize list of objects to move
|
||||
local moveTheseObjects = {}
|
||||
|
||||
for _, obj in ipairs(searchLib.onObject(hoveredObject, "isTileOrToken")) do
|
||||
table.insert(moveTheseObjects, obj)
|
||||
end
|
||||
|
||||
-- find out if the original card is on the green or red playmats
|
||||
local result
|
||||
local result = playmatApi.searchAroundPlaymat("Green", "isCard")
|
||||
local originalMatColor
|
||||
|
||||
for _, card in ipairs(result) do
|
||||
if hoveredObject.getGUID() == card.getGUID() then
|
||||
originalMatColor = "Green"
|
||||
end
|
||||
end
|
||||
|
||||
local result = playmatApi.searchAroundPlaymat("Red", "isCard")
|
||||
|
||||
for _, card in ipairs(result) do
|
||||
if hoveredObject.getGUID() == card.getGUID() then
|
||||
originalMatColor = "Red"
|
||||
end
|
||||
end
|
||||
-- determine modifiers for the playmats
|
||||
local modifierY
|
||||
if originalMatColor == "Red" then
|
||||
modifierY = 90
|
||||
elseif originalMatColor == "Green" then
|
||||
modifierY = -90
|
||||
else
|
||||
modifierY = 0
|
||||
end
|
||||
|
||||
local localPositions = {}
|
||||
|
||||
for i, obj in ipairs(moveTheseObjects) do
|
||||
local localPos = hoveredObject.positionToLocal(obj.getPosition())
|
||||
localPositions[i] = localPos
|
||||
end
|
||||
|
||||
hoveredObject.setPosition(pos)
|
||||
hoveredObject.setRotation(hoveredObject.getRotation() - Vector(0, 270-mat.getRotation().y-modifierY, 0))
|
||||
|
||||
for i, obj in ipairs(moveTheseObjects) do
|
||||
if not obj.locked then
|
||||
local globalPos = hoveredObject.positionToWorld(localPositions[i])
|
||||
obj.setPosition(globalPos)
|
||||
obj.setRotation(obj.getRotation() - Vector(0, 270-mat.getRotation().y-modifierY, 0))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- discard the hovered object to the respective trashcan and discard tokens on it if it was a card
|
||||
function discardObject(playerColor, hoveredObject)
|
||||
-- only continue if an unlocked card, deck or tile was hovered
|
||||
|
Loading…
Reference in New Issue
Block a user