Player_colors not showing

Game development with Board Game Arena Studio
Post Reply
User avatar
LKnumchuck
Posts: 3
Joined: 30 January 2021, 05:13

Player_colors not showing

Post by LKnumchuck »

I have the colors that I want for the game set in my gameinfos.inc.php file as so:

// Colors attributed to players
'player_colors' => array( "#ec008c", "#bcbdc0", "#88c878", "#f1e100", "#00aeef", "#d0a96a", "#f36f21", "#84378b"),
'favorite_colors_support' => false,

And the setup for the colors in the yourgamename.game.php in the setupNewGame method as so:

$gameinfos = self::getGameinfos();
$default_colors = $gameinfos['player_colors'];

$sql = "INSERT INTO player (player_id, player_color, player_canal, player_name, player_avatar) VALUES ";
$values = array();
foreach( $players as $player_id => $player )
{
$color = array_shift( $default_colors );
$values[] = "('".$player_id."','$color','".$player['player_canal']."','".addslashes( $player['player_name'] )."','".addslashes( $player['player_avatar'] )."')";

}
$sql .= implode( $values, ',' );
self::DbQuery( $sql );
self::reattributeColorsBasedOnPreferences( $players, $gameinfos['player_colors'] );
self::reloadPlayersBasicInfos();


The colors still aren't showing up for me. This looked like the documentation recommended by BGA to do this. Is there anything I'm doing wrong or missing to implement colors for players into the game? Thanks!
User avatar
robinzig
Posts: 459
Joined: 11 February 2021, 18:23

Re: Player_colors not showing

Post by robinzig »

What do you mean by "the colors still aren't showing up for me"?

If you mean that the players are getting colors based on turn order rather than their preferences, that's because you've set favorite_colors_suppor to false in gameinfos (it needs to be true, of course).

If you mean you don't want that but the colours in your array aren't getting assigned correctly in the database - then I'm not sure.
User avatar
LKnumchuck
Posts: 3
Joined: 30 January 2021, 05:13

Re: Player_colors not showing

Post by LKnumchuck »

The colors in the array are correct in the database in the player_color row of the player table, but every player still has just a blue gamertag. Thanks!
User avatar
Benoit314
Posts: 82
Joined: 02 April 2020, 22:12

Re: Player_colors not showing

Post by Benoit314 »

You need to remove the # in your player_colors array, they are added by the framework.
Last edited by Benoit314 on 24 September 2021, 20:28, edited 1 time in total.
User avatar
LKnumchuck
Posts: 3
Joined: 30 January 2021, 05:13

Re: Player_colors not showing

Post by LKnumchuck »

I figured it out! It was actually just because I had the # in the hexadecimal player_colors and that's why it wasn't showing. Thanks!
Post Reply

Return to “Developers”