Notify on refresh

Game development with Board Game Arena Studio
Thalack
Posts: 71
Joined: 31 July 2022, 19:42

Re: Notify on refresh

Post by Thalack »

I'm a bit confused.
Player 1 is in State1, performs some actions on client side that impact other players but does not change state
In your first message you state actions are done client side, ie nothing is sent to the server. In that case other players should not have received any notifications and there is no issue with Player 1 refreshing (pressing F5).

If you are sending actions to the server and notifying other players, it sounds like you might be notifying them without updating the game database? So either you do notify and a page refresh for Player 1 should show him the game state the other players also see. Or you let Player 1 perform all actions and only notify the other players when you do update the database.

If you are talking about undo functionality (ie rolling back the database), which should not happen on a page refresh, you can send them a notification to undo as well.
Last edited by Thalack on 14 August 2025, 22:04, edited 1 time in total.
User avatar
thoun
Posts: 1620
Joined: 10 December 2020, 22:25

Re: Notify on refresh

Post by thoun »

A refresh should show the same screen as before the refresh, not cancel anything.
If you send a notif of the moved piece, but it doesn't match what you save in DB, then the refresh will create the situation you seems to describe.
If he player is just at half of a client side action, you shouldn't send any notif to the others.
Maybe if you share your project name, we could help you more.
User avatar
JudgeWhyMe
Posts: 36
Joined: 08 August 2012, 17:14

Re: Notify on refresh

Post by JudgeWhyMe »

The project name is Les Derniers Droides. It is my first project, and the code is far from easy to read.

Ok, I'll talk about the real case, instead of making examples.

In the game, player 1 is dealt 2 cards, keeps one for him, and gave the other to player 2.

Then both player enters a "Trade" phase. Players can trade ressources for others ressources. By clicking on several buttons, players can trade ressources. These trades are not registered yet on database. When a player clicks on "Cancel trades"', the game displays on their screen the ressources they have at the beginning on the trade phase. The same thing happens when a player refreshes their page, since no trades are registered in database. When a player clicks on the "end trade phase" button, the trades are registered in database, and the player goes to the next state (private parallel states, so the other player might still be in trade phase). Other players are notified so their screen updates with the new ressources for the player that ends their trade phase.

The requirement is:
As long as player 2 didn't click on any trade action, player 2 can go back to "card choice" phase. If player 2 cancels their trade actions, player 1 can then go back to "card choice" phase.

So:
- after "choice card" phase, player 1 has a undo button, active
- When Player 2 clicks on anything during trade phase, they sent an action to server so it can register in the database that they have a "trade in progress", and a notification is sent to player 1 to deactivate the undo button
- If player 2 clicks to "Cancel trades", an action is sent to server to register in database that they don't have a trade in progress, and a notification is sent to player 1 to activate the undo button again.

Now, my problem is:
- player 2 clicks on something during trade phase
- player 2 refreshes their page. Since nothing is registered in database, it is considered as cancelling their trade phase. Player 1 should have their undo button activated again, so he needs a notification that player 2 refreshes their page.

My problem is that, on refresh, I don't know where in the code to send a notification to player 1.

I tried in stStartTrade, in argStartTrade, no notification is received by player 1.

What can I do? In which method can I send a notification?
aartb
Posts: 4
Joined: 27 October 2022, 23:21

Re: Notify on refresh

Post by aartb »

The solution is pretty simple. You should just never notify other players without a change in a game state/database etc. Refreshing shouldn't activate an undo. If you want other players to be notified of a change, make sure it is saved on the server.
User avatar
oBsiDiaN
Posts: 12
Joined: 25 April 2020, 03:19

Re: Notify on refresh

Post by oBsiDiaN »

I read through the english rules and came to a different conclusion than how you described it so I think a designer clarification is needed:
- when does the optional trading phase start and end?

My reading is that it happens between 1. Choose a Droid and 2. Action, ie starting after the droid cards have been drawn, discussed and allocated, and finishing before the action phase starts.

(If it happens during the Choose a Droid phase, why would you trade before you knowing which droid you were going to receive, and why would you allocate the droid before your opponent has committed to their trades?)

If I am reading it correctly, then you should be able to just use standard multiactiveplayer with private parallel states and send the full set of trades to players when everyone is finished. Cartographers has undoable private parallel states if you need an example.
Post Reply

Return to “Developers”