Skip to content

Commit

Permalink
feat: show table of scores between each round
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliboy50 committed Jun 9, 2022
1 parent b09fd02 commit e8173e2
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 10 deletions.
7 changes: 7 additions & 0 deletions velonimo.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@

/* Note: you must not use any @import directive */

/**
Override "tableWindow" style (BGA framework feature)
*/
.tableWindow table {
width: 100%;
}

/**
Board
*/
Expand Down
63 changes: 53 additions & 10 deletions velonimo.game.php
Original file line number Diff line number Diff line change
Expand Up @@ -752,13 +752,15 @@ function stEndRound() {
$players = $this->getPlayersFromDatabase();
$numberOfPlayers = count($players);
$currentRound = (int) self::getGameStateValue(self::GAME_STATE_CURRENT_ROUND);
$numberOfPointsForRoundByPlayerId = [];
foreach ($players as $k => $player) {
$numberOfPointsForRoundByPlayerId[$player->getId()] = $this->getNumberOfPointsAtRankForRound(
$player->getLastRoundRank(),
$currentRound,
$numberOfPlayers
);
$players[$k] = $player->addPoints(
$this->getNumberOfPointsAtRankForRound(
$player->getLastRoundRank(),
$currentRound,
$numberOfPlayers
)
$numberOfPointsForRoundByPlayerId[$player->getId()]
);
}
$newWinner = $this->getCurrentWinner($players);
Expand All @@ -783,13 +785,54 @@ function stEndRound() {
'players' => $this->formatPlayersForClient($players),
]);

// go to next round or end the game
$howManyRounds = (int) self::getGameStateValue(self::GAME_OPTION_HOW_MANY_ROUNDS);
if ($currentRound < $howManyRounds) {
$this->gamestate->nextState('nextRound');
} else {
$this->gamestate->nextState('endGame');
$isGameOver = $currentRound >= $howManyRounds;

// use "Scoring dialogs" to recap scoring for end-users before moving forward
// @see https://en.doc.boardgamearena.com/Game_interface_logic:_yourgamename.js#Scoring_dialogs
$headers = [
'', // first column of headers line does not have content
];
$roundPoints = [
[
'str' => clienttranslate('Round points'),
'args' => [],
],
];
$totalPoints = [
[
'str' => clienttranslate('Total points'),
'args' => [],
],
];
foreach ($players as $player) {
$headers[] = [
'str' => '${player_name}',
'args' => [
'player_name' => $player->getName(),
],
'type' => 'header'
];
$roundPoints[] = $numberOfPointsForRoundByPlayerId[$player->getId()];
$totalPoints[] = $player->getScore();
}
$this->notifyAllPlayers( 'tableWindow', '', array(
'id' => 'finalScoring',
'title' => sprintf(
clienttranslate('Result of round %s/%s'),
$currentRound,
$howManyRounds
),
'table' => [
$headers,
$roundPoints,
$totalPoints
],
'closing' => $isGameOver ? clienttranslate('End of game') : clienttranslate('Next round')
));

// go to next round or end the game
$this->gamestate->nextState($isGameOver ? 'endGame' : 'nextRound');
}

////////////////////////////////////////////////////////////////////////////
Expand Down
5 changes: 5 additions & 0 deletions velonimo.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ const PLAYERS_PLACES_BY_NUMBER_OF_PLAYERS = {
// @TODO: show cards in logs (especially the cards picked/gave for the impacted players)
// @TODO: color player names (logs, action messages)
// @TODO: support 2 players game
// @TODO: ? game rounds topology instead of choosing number of rounds
// @TODO: ? be able to move cards individually in your hand
// @TODO: ? add the winner in the end of round log
// @TODO: ? be able to click on the jersey to play it instead of having a 2nd button
// @TODO: ? improve the visibility of the jersey that has been played with the combination on the table
define([
'dojo','dojo/_base/declare',
'ebg/core/gamegui',
Expand Down

0 comments on commit e8173e2

Please sign in to comment.