Skip to content

Commit

Permalink
fix(style): bigger cards + tie breaker + keep pass bubble forever
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliboy50 committed Sep 9, 2022
1 parent 27c280d commit f0dbf58
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 72 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@

### Create sprite of cards

- Resize 180px wide PNG card images to be 90px wide and create sprite from them:
- Create sprite from 180px wide PNG card images:
```shell
magick montage $(ls blue-*.png) $(ls brown-*.png) $(ls gray-*.png) $(ls green-*.png) $(ls pink-*.png) $(ls red-*.png) $(ls yellow-*.png) jersey.png $(ls adventurer-*.png) -geometry +0+0 -tile 7x8 -mode concatenate -background none -resize 90 montage.png
magick montage $(ls blue-*.png) $(ls brown-*.png) $(ls gray-*.png) $(ls green-*.png) $(ls pink-*.png) $(ls red-*.png) $(ls yellow-*.png) jersey.png $(ls adventurer-*.png) -geometry +0+0 -tile 7x8 -mode concatenate -background none cards.png
```
- Reduce generated sprite size by ~90% sending it to https://tinypng.com

- Reduce generated sprite size by ~90% (using https://tinypng.com or https://compresspng.com if the file is too large)

## License

Expand All @@ -21,11 +20,11 @@ See [Velonimo on BoardGameGeek](https://boardgamegeek.com/boardgame/323262/velon

### Board Game Arena adaptation (this repository)

What is contained in the first commit is licensed under [LICENCE_BGA](LICENCE_BGA) file (this is the source code generated by the Board Game Arena framework).
What is contained in the first git commit is licensed under [LICENCE_BGA](LICENCE_BGA) file (this is the source code generated by the Board Game Arena framework).

The images (in `img`) come from the original game design which is the property of the [Velonimo game designers](https://boardgamegeek.com/boardgame/323262/velonimo).
The usage of these images in this project is done with the agreement of the Velonimo game publisher ([Stratosphères](https://www.studiostratospheres.com)).

The game interface is inspired from [bga-papayoo](https://github.com/Syarwin/bga-papayoo).

All the rest is licensed under GPLv3 - See [LICENSE.md](LICENSE.md) file.
The rest is licensed under GPLv3, credits go to the git commits author. - See [LICENSE.md](LICENSE.md) file.
12 changes: 6 additions & 6 deletions gameinfos.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@
// Time in second add to a player when "giveExtraTime" is called (speed profile = slow)
'slow_additional_time' => 50,

// If you are using a tie breaker in your game (using "player_score_aux"), you must describe here
// If you are using a tiebreaker in your game (using "player_score_aux"), you must describe here
// the formula used to compute "player_score_aux". This description will be used as a tooltip to explain
// the tie breaker to the players.
// Note: if you are NOT using any tie breaker, leave the empty string.
// the tiebreaker to the players.
// Note: if you are NOT using any tiebreaker, leave the empty string.
//
// Example: 'tie_breaker_description' => totranslate( "Number of remaining cards in hand" ),
'tie_breaker_description' => '',
'tie_breaker_description' => totranslate('Number of points earned during the last round'),

// If in the game, all losers are equal (no score to rank them or explicit in the rules that losers are not ranked between them), set this to true
// The game end result will display "Winner" for the 1st player and "Loser" for all other players
Expand Down Expand Up @@ -100,10 +100,10 @@
'strategy' => 3,

// Diplomacy of the game, from 0 (no interaction in this game) to 5 (totally based on interaction and discussion between players)
'diplomacy' => 1,
'diplomacy' => 2,

// Colors attributed to players
'player_colors' => ['ff0000', '008000', '0000ff', 'ffa500', '773300'],
'player_colors' => ['ff0000', '00aa00', '2222ff', 'ffbb00', '222222'],

// Favorite colors support : if set to "true", support attribution of favorite colors based on player's preferences (see reattributeColorsBasedOnPreferences PHP method)
// NB: this parameter is used only to flag games supporting this feature; you must use (or not use) reattributeColorsBasedOnPreferences PHP method to actually enable or disable the feature.
Expand Down
Binary file modified img/cards.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion modules/VelonimoPlayer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class VelonimoPlayer
private string $name;
private string $color;
private int $score;
private int $lastNumberOfPointsEarned;
/**
* @var array<int, int> where the key is the round_number and the value is the rank_number
* Example: if the player finished 1st during the 2nd round (i.e. he won this round), the array will contain [..., 2 => 1, ...].
Expand All @@ -25,6 +26,7 @@ public function __construct(
string $name,
string $color,
int $score,
int $lastNumberOfPointsEarned,
array $roundsRanking,
bool $isWearingJersey
) {
Expand All @@ -33,6 +35,7 @@ public function __construct(
$this->name = $name;
$this->color = $color;
$this->score = $score;
$this->lastNumberOfPointsEarned = $lastNumberOfPointsEarned;
$this->roundsRanking = $roundsRanking;
$this->isWearingJersey = $isWearingJersey;
}
Expand Down Expand Up @@ -102,6 +105,10 @@ public function getScore(): int
{
return $this->score;
}
public function getLastNumberOfPointsEarned(): int
{
return $this->lastNumberOfPointsEarned;
}
public function isWearingJersey(): bool
{
return $this->isWearingJersey;
Expand All @@ -124,12 +131,18 @@ public function isLastRoundWinner(): bool
/*
* SETTERS
*/
public function addPoints($points): self
public function addPoints(int $points): self
{
$this->score = $this->score + $points;

return $this;
}
public function setLastNumberOfPointsEarned(int $lastNumberOfPointsEarned): self
{
$this->lastNumberOfPointsEarned = $lastNumberOfPointsEarned;

return $this;
}
public function setIsWearingJersey(bool $isWearingJersey): self
{
$this->isWearingJersey = $isWearingJersey;
Expand Down
24 changes: 15 additions & 9 deletions velonimo.css
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Board
font-weight: bold;
border: 2px solid transparent;
box-sizing: border-box;
z-index: 1;
z-index: 5;
}
.player-table.selectable .player-table-name,
.player-table.selectable-for-card-picking .player-table-name {
Expand Down Expand Up @@ -151,6 +151,7 @@ Board
padding-left: 100px;
transition-property: top, bottom;
transition-duration: 1s;
z-index: 4;
}
.player-table.selectable .player-table-hand,
.player-table.selectable-for-card-picking .player-table-hand {
Expand Down Expand Up @@ -214,7 +215,7 @@ Board
font-weight: bold;
opacity: 0;
transition-property: opacity;
transition-duration: 0.4s;
transition-duration: 0.5s;
}
.player-table.selectable .player-table-speech-bubble,
.player-table.selectable-for-card-picking .player-table-speech-bubble {
Expand Down Expand Up @@ -265,8 +266,7 @@ Board
.player-table.player-position-bottom .player-table-speech-bubble.speech-bubble-on-right::after {
transform: rotate(60deg);
}
.player-table-speech-bubble.show-bubble,
.player-table-speech-bubble.temporary-show-bubble {
.player-table-speech-bubble.show-bubble {
opacity: 1;
}
.player-table.is-wearing-jersey .player-table-jersey {
Expand Down Expand Up @@ -353,17 +353,23 @@ Board cards
height: 148px; /* cardHeight + (cardHeight / 6) */
z-index: 4;
}
#previous-last-played-cards {
position: absolute;
top: 0;
height: 126px; /* cardHeight */
z-index: 8;
}
#last-played-cards {
position: absolute;
bottom: 0;
height: 126px; /* cardHeight */
z-index: 10;
}
#previous-last-played-cards {
position: absolute;
top: 0;
height: 126px; /* cardHeight */
z-index: 8;
#previous-last-played-cards .velonimo-card,
#last-played-cards .velonimo-card {
transition-property: all;
transition-duration: 0.5s;
transform: scale(1.2);
}
/* /!\ 2P mode only */
#cards-deck {
Expand Down
49 changes: 28 additions & 21 deletions velonimo.game.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,14 +413,14 @@ function playCards(array $playedCardIds, bool $cardsPlayedWithJersey) {
if (($numberOfCurrentPlayerCards - $numberOfPlayedCards) === 0) {
$currentRound = (int) self::getGameStateValue(self::GAME_STATE_CURRENT_ROUND);
$nextRankForRound = $this->getNextRankForRound($players, $currentRound);
$currentPlayer->addRoundRanking($currentRound, $nextRankForRound);
$this->updatePlayerRoundsRanking($currentPlayer);
$this->updatePlayerRoundsRanking($currentPlayer, $players, $currentRound, $nextRankForRound);
if ($nextRankForRound === 1) {
$this->incStat(1, 'numberOfRoundsWon', $currentPlayerId);
}
self::notifyAllPlayers('playerHasFinishedRound', clienttranslate('${player_name} finished in position ${rank}'), [
'playerId' => $currentPlayer->getId(),
'roundsRanking' => $currentPlayer->getRoundsRanking(),
'lastNumberOfPointsEarned' => $currentPlayer->getLastNumberOfPointsEarned(),
'player_name' => $currentPlayerName,
'rank' => $nextRankForRound,
]);
Expand All @@ -433,8 +433,7 @@ function playCards(array $playedCardIds, bool $cardsPlayedWithJersey) {
// end the round if there is only 1 player who can play now
if (count($playersWhoCanPlay) === 1) {
$lastPlayer = $playersWhoCanPlay[0];
$lastPlayer->addRoundRanking($currentRound, $nextRankForRound + 1);
$this->updatePlayerRoundsRanking($lastPlayer);
$this->updatePlayerRoundsRanking($lastPlayer, $players, $currentRound, $nextRankForRound + 1);

$this->gamestate->nextState('endRound');
return;
Expand Down Expand Up @@ -909,19 +908,9 @@ function stApplySelectedNextPlayer() {
function stEndRound() {
// update players score and jersey
$players = $this->getPlayersFromDatabase();
$numberOfPlayers = count($players);
$currentRound = (int) self::getGameStateValue(self::GAME_STATE_CURRENT_ROUND);
$numberOfPointsForRoundByPlayerId = [];
foreach ($players as $k => $player) {
$playerCurrentRoundRank = $player->getLastRoundRank();
$numberOfPointsForRoundByPlayerId[$player->getId()] = $this->getNumberOfPointsAtRankForRound(
$playerCurrentRoundRank,
$currentRound,
$numberOfPlayers
);
$players[$k] = $player->addPoints(
$numberOfPointsForRoundByPlayerId[$player->getId()]
);
$players[$k] = $player->addPoints($player->getLastNumberOfPointsEarned());
}
$newWinner = $this->getCurrentWinner($players);
foreach ($players as $k => $player) {
Expand Down Expand Up @@ -949,9 +938,9 @@ function stEndRound() {
$translatedMessageForPoints = clienttranslate('${player_name} wins ${points} point(s)');
$translatedMessageForNoPoints = clienttranslate('${player_name} does not get any point');
foreach ($players as $player) {
self::notifyAllPlayers('pointsWon', ($numberOfPointsForRoundByPlayerId[$player->getId()] > 0) ? $translatedMessageForPoints : $translatedMessageForNoPoints, [
self::notifyAllPlayers('pointsWon', ($player->getLastNumberOfPointsEarned() > 0) ? $translatedMessageForPoints : $translatedMessageForNoPoints, [
'player_name' => $player->getName(),
'points' => $numberOfPointsForRoundByPlayerId[$player->getId()],
'points' => $player->getLastNumberOfPointsEarned(),
]);
}

Expand Down Expand Up @@ -983,7 +972,7 @@ function stEndRound() {
],
'type' => 'header'
];
$roundPoints[] = $numberOfPointsForRoundByPlayerId[$player->getId()];
$roundPoints[] = $player->getLastNumberOfPointsEarned();
$totalPoints[] = $player->getScore();
}
$this->notifyAllPlayers( 'tableWindow', '', array(
Expand Down Expand Up @@ -1150,7 +1139,7 @@ private function getCardsValue(array $cards, bool $withJersey): int {
*/
private function getPlayersFromDatabase(): array {
$players = array_values(self::getCollectionFromDB(
'SELECT player_id, player_no, player_name, player_color, player_score, rounds_ranking, is_wearing_jersey FROM player'
'SELECT player_id, player_no, player_name, player_color, player_score, player_score_aux, rounds_ranking, is_wearing_jersey FROM player'
));

return array_map(
Expand All @@ -1160,6 +1149,7 @@ private function getPlayersFromDatabase(): array {
$player['player_name'],
$player['player_color'],
(int) $player['player_score'],
(int) $player['player_score_aux'],
VelonimoPlayer::deserializeRoundsRanking($player['rounds_ranking']),
((int) $player['is_wearing_jersey']) === 1
),
Expand Down Expand Up @@ -1227,6 +1217,7 @@ private function formatPlayersForClient(array $players): array {
'name' => $player->getName(),
'color' => $player->getColor(),
'score' => $player->getScore(),
'lastNumberOfPointsEarned' => $player->getLastNumberOfPointsEarned(),
'roundsRanking' => $player->getRoundsRanking(),
'isWearingJersey' => $player->isWearingJersey(),
'howManyCards' => count($this->deck->getCardsInLocation(self::CARD_LOCATION_PLAYER_HAND, $player->getId())),
Expand Down Expand Up @@ -1351,10 +1342,26 @@ private function discardAttackRewardCards(): void {
self::notifyAllPlayers('attackRewardCardsDiscarded', '', []);
}

private function updatePlayerRoundsRanking(VelonimoPlayer $player): void {
/**
* @param VelonimoPlayer[] $players
*/
private function updatePlayerRoundsRanking(
VelonimoPlayer $player,
array $players,
int $currentRound,
int $nextRankForRound
): void {
$player->addRoundRanking($currentRound, $nextRankForRound);
$player->setLastNumberOfPointsEarned($this->getNumberOfPointsAtRankForRound(
$player->getLastRoundRank(),
$currentRound,
count($players)
));

self::DbQuery(sprintf(
'UPDATE player SET rounds_ranking="%s" WHERE player_id=%s',
'UPDATE player SET rounds_ranking="%s", player_score_aux=%s WHERE player_id=%s',
VelonimoPlayer::serializeRoundsRanking($player->getRoundsRanking()),
$player->getLastNumberOfPointsEarned(),
$player->getId()
));
}
Expand Down
Loading

0 comments on commit f0dbf58

Please sign in to comment.