Auto score on setup

Game development with Board Game Arena Studio
Post Reply
User avatar
Tisaac
Posts: 2743
Joined: 26 August 2014, 21:28

Auto score on setup

Post by Tisaac »

Hi,

I was thinking that the score counter would automatically take the value in gamedatas.players[id].player_score on setup but this is not working.
How are we supposed to setup the scores then ?
I tried using scoreCtrl but these are not working in the the setup function, I have to wait to enter some state to make them work...
And using a notification seems a little bit too much...
User avatar
RicardoRix
Posts: 2548
Joined: 29 April 2012, 23:43

Re: Auto score on setup

Post by RicardoRix »

Adjust player_score in the players table in the setupNewGame()

self::DbQuery( "UPDATE player SET player_score = $money");
User avatar
Tisaac
Posts: 2743
Joined: 26 August 2014, 21:28

Re: Auto score on setup

Post by Tisaac »

Already done but it is not showing up...
The only solution I have found so far is calling a function at each enteringState to make sure scores are consistent...

Code: Select all

updateScore: function(){
 for(var pId in this.gamedatas.players){
    this.scoreCtrl[pId].toValue( this.gamedatas.players[pId].player_score);
  }
}
User avatar
RicardoRix
Posts: 2548
Joined: 29 April 2012, 23:43

Re: Auto score on setup

Post by RicardoRix »

it works for me. I think you're missing something.

It's done automatically, because the same as a F5, there is nothing required JS client side to update the controls. It's only if you need to adjust the scores with a notification do you need to do the JS stuff.
User avatar
Tisaac
Posts: 2743
Joined: 26 August 2014, 21:28

Re: Auto score on setup

Post by Tisaac »

Can you show me an allDatas example that works ?
Maybe the field name is important.
User avatar
RicardoRix
Posts: 2548
Joined: 29 April 2012, 23:43

Re: Auto score on setup

Post by RicardoRix »

I already did ^^

self::DbQuery( "UPDATE player SET player_score = $money");

If you go to the database and look at the player table, what does it say?
User avatar
Tisaac
Posts: 2743
Joined: 26 August 2014, 21:28

Re: Auto score on setup

Post by Tisaac »

No, I meant an example of getAllDatas.
The field player_score is working, the end of game is also working, it's really just the UI that won't get the proper field.
I am overwriting the default "player" key of gamedatas, so perhaps the naming of the field inside it is wrong (I am using player_score where maybe the BGA framework is using juste "score" by default ?)
User avatar
RicardoRix
Posts: 2548
Joined: 29 April 2012, 23:43

Re: Auto score on setup

Post by RicardoRix »

just the default code:
$sql = "SELECT player_id id, player_score score FROM player ";
$result['players'] = self::getCollectionFromDb( $sql );

so its just 'score' client side.
Why would you overwrite that? I can't see any possible benefit from doing that, plus like now having problems like this.
User avatar
Tisaac
Posts: 2743
Joined: 26 August 2014, 21:28

Re: Auto score on setup

Post by Tisaac »

RicardoRix wrote: 13 July 2020, 15:45 just the default code:
$sql = "SELECT player_id id, player_score score FROM player ";
$result['players'] = self::getCollectionFromDb( $sql );

so its just 'score' client side.
Why would you overwrite that? I can't see any possible benefit from doing that, plus like now having problems like this.
Ok i will try with score.

On this game, I am actually finishing someone else's project so this was already written.
On other project, I usually avoid sending collection on the js side because it can no longer being iterated over using js array functions (which are the best)
Post Reply

Return to “Developers”