Page 1 of 1
Action of other players during an active player's turn
Posted: 11 September 2023, 18:11
by MathCT
Hello everyone,
I would like, during a player's turn, to give all the other players the opportunity to take a recurring action (for example, rearranging their game board) until the active player finishes their turn. Then the active player changes, and the other players can resume their rearrangement while waiting for their own turn.
Currently, my example of rearranging the player's board is only accessible to my active player, and I would like to make it possible for non-active players to do so outside of their turn in order to save time.
Should I use a multi-active player state(with private states? ) ? Or are there other solutions?
Thank you in advance.
Re: Action of other players during an active player's turn
Posted: 12 September 2023, 13:17
by MathCT
Alright, I've found a solution using $this->gamestate->checkPossibleAction. But now, I have another issue, and I can't find the solution.
First, let me explain what I want to do, what I've done so far, and the problem I'm facing.
What I want to do:
Players have a personal board with elements on it. The active player can move these elements with arrows during their action phase. The arrows appear based on the elements present (some positions of these elements can be empty, so the arrows don't appear). I want to allow inactive players to move their elements as well to save time during their turns.
What I've done:
- In my onEnteringState function, I've allowed inactive players to see their own arrows.
- In my argPlayerTurn function, I've retrieved the arrows to display for the "current player" instead of the "active player": $player_id = self::getCurrentPlayerId();
- I've allowed player clicks in onSelectArrow by removing my condition: if (!this.isCurrentPlayerActive()) { return; }
- Finally, in my PHP function function actSelectArrow($arrow_id), I added $this->gamestate->checkPossibleAction('select'); at the beginning to allow the action for other players, and I make modifications in the database indicating that the player is the current one: $player_id = self::getCurrentPlayerId();
My problem:
At the start of the game or after a page refresh (F5), everything works correctly. However, as soon as a player clicks on one of their arrows and moves their element without any issues, the arrows for all other players disappear, and they see the arrows of the active player. If they click on the active player's arrows, it returns to normal for them, but the problem shifts to other players, and so on. A page refresh (F5) resets everything to normal until a player clicks on an arrow and moves their element.
I'm not sure if my explanation is clear enough, but I might have missed something in my code, and I can't find it. Do I need to reset something somewhere? In short, I'm lost.
Thanks in advance for your help.
Re: Action of other players during an active player's turn
Posted: 12 September 2023, 13:29
by MathCT
I just realized that the changes made to the PHP files prevent the game from launching (caused by $player_id = self::getCurrentPlayerId(); in argPlayerTurn). I'm reverting back while waiting for a solution.
Re: Action of other players during an active player's turn
Posted: 12 September 2023, 15:49
by MathCT
It's good, I've resolved the issue, and it's working as I wanted.
Just one question: is there a risk that two players (or more) click at the same time and it causes a bug (in Db for exemple)? If so, how can we avoid this kind of risk?
Re: Action of other players during an active player's turn
Posted: 13 September 2023, 00:14
by cigma
I am not a developer, but I know there are several games here which allow all players to click at any time to perform an action, e. g. Dobble, Panic Lab and Solo, and some other games which might use what you described as "a multi-active player state with private states" like Welcome to and Can't Stop Express. And obviously all of them can be played without such an interference bug. Hopefully this information can help you to answer your question (if you can check those game codes).
But I don't know of any game here with such a feature as you invented it, so I think this concept has to be checked carefully for unwanted side effects.
First, BGA is rather strict on the time limit given and the time used by any player during the game. What you have invented might interfere with their timer philosophy. As a start you might read the faq:
https://boardgamearena.com/faq?anchor=faq_playing_clock and
https://boardgamearena.com/faq?anchor=f ... notplaying, but these faq won't answer this question. You can also find lots of discussions about the game timers here in the forums. I don't know if there are any developer's rules about them.
Second, I've got the players' point of view in mind: Let's say A is the active player and B is the inactive player. Can the rearrangement of B's board, change A's action plans? If so, I think you shouldn't use this feature.
Another point is to test if this feature functions as well in turn-based as in realtime games. Can it confuse the notification system, which tells who's turn it is next?
And I think you should check if this causes any bugs in the replay feature.
That's just my 2 cents on this issue.
Good luck!
Re: Action of other players during an active player's turn
Posted: 13 September 2023, 11:52
by MathCT
Thank you for your advice.
To answer your question, no, the action of the inactive player has no impact on the action of the active player. But at the "server" level this will make a query on the same database (not the same lines... just the same table).
Re: Action of other players during an active player's turn
Posted: 13 September 2023, 12:44
by RicardoRix
The DB uses a 'transaction' model so it should be safe. The same reason you can bail with a exception at any point.
But there are possible deadlock situations, of which I am completely unaware of the details, and sound horrific.
Is it possible to simplify the idea, to only update to the server with the cards order when it's their own turn? The only downside is a loss of order should you hit an F5.