onEnteringState() vs setAllPlayersMultiactive() in action

Game development with Board Game Arena Studio
Post Reply
User avatar
HumanBot
Posts: 11
Joined: 29 March 2020, 07:43

onEnteringState() vs setAllPlayersMultiactive() in action

Post by HumanBot »

So I called setAllPlayersMultiactive() in the action function of a multipleactiveplayer state and I noticed that at the very beginning of onEnteringState, if I called isCurrentPlayerActive(), it would return false. This leads me to believe that onEnteringState() and the action function for the state happens at the same time (or onEnteringState() happens first). I haven't seen anything about this in the docs so far. Does someone know which it is?
User avatar
CuriousTerran
Posts: 21
Joined: 12 July 2020, 21:03

Re: onEnteringState() vs setAllPlayersMultiactive() in action

Post by CuriousTerran »

I also just found some oddities with multiplayer states and whether players are active in the onEnteringState() function.
If I use setAllPlayersMultiactive() in an action function, then I DO see all players as active inside onEnteringState().
This behavior seems opposite to what you are reporting.
However, if I use setPlayersMultiactive($player_ids, 'state_name'), where I list a subset of players to be active during a multipleactiveplayer state, then NO players are active inside onEnteringState() ? I've used this.getActivePlayers() on the client side to ascertain the behavior of which players are active during onEnteringState.
Thus, it appears that one cannot reliably determine whether a player is active or not during the onEnteringState() function.
User avatar
Marcuda
Posts: 25
Joined: 21 September 2015, 00:36

Re: onEnteringState() vs setAllPlayersMultiactive() in action

Post by Marcuda »

Correct, the active status in onEnteringState is not reliable during multi active states. You need to handle it in onUpdateActionButtons instead, which is only called for active players.

See the very end of http://en.doc.boardgamearena.com/Your_g ... ive_states
User avatar
Volker78
Posts: 66
Joined: 29 April 2020, 21:37

Re: onEnteringState() vs setAllPlayersMultiactive() in action

Post by Volker78 »

This really should be documented in the clientside isCurrentPlayerActive Documentation
User avatar
RicardoRix
Posts: 2541
Joined: 29 April 2012, 23:43

Re: onEnteringState() vs setAllPlayersMultiactive() in action

Post by RicardoRix »

This same problem seems to come up in the forum once every few months or so.
Post Reply

Return to “Developers”