Merge pull request #537 from argonui/multihand-improvements
Multihand improvements
This commit is contained in:
commit
ea1140098d
@ -1,17 +1,20 @@
|
||||
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
|
||||
local guidReferenceApi = require("core/GUIDReferenceApi")
|
||||
local navigationOverlayApi = require("core/NavigationOverlayApi")
|
||||
local optionPanelApi = require("core/OptionPanelApi")
|
||||
local playmatApi = require("playermat/PlaymatApi")
|
||||
local searchLib = require("util/SearchLib")
|
||||
local victoryDisplayApi = require("core/VictoryDisplayApi")
|
||||
|
||||
function onLoad()
|
||||
addHotkey("Add Doom to Agenda", addDoomToAgenda)
|
||||
addHotkey("Bless/Curse Status", showBlessCurseStatus)
|
||||
addHotkey("Discard Object", discardObject)
|
||||
addHotkey("Add doom to agenda", addDoomToAgenda)
|
||||
addHotkey("Discard object", discardObject)
|
||||
addHotkey("Discard top card", discardTopDeck)
|
||||
addHotkey("Display Bless/Curse status", showBlessCurseStatus)
|
||||
addHotkey("Move card to Victory Display", moveCardToVictoryDisplay)
|
||||
addHotkey("Remove a use", removeOneUse)
|
||||
addHotkey("Switch seat clockwise", switchSeatClockwise)
|
||||
addHotkey("Switch seat counter-clockwise", switchSeatCounterClockwise)
|
||||
addHotkey("Take clue from location", takeClueFromLocation)
|
||||
addHotkey("Upkeep", triggerUpkeep)
|
||||
addHotkey("Upkeep (Multi-handed)", triggerUpkeepMultihanded)
|
||||
@ -200,6 +203,59 @@ function removeOneUse(playerColor, hoveredObject)
|
||||
playmatApi.discardListOfObjects(discardForMatColor, { targetObject })
|
||||
end
|
||||
|
||||
-- switches the triggering player to the next seat (clockwise)
|
||||
function switchSeatClockwise(playerColor)
|
||||
switchSeat(playerColor, "clockwise")
|
||||
end
|
||||
|
||||
-- switches the triggering player to the next seat (counter-clockwise)
|
||||
function switchSeatCounterClockwise(playerColor)
|
||||
switchSeat(playerColor, "counter-clockwise")
|
||||
end
|
||||
|
||||
-- handles seat switching in the given direction
|
||||
function switchSeat(playerColor, direction)
|
||||
if playerColor == "Black" or playerColor == "Grey" then
|
||||
broadcastToColor("This hotkey is only available to seated players.", playerColor, "Orange")
|
||||
return
|
||||
end
|
||||
|
||||
-- sort function for matcolors based on hand position (Green, White, Orange, Red)
|
||||
local function sortByHandPosition(color1, color2)
|
||||
local pos1 = Player[color1].getHandTransform().position
|
||||
local pos2 = Player[color2].getHandTransform().position
|
||||
return pos1.z > pos2.z
|
||||
end
|
||||
|
||||
-- get used playermats
|
||||
local usedColors = playmatApi.getUsedMatColors()
|
||||
table.sort(usedColors, sortByHandPosition)
|
||||
|
||||
-- get current seat index
|
||||
local index
|
||||
for i, color in ipairs(usedColors) do
|
||||
if color == playerColor then
|
||||
index = i
|
||||
break
|
||||
end
|
||||
end
|
||||
if not index then
|
||||
broadcastToColor("Couldn't detect investigator.", playerColor, "Orange")
|
||||
return
|
||||
end
|
||||
|
||||
-- get next color
|
||||
index = index + ((direction == "clockwise") and -1 or 1)
|
||||
if index == 0 then
|
||||
index = #usedColors
|
||||
elseif index > #usedColors then
|
||||
index = 1
|
||||
end
|
||||
|
||||
-- swap color
|
||||
navigationOverlayApi.loadCamera(playerColor, usedColors[index])
|
||||
end
|
||||
|
||||
-- takes a clue from a location, player needs to hover the clue directly or the location
|
||||
function takeClueFromLocation(playerColor, hoveredObject)
|
||||
local cardName, clue
|
||||
|
@ -204,6 +204,22 @@ function onObjectEnterZone(zone, enteringObj)
|
||||
end
|
||||
end
|
||||
|
||||
-- handle card drawing via number typing for multihanded gameplay
|
||||
-- (and additionally allow Norman Withers to draw multiple cards via number)
|
||||
function onObjectNumberTyped(hoveredObject, playerColor, number)
|
||||
-- only continue for decks or cards
|
||||
if hoveredObject.type ~= "Deck" and hoveredObject.type ~= "Card" then return end
|
||||
|
||||
-- check whether the hovered object is part of a players draw objects
|
||||
for _, color in ipairs(playmatApi.getUsedMatColors()) do
|
||||
local deckAreaObjects = playmatApi.getDeckAreaObjects(color)
|
||||
if deckAreaObjects.topCard == hoveredObject or deckAreaObjects.draw == hoveredObject then
|
||||
playmatApi.drawCardsWithReshuffle(color, number)
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---------------------------------------------------------
|
||||
-- chaos token drawing
|
||||
---------------------------------------------------------
|
||||
|
@ -22,5 +22,15 @@ do
|
||||
getNOHandler().call("cycleVisibility", playerColor)
|
||||
end
|
||||
|
||||
-- loads the specified camera for a player
|
||||
---@param player TTSPlayerInstance Player whose camera should be moved
|
||||
---@param camera Variant If number: Index of the camera view to load | If string: Color of the playermat to swap to
|
||||
NavigationOverlayApi.loadCamera = function(playerColor, camera)
|
||||
getNOHandler().call("loadCameraFromApi", {
|
||||
playerColor = playerColor,
|
||||
camera = camera
|
||||
})
|
||||
end
|
||||
|
||||
return NavigationOverlayApi
|
||||
end
|
||||
|
@ -291,9 +291,30 @@ function getDynamicViewBounds(objList)
|
||||
return totalBounds
|
||||
end
|
||||
|
||||
function loadCameraFromApi(params)
|
||||
loadCamera(Player[params.playerColor], params.camera)
|
||||
end
|
||||
|
||||
-- loads the specified camera for a player
|
||||
function loadCamera(player, index)
|
||||
local lookHere
|
||||
---@param player TTSPlayerInstance Player whose camera should be moved
|
||||
---@param camera Variant If number: Index of the camera view to load | If string: Color of the playermat to swap to
|
||||
function loadCamera(player, camera)
|
||||
local lookHere, index, matColor
|
||||
local matColorList = { "White", "Orange", "Green", "Red" }
|
||||
local indexList = {
|
||||
White = 3,
|
||||
Orange = 4,
|
||||
Green = 5,
|
||||
Red = 6
|
||||
}
|
||||
|
||||
if tonumber(camera) then
|
||||
index = tonumber(camera)
|
||||
matColor = matColorList[index - 2] -- mat index 1 - 4
|
||||
else
|
||||
index = indexList[camera]
|
||||
matColor = camera
|
||||
end
|
||||
|
||||
-- dynamic view of the play area
|
||||
if index == 2 then
|
||||
@ -307,9 +328,6 @@ function loadCamera(player, index)
|
||||
}
|
||||
-- dynamic view of the clicked play mat
|
||||
elseif index >= 3 and index <= 6 then
|
||||
local matColorList = { "White", "Orange", "Green", "Red" }
|
||||
local matColor = matColorList[index - 2] -- mat index 1 - 4
|
||||
|
||||
-- check if anyone (except for yourself) has claimed this color
|
||||
local isClaimed = false
|
||||
|
||||
@ -325,6 +343,7 @@ function loadCamera(player, index)
|
||||
local newPlayerColor = playmatApi.getPlayerColor(matColor)
|
||||
copyVisibility({ startColor = player.color, targetColor = newPlayerColor })
|
||||
player.changeColor(newPlayerColor)
|
||||
player = Player[newPlayerColor]
|
||||
end
|
||||
|
||||
-- search on the playmat for objects
|
||||
|
@ -1,6 +1,7 @@
|
||||
do
|
||||
local PlaymatApi = {}
|
||||
local guidReferenceApi = require("core/GUIDReferenceApi")
|
||||
local searchLib = require("util/SearchLib")
|
||||
|
||||
-- Convenience function to look up a mat's object by color, or get all mats.
|
||||
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
|
||||
@ -180,6 +181,15 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- triggers the draw function for the specified playmat
|
||||
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
|
||||
---@param number Number Amount of cards to draw
|
||||
PlaymatApi.drawCardsWithReshuffle = function(matColor, number)
|
||||
for _, mat in pairs(getMatForColor(matColor)) do
|
||||
mat.call("drawCardsWithReshuffle", number)
|
||||
end
|
||||
end
|
||||
|
||||
-- returns the resource counter amount
|
||||
---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All")
|
||||
---@param type String Counter to target
|
||||
@ -189,6 +199,22 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
-- returns a list of mat colors that have an investigator placed
|
||||
PlaymatApi.getUsedMatColors = function()
|
||||
local localInvestigatorPosition = { x = -1.17, y = 1, z = -0.01 }
|
||||
local usedColors = {}
|
||||
|
||||
for matColor, mat in pairs(getMatForColor("All")) do
|
||||
local searchPos = mat.positionToWorld(localInvestigatorPosition)
|
||||
local searchResult = searchLib.atPosition(searchPos, "isCardOrDeck")
|
||||
|
||||
if #searchResult > 0 then
|
||||
table.insert(usedColors, matColor)
|
||||
end
|
||||
end
|
||||
return usedColors
|
||||
end
|
||||
|
||||
-- resets the specified skill tracker to "1, 1, 1, 1"
|
||||
---@param matColor String Color of the playmat - White, Orange, Green, Red or All
|
||||
PlaymatApi.resetSkillTracker = function(matColor)
|
||||
|
Loading…
x
Reference in New Issue
Block a user