Struggling with multiactive state

Game development with Board Game Arena Studio
Post Reply
Angst03
Posts: 8
Joined: 01 September 2023, 19:04

Struggling with multiactive state

Post 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.
imralav
Posts: 29
Joined: 02 February 2024, 08:56

Re: Struggling with multiactive state

Post 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.
User avatar
thoun
Posts: 1291
Joined: 10 December 2020, 22:25

Re: Struggling with multiactive state

Post 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?
Angst03
Posts: 8
Joined: 01 September 2023, 19:04

Re: Struggling with multiactive state

Post 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().
User avatar
KuWizard
Posts: 96
Joined: 24 May 2018, 14:10

Re: Struggling with multiactive state

Post 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
Angst03
Posts: 8
Joined: 01 September 2023, 19:04

Re: Struggling with multiactive state

Post 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.
User avatar
thoun
Posts: 1291
Joined: 10 December 2020, 22:25

Re: Struggling with multiactive state

Post by thoun »

For private infos, you should use _private described in the doc ;)
Post Reply

Return to “Developers”