Page 1 of 1

Struggling with multiactive state

Posted: 22 July 2024, 03:08
by Angst03
Hi,

I have a problem with multipleactiveplayerstate in my game. The problem I have is that the current player methods returns the player who played last in the other player browser. If I refresh the page everything is OK. In the state method, all I do is:

Code: Select all

$this->gamestate->setAllPlayersMultiactive();
In the "argMethod" I have tested some "CurrentPlayer" and "ActivePlayer" methods and the JavaScript receive the same values in both browsers tab and so in both "onEnteringState" and "onUpdateActionButtons". If I refresh the page, the "CurrentPlayer" methods returns the expected values. What am I missing. Do I need another state? Any help appreciated.

Re: Struggling with multiactive state

Posted: 22 July 2024, 05:09
by imralav
I think that's by design and BGA's wiki explicitly states to not rely on CurrentPlayer in multiactiveplayerstates. I can grant that there can be some confusion around who is current player and who is active player, but it's just the way it is.

Re: Struggling with multiactive state

Posted: 22 July 2024, 08:52
by thoun
CurrentPlayerId should only be used when answering an action of a multiactiveplayerstate, but never when entering the state.
ActivePlayerId doesn't have any meaning in a multiactiveplayerstate as there are multiple active players.
What are you trying to do?

Re: Struggling with multiactive state

Posted: 22 July 2024, 17:28
by Angst03
Hi, players must do actions based on their "material reality". I have a dialog that requires to display player related elements. As stated earlier, if I'm "live" in the game both players displays the same thing but if I reload the page everything is OK... I've put some debug info in my game.php file and I can see that the "argMethod" is called before the multiplayer state method which does the setAllPlayersMultiactive().

Re: Struggling with multiactive state

Posted: 22 July 2024, 19:01
by KuWizard
Angst03 wrote: 22 July 2024, 17:28 "argMethod" is called before the multiplayer state method which does the setAllPlayersMultiactive().
Oh yeah, arg-methods calls are nasty. They are sometimes called after the state have been finished :) No idea why

Re: Struggling with multiactive state

Posted: 28 July 2024, 15:51
by Angst03
Hi, since the information is not really private I send everything to every player and I filter the info in the JavaScript with this.player_id. I'm OK for this time but still curious if someone knows a better way for the future or someone else.

Re: Struggling with multiactive state

Posted: 28 July 2024, 16:04
by thoun
For private infos, you should use _private described in the doc ;)