Merge pull request #733 from argonui/colored-broadcasts

Added coloring to player names in broadcasts
This commit is contained in:
dscarpac 2024-07-01 16:41:39 -05:00 committed by GitHub
commit 15db35dc98
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 10 deletions

View File

@ -282,8 +282,7 @@ function removeOneUse(playerColor, hoveredObject)
end end
end end
local playerName = Player[playerColor].steam_name broadcastToAll(getColoredName(playerColor) .. " removed a token: " .. tokenName, playerColor)
broadcastToAll(playerName .. " removed a token: " .. tokenName, playerColor)
local discardForMatColor = getColorToDiscardFor(hoveredObject, playerColor) local discardForMatColor = getColorToDiscardFor(hoveredObject, playerColor)
playermatApi.discardListOfObjects(discardForMatColor, { targetObject }) playermatApi.discardListOfObjects(discardForMatColor, { targetObject })
@ -404,12 +403,10 @@ function takeClueFromLocation(playerColor, hoveredObject)
local clickableClues = optionPanelApi.getOptions()["useClueClickers"] local clickableClues = optionPanelApi.getOptions()["useClueClickers"]
-- handling for calling this for a specific mat via hotkey -- handling for calling this for a specific mat via hotkey
local playerName, matColor, pos local matColor, pos
if Player[playerColor] and Player[playerColor].seated then if Player[playerColor] and Player[playerColor].seated then
playerName = Player[playerColor].steam_name
matColor = playermatApi.getMatColor(playerColor) matColor = playermatApi.getMatColor(playerColor)
else else
playerName = playerColor
matColor = playerColor matColor = playerColor
end end
@ -431,9 +428,9 @@ function takeClueFromLocation(playerColor, hoveredObject)
end end
if cardName then if cardName then
broadcastToAll(playerName .. " took one clue from " .. cardName .. ".", "White") broadcastToAll(getColoredName(playerColor) .. " took one clue from " .. cardName .. ".", "White")
else else
broadcastToAll(playerName .. " took one clue.", "White") broadcastToAll(getColoredName(playerColor) .. " took one clue.", "White")
end end
victoryDisplayApi.update() victoryDisplayApi.update()
@ -472,3 +469,14 @@ function getFirstSeatedPlayer()
return color return color
end end
end end
-- returns the colored steam name or color
function getColoredName(playerColor)
local displayName = playerColor
if Player[playerColor].steam_name then
displayName = Player[playerColor].steam_name
end
-- add bb-code
return "[" .. Color.fromString(playerColor):toHex() .. "]" .. displayName .. "[-]"
end

View File

@ -577,9 +577,7 @@ function doDiscardOne()
-- get a random non-hidden card (from the "choices" table) -- get a random non-hidden card (from the "choices" table)
local num = math.random(1, #choices) local num = math.random(1, #choices)
deckLib.placeOrMergeIntoDeck(hand[choices[num]], returnGlobalDiscardPosition(), self.getRotation()) deckLib.placeOrMergeIntoDeck(hand[choices[num]], returnGlobalDiscardPosition(), self.getRotation())
broadcastToAll(getColoredName(playerColor) .. " randomly discarded card " .. choices[num] .. "/" .. #hand .. ".", "White")
local playerName = Player[playerColor].steam_name or playerColor
broadcastToAll(playerName .. " randomly discarded card " .. choices[num] .. "/" .. #hand .. ".", "White")
end end
end end
@ -1246,3 +1244,14 @@ function updatePlayerCards(args)
local playerCardData = customDataHelper.getTable("PLAYER_CARD_DATA") local playerCardData = customDataHelper.getTable("PLAYER_CARD_DATA")
tokenManager.addPlayerCardData(playerCardData) tokenManager.addPlayerCardData(playerCardData)
end end
-- returns the colored steam name or color
function getColoredName(playerColor)
local displayName = playerColor
if Player[playerColor].steam_name then
displayName = Player[playerColor].steam_name
end
-- add bb-code
return "[" .. Color.fromString(playerColor):toHex() .. "]" .. displayName .. "[-]"
end