Update players

Game development with Board Game Arena Studio
Post Reply
User avatar
DirkDeBelg
Posts: 11
Joined: 09 September 2013, 21:06

Update players

Post by DirkDeBelg »

Hello

I added custom fields to the player table and they end-up in the gamedatas.player variable.

I need to trigger an UI via an notification after that I updated some customer fields in the player table. I actually want to persist that information in the client back into the gamedatas.player object in the notification handler.

What is the best way to force a refresh of this gamesdata.player object ? In the getAllDatas() routine, it seems you don't need to specify all standard, BGA-managed fields of the player table, while they are being received on the client. When passing an array to the notification args, that is not done automatically.

Dirk
User avatar
RicardoRix
Posts: 2541
Joined: 29 April 2012, 23:43

Re: Update players

Post by RicardoRix »

You could do this:

php notification argument, you have to rename ALL the fields to suit. The id field has to be first to make it the key of the array.

Code: Select all

 	'players' => self::getCollectionFromDB( "SELECT player_id id, player_score score, player_no,  ..additional fields... " FROM player");

JS notification:

Code: Select all

this.gamedatas.players = notif.args.players;
User avatar
DirkDeBelg
Posts: 11
Joined: 09 September 2013, 21:06

Re: Update players

Post by DirkDeBelg »

Thanks, I was indeed thinking about that way, but then I could expect future compatibility issues. What if I replace the player game and BGA would add common features to the player table. I think I'll stick to copying the whole players object into a custom client object and using that for my logic.
Post Reply

Return to “Developers”