Player colours aren't random: BGA Studio

Game development with Board Game Arena Studio
Post Reply
User avatar
RicardoRix
Posts: 2548
Joined: 29 April 2012, 23:43

Player colours aren't random: BGA Studio

Post by RicardoRix »

My game has 4 different player colours, each colour has slightly different powers, the colour assignment needs to be random.

But I have opened a bunch (at least 10) of 2 player games, and it's always the same colours to the same 0 and 1 colour, and it's the first 2 colours in the games options list. So I'm guessing it's not random?
4-player games seem randomised, but it's just 2-player which is stuck.

Is there a random colour option I've missed?

Code: Select all

'favorite_colors_support' => false,
'disable_player_order_swap_on_rematch' => false,
Last edited by RicardoRix on 20 January 2022, 14:02, edited 1 time in total.
User avatar
thoun
Posts: 1621
Joined: 10 December 2020, 22:25

Re: Player colours aren't random: BGA Studio

Post by thoun »

Well you insert colors you want on setupNewGame, so you can replace default color assignment by your own :)
User avatar
RicardoRix
Posts: 2548
Joined: 29 April 2012, 23:43

Re: Player colours aren't random: BGA Studio

Post by RicardoRix »

I just opened 6 games of cchess, and it was always 0=red 1=blue, with a random start player. I can't see how this is possible.

Yes. I think I fried my brain opening and closing so many games, but I can overcome it with this:

Code: Select all

	$r = bga_rand(0, count($default_colors) - 1);
			$color = $default_colors[$r];
			array_splice($default_colors, $r, 1);			
		    //$color = array_shift( $default_colors );
User avatar
ufm
Posts: 2039
Joined: 06 January 2017, 08:38

Re: Player colours aren't random: BGA Studio

Post by ufm »

It is totally natural, since BGA template uses array_shift() to assign colors.
Just manually randomize $default_colors or color assignment itself.
User avatar
RicardoRix
Posts: 2548
Joined: 29 April 2012, 23:43

Re: Player colours aren't random: BGA Studio

Post by RicardoRix »

Yes, $default_colors will always be the same. But that data comes from behind a function, so it doesn't necessarily have to be fixed.
but the gameSetup $players array argument seems to come out randomised.

I think I was thrown in testing cchess, because that uses players colour preference, reattributeColorsBasedOnPreferences()

It would also be nice if randomised colour was an option, rather than having to manually do it. The same for colour preferences.
Post Reply

Return to “Developers”