updating player boards

Game development with Board Game Arena Studio
Post Reply
Gauben
Posts: 11
Joined: 23 February 2025, 20:45

updating player boards

Post by Gauben »

I seem to be stuck and not able to update the player score on the board. I'm using the scoreCtrl but only when I refresh the page do the scores get updated. I'm receiving the notif with all the args but nothing after. Here are the codes I'm using.

serverside:

$newScores = $this->getCollectionFromDb("SELECT player_id, player_score FROM player", true);
$this->notify->all("scoreUpdate", "", array(
"scores" => $newScores
));
-------------------------
client side:

notif_scoreUpdate: async function(args) {
console.log("Received scoreUpdate notification with:", args);

for( var player_id in args.scores )
{
var newScore = args.scores[ player_id ];
this.scoreCtrl[ player_id ].toValue( newScore );
}
},
User avatar
thoun
Posts: 1620
Joined: 10 December 2020, 22:25

Re: updating player boards

Post by thoun »

At first sight, it seems good. Does the console.log displays what you expect in it? Do you have errors in the console?
Gauben
Posts: 11
Joined: 23 February 2025, 20:45

Re: updating player boards

Post by Gauben »

yes actually I was able to narrow on the issue. The console log shows that all the information is sent with the notif, but the information in the args are undefined. The issue seem to be how the information is structured inside the args.

Image
User avatar
thoun
Posts: 1620
Joined: 10 December 2020, 22:25

Re: updating player boards

Post by thoun »

If you use the new notification system (bgaSetupPromiseNotifications), "notif_scoreUpdate: async function(args) {" is correct.
If you use the old way (dojo.subscribe) then you receive an objectif "notif" containing the args.
The new way ditch the useless level.
Gauben
Posts: 11
Joined: 23 February 2025, 20:45

Re: updating player boards

Post by Gauben »

Oh thanks, that was the issue, I was sending the old way I guess, switching to notif_scoreUpdate: function(notif) fixed my problem.
Post Reply

Return to “Developers”