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
local playerName = Player[playerColor].steam_name
broadcastToAll(playerName .. " removed a token: " .. tokenName, playerColor)
broadcastToAll(getColoredName(playerColor) .. " removed a token: " .. tokenName, playerColor)
local discardForMatColor = getColorToDiscardFor(hoveredObject, playerColor)
playermatApi.discardListOfObjects(discardForMatColor, { targetObject })
@ -404,12 +403,10 @@ function takeClueFromLocation(playerColor, hoveredObject)
local clickableClues = optionPanelApi.getOptions()["useClueClickers"]
-- 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
playerName = Player[playerColor].steam_name
matColor = playermatApi.getMatColor(playerColor)
else
playerName = playerColor
matColor = playerColor
end
@ -431,9 +428,9 @@ function takeClueFromLocation(playerColor, hoveredObject)
end
if cardName then
broadcastToAll(playerName .. " took one clue from " .. cardName .. ".", "White")
broadcastToAll(getColoredName(playerColor) .. " took one clue from " .. cardName .. ".", "White")
else
broadcastToAll(playerName .. " took one clue.", "White")
broadcastToAll(getColoredName(playerColor) .. " took one clue.", "White")
end
victoryDisplayApi.update()
@ -472,3 +469,14 @@ function getFirstSeatedPlayer()
return color
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)
local num = math.random(1, #choices)
deckLib.placeOrMergeIntoDeck(hand[choices[num]], returnGlobalDiscardPosition(), self.getRotation())
local playerName = Player[playerColor].steam_name or playerColor
broadcastToAll(playerName .. " randomly discarded card " .. choices[num] .. "/" .. #hand .. ".", "White")
broadcastToAll(getColoredName(playerColor) .. " randomly discarded card " .. choices[num] .. "/" .. #hand .. ".", "White")
end
end
@ -1246,3 +1244,14 @@ function updatePlayerCards(args)
local playerCardData = customDataHelper.getTable("PLAYER_CARD_DATA")
tokenManager.addPlayerCardData(playerCardData)
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