Merge pull request #637 from argonui/take-clue-fix

Bugfix for "Take A Clue" hotkeys for specific mats
This commit is contained in:
Entrox-Licher 2024-03-27 16:25:30 -04:00 committed by GitHub
commit 0c184804ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -280,24 +280,30 @@ end
-- takes a clue from a location, player needs to hover the clue directly or the location
function takeClueFromLocation(playerColor, hoveredObject)
-- use different color for messages if player is not seated (because this hotkey is called for a different mat)
local messageColor = playerColor
if not Player[playerColor] or not Player[playerColor].seated then
messageColor = getFirstSeatedPlayer()
end
local cardName, clue
if hoveredObject == nil then
broadcastToColor("Hover a clue or card with clues and try again.", playerColor, "Yellow")
broadcastToColor("Hover a clue or card with clues and try again.", messageColor, "Yellow")
return
elseif hoveredObject.type == "Card" then
cardName = hoveredObject.getName()
local searchResult = searchLib.onObject(hoveredObject, "isClue")
if #searchResult == 0 then
broadcastToColor("This card does not have any clues on it.", playerColor, "Yellow")
broadcastToColor("This card does not have any clues on it.", messageColor, "Yellow")
return
else
clue = searchResult[1]
end
elseif hoveredObject.memo == "clueDoom" then
if hoveredObject.is_face_down then
broadcastToColor("This is a doom token and not a clue.", playerColor, "Yellow")
broadcastToColor("This is a doom token and not a clue.", messageColor, "Yellow")
return
end
@ -311,14 +317,22 @@ function takeClueFromLocation(playerColor, hoveredObject)
clue = hoveredObject.takeObject()
cardName = "token pool"
else
broadcastToColor("Hover a clue or card with clues and try again.", playerColor, "Yellow")
broadcastToColor("Hover a clue or card with clues and try again.", messageColor, "Yellow")
return
end
local clickableClues = optionPanelApi.getOptions()["useClueClickers"]
local playerName = Player[playerColor].steam_name
local matColor = playmatApi.getMatColor(playerColor)
local pos = nil
-- handling for calling this for a specific mat via hotkey
local playerName, matColor, pos
if Player[playerColor] and Player[playerColor].seated then
playerName = Player[playerColor].steam_name
matColor = playmatApi.getMatColor(playerColor)
else
playerName = playerColor
matColor = playerColor
end
if clickableClues then
pos = {x = 0.49, y = 2.66, z = 0.00}
playmatApi.updateCounter(matColor, "ClickableClueCounter", _, 1)
@ -371,3 +385,10 @@ function titleCase(str)
local rest = str:sub(2)
return first:upper() .. rest:lower()
end
-- returns the color of the first seated player
function getFirstSeatedPlayer()
for _, color in ipairs(getSeatedPlayers()) do
return color
end
end