Playername color on background

Game development with Board Game Arena Studio
Post Reply
User avatar
Volker78
Posts: 66
Joined: 29 April 2020, 21:37

Playername color on background

Post by Volker78 »

I have a gamestate turn description like this:
${you} must guess: Which of the four words does ${player_name} have?
Unfortunately ${player_name} is not colorized automatically, so I do it manually:

Code: Select all

function argGuess() {
		$players = $this->getPlayers();
		$p = $players[$this->getActivePlayerId()];
		return [
			"active_player_id" => $p["id"],
			"player_name" => '<span style="color:#' . $p["color"] . ';">' . $p["name"] . '</span>',
		];
	}
But this makes problems for example with white color on white backgrounds. BGA already solved this, but is there an API function for this? To compute an optional background color, if needed? That would be nice!
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: Playername color on background

Post by Victoria_La »

Code: Select all

	if (this.gamedatas.players[this.player_id] && this.gamedatas.players[this.player_id].color_back) {
				color_bg = "background-color:#" + this.gamedatas.players[this.player_id].color_back + ";";

			}
(replace this.player_id with player var)
User avatar
Volker78
Posts: 66
Joined: 29 April 2020, 21:37

Re: Playername color on background

Post by Volker78 »

I don't understand. In this gamestate the ${player_name} is NOT the active player (multiplayer gamestate)
User avatar
PirateKitten
Posts: 25
Joined: 05 August 2015, 19:18

Re: Playername color on background

Post by PirateKitten »

Try using otherplayer in your description and setting otherplayer (as their name) and otherplayer_id in the args, these will also get picked up and coloured automatically.
User avatar
Volker78
Posts: 66
Joined: 29 April 2020, 21:37

Re: Playername color on background

Post by Volker78 »

I now found that in the studio-js sources, too, this is not documented, right? There I also found an undocumented player-property "color_back", sadly only on client-side.
User avatar
PirateKitten
Posts: 25
Joined: 05 August 2015, 19:18

Re: Playername color on background

Post by PirateKitten »

Yes I don't believe it's documented, I found it in the JS source too when looking up how to add a non-active name into the log and have it formatted correctly.
Post Reply

Return to “Developers”