Skip to content

$this->bga->playerScoreAux

The built-in PlayerCounter for player.player_score_aux. Access the same instance through $this->bga->playerScoreAux or $this->playerScoreAux in Game.

For normal scoring, the framework uses the auxiliary score to rank players whose main scores are equal. Higher auxiliary scores rank first. Set a value that represents your game’s tie-breaking rule.

The counter starts at 0, has no minimum or maximum, and uses player IDs by default. Do not create another counter named player_score_aux.

API

Use the same get, set, inc, getAll, and setAll methods as playerScore. The full API, including notification controls and player-number mode, is documented under PlayerCounter.

// For a rule that breaks score ties using remaining money:
$this->bga->playerScoreAux->set($playerId, $remainingMoney);

See the scoring reference for reverse scoring, cooperative results, and other ranking rules.

Describing the tie breaker

Set tie_breaker_description in gameinfos to explain the auxiliary score in the results tooltip:

gameinfos.jsonc
"tie_breaker_description": "Remaining money"

The results screen shows the auxiliary score when main scores are tied. If both scores are equal, the players remain tied. For several ordered tie breakers, combine them into one integer and configure multiple tie breakers with tie_breaker_split.

Lowest auxiliary score wins

Return a GameResult from the final state instead of returning state ID 99:

use Bga\GameFramework\GameResult\GameResult;

public function onEnteringState(): GameResult
{
    return GameResult::individualRanking(reverseScoreAux: true);
}

This reverses only the tie breaker. Set reverseScore: true as well if lower main scores also rank first. Store scores in the form you want displayed; see reverse scoring.