Page 2 of 3
Re: [SOLVED] NotifyAllPlayersBut
Posted: 08 June 2020, 17:52
by fafa-fr
Hi, thanks for the answer!
sourisdudesert wrote: ↑08 June 2020, 09:32
In your case, you get something like:
"Player X draws a <card_type> card"
"~ You draw <card_name> ~"
I think this is pretty clear, and it does the trick.
No, the problem is that my case is not that simple. I'm not sending two different messages/notifs, I'm sending exactly the same message and notif (no hidden information at all) but at a different time. If you're interested, here's why (otherwise jump to next post, there are some other questions there):
I have implemented an "Undo turn" feature, and I think it would be better if opponents and spectators don't receive all the notifications for actions that have not been confirmed, for turn undoing, with tiles going here and there in the interface and log messages that will eventually not be an actual move. I'd
really like to send them only the real moves, once they have been confirmed.
So what I would like to get is more something like this:
For the active player, in the flow of the game:
Pl uses action A
Pl uses action B
Pl cancels their turn
Pl uses action C
Pl gets bonus action 1
Pl uses action A
For other players, only once Pl turn is confirmed:
Pl uses action C
Pl gets bonus action 1
Pl uses action A
But if upon turn confirmation I send notifyAllPlayers() notifs without avoiding the messages for the active player, this is what I get for the active player:
Pl uses action A
Pl uses action B
Pl cancels their turn
Pl uses action C
Pl gets bonus action 1
Pl uses action A
Pl uses action C
Pl gets bonus action 1
Pl uses action A
All the real notifs are displayed twice, and this may not be obvious because identical messages are not next to each other. In the quick example above, there are only 3 messages in the game log, but sometimes there's like 8 or 10 messages in a turn. So I'd like to avoid duplicating all these messages.
Re: [SOLVED] NotifyAllPlayersBut
Posted: 08 June 2020, 17:59
by fafa-fr
So now that I have a confirmation that a notifyAllPlayersBut() method is not an option, here are my different options:
It would be great if there was a way to deal with this client-side. There could be, in the notification args, an array (ignorePlayers) containing id's of the players that must ignore this notification. I think that if there's no hidden information in it, it should be ok.
Otherwise, I hope that there's no problem with
the solution I proposed two days ago (sending the notification to each opponent with a notifyPlayer(), and sending an identical notif with notifyAllPlayers(), but with a different notif type so that only spectators subscribe to this notif).
My third and last option would be to give up my idea to send notifs only on turn confirmation, and let players see their opponents playing and undoing their turns. I'd really love to avoid this, but I think this would be less bad than having duplicated and confusing messages in the log.
sourisdudesert wrote: ↑08 June 2020, 09:32
If you want to improve this, you may want to consider to hide the previous log using javascript. However, a page refresh will make the log appear again (and it will not work in turn based).
No, sorry I don't want to consider this

. This is why I asked "is there a
clean way ...". For games that are played more than 100,000 times a year, I think it is not wasted time to improve user experience.
Re: [SOLVED] NotifyAllPlayersBut
Posted: 09 January 2021, 06:51
by quietmint
I agree that I also want to see notifyOtherPlayers( int|array $notPlayerIds, string $notif_type, string $msg, array $args) method added to framework. The vast majority of games do not have 100% open information. 3 of the 4 games I am developing on BGA already need this, so please do not say it is "very rare" or not needed. This is not at all a rare use case. Look how many of us have come here to find a workaround for this problem!
The framework should support this, and it is so simple! It can be done entirely on JavaScript side with no performance penalty. Essentially, new PHP function notifyOtherPlayers would do the same thing as notifyAllPlayers + includes hidden argument (array) "notPlayerIds". On client side, when you receive any notification with this arg, check if current player ID is in the array and ignore the notification entirely (do not log, do not invoke game callback function, etc.). That's it!* It is very simple to add and it would benefit a lot of games, as evidenced here!!
* Minor additional work needed to make the framework preserve new arg "notPlayerIds" in notifications database table (when notifications get condensed and re-sent on page refresh).
Re: [SOLVED] NotifyAllPlayersBut
Posted: 09 January 2021, 10:27
by fafa-fr
I added a suggestion for this two weeks ago in the bugs section of the Studio.
But it's not a good idea to use this to hide private informations: even if the javascript code can hide them, cheaters could have access to them.
Furthermore, private informations should not be sent to spectators either. In this case, it's not complicated to send several notifyPlayer. A notifyAllPlayersBut() method could be useful especially when we need to send notifications also to spectators, and when you need to ignore this notif for some players because you notify them in another way or at a different time. (I think specifically about game log messages, because in our gamename.js file, it's possible to not execute the notification method for some players, but we don't have access to the game log messages.)
Re: [SOLVED] NotifyAllPlayersBut
Posted: 09 January 2021, 12:38
by Tisaac
fafa-fr wrote: ↑09 January 2021, 10:27
I added a suggestion for this two weeks ago in the bugs section
of the Studio.
But it's not a good idea to use this to hide private informations: even if the javascript code can hide them, cheaters could have access to them.
Furthermore, private informations should not be sent to spectators either.
Of course no, the idea is to avoid duplicate log : send first log with private info to a player «you draw the 4 of spades», then for everyone «Tisaac draw 1 card from the deck» except for the player that just drew the card. It's really all we need and indeed is just about client side. I could event do some overwriting to handle that but as quietmint said it would be far better to have the framework handle it
Re: [SOLVED] NotifyAllPlayersBut
Posted: 09 January 2021, 14:42
by fafa-fr
Well, I may have misunderstood quietmint (by reading / thinking too fast) when they said that "The vast majority of games do not have 100% open information".
Then if it's the same feature that we indeed need, you could upvote
https://en.studio.boardgamearena.com/bug?id=26
Re: [SOLVED] NotifyAllPlayersBut
Posted: 09 January 2021, 16:28
by Tisaac
fafa-fr wrote: ↑09 January 2021, 14:42
Well, I may have misunderstood quietmint (by reading / thinking too fast) when they said that "The vast majority of games do not have 100% open information".
Then if it's the same feature that we indeed need, you could upvote
https://en.studio.boardgamearena.com/bug?id=26
What he means was precisely that when someone draw a card, only this player should see the value of the card, but everyone should now he draws one. So that's indeed a game without 100% open information
Re: [SOLVED] NotifyAllPlayersBut
Posted: 15 January 2021, 19:41
by Hornir91
I'm also having this problem. I want to send log info to the player about his placed card (which would be placed face down, so he wouldn't be able to see it) via notifyPlayer() and also send a notification for all players via notifyAllPlayers() to show that he placed a card (but without private info).
Now when I'm using these two options, my placed card gets doubled and it would be nice to exclude current player (not active - it's multipleplayer state) so it wouldn't get doubled.
In a moment I will try to fix it with proposed solutions in this post but finally I would want to see a method to exclude current player from notifyAllPlayers() :/.
Re: [SOLVED] NotifyAllPlayersBut
Posted: 15 January 2021, 20:24
by Benoit314
For your specific problem, when you send these kind of double notifications, in JavaScript you just need to check if this.player_id is the one concerned by the notif, then do nothing in this case, since your other notification is handling it.
Re: [SOLVED] NotifyAllPlayersBut
Posted: 15 January 2021, 21:53
by Hornir91
Yeah, thanks. I was generally thinking about doing it with JS to exclude one notif based on current player.