Page 1 of 1

setting player_score / star on player panel

Posted: 21 September 2024, 07:06
by Ditto11
So I thought I had this figured out:

I'm using this code to calculate a player's score (simple chess-like game - score = pts of captured pieces).

Code: Select all

            // update score
            $value = $this->pieceValue[$captured_piece['piece_type']];
				$sql = "UPDATE player SET player_score_aux = player_score_aux + $value WHERE player_id = $player_id";
				self::DbQuery( $sql );
            
            $newScores = self::getCollectionFromDb( "SELECT player_id, player_score_aux score FROM player", true );
            self::notifyAllPlayers( "newScores", '', array( 'newScores' => $newScores ) );
and this works while in development .. however, just gone to ALPHA .. and it "seems" like this isn't working? I'm in a game with a friend testing things out, and I noticed our scores are both "0" despite both having captured pieces.

Did some searching, found this thread:

https://boardgamearena.com/forum/viewto ... ar#p151036

Code: Select all

            $sql = "SELECT player_id id, player_score score, player_no, player_name name, player_color color FROM player";
            $result["players"] = self::getCollectionFromDb($sql);

But that logic doesn't seem to update anything on the player's panel.

So why does original logic work in dev, but not in Alpha (ie production) ?
and how "SHOULD" I be coding it ?

(again, all I'm trying to do is update the score in the player panel next to the golden Star)

Re: setting player_score / star on player panel

Posted: 21 September 2024, 07:35
by Tisaac
You need to use player_score and not player_score_aux

Re: setting player_score / star on player panel

Posted: 21 September 2024, 17:11
by Ditto11
Yeah, I figured that .., and tried it .. but it didn't work ..

so I just re-tried again ..., and of course . it works now .. O.o

So obviously I did something different ... well, let's see if it keeps working in production .

thank you!