Skip to content

Commit

Permalink
fix: 2 players mode rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliboy50 committed Feb 1, 2024
1 parent 4497138 commit 5f72a65
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion velonimo.game.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
class Velonimo extends Table
{
private const NUMBER_OF_CARDS_TO_DEAL_TO_EACH_PLAYER = 11;
private const SCORE_TO_REACH_IN_2_PLAYERS_MODE = 8;

private const GAME_STATE_CURRENT_ROUND = 'currentRound';
private const GAME_STATE_JERSEY_IS_NOT_PLAYABLE = 'jerseyIsNotPlayable';
Expand Down Expand Up @@ -403,6 +404,9 @@ function playCards(
if (!$currentPlayerIsWearingJersey) {
$this->throwPlayedCardNotInPlayerHand();
}
if ($this->is2PlayersMode($players)) {
$this->throwPlayedCardNotInPlayerHand();
}
}
if ($cardsPlayedWithLegendsBroomWagon) {
if ($this->isLegendsBroomWagonNotPlayable()) {
Expand Down Expand Up @@ -1224,7 +1228,11 @@ function stEndRound() {
}

$howManyRounds = $this->getHowManyRounds();
$isGameOver = $currentRound >= $howManyRounds;
$isGameOver = ($currentRound >= $howManyRounds)
|| (
$this->is2PlayersMode()
&& array_reduce($players, fn (bool $acc, VelonimoPlayer $player) => $acc || ($player->getScore() >= self::SCORE_TO_REACH_IN_2_PLAYERS_MODE), false)
);

// 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
Expand Down
2 changes: 1 addition & 1 deletion velonimo.js
Original file line number Diff line number Diff line change
Expand Up @@ -1988,7 +1988,7 @@ function (dojo, declare) {
*/
getSpecialPlayerCardIds: function () {
return [
[CARD_ID_JERSEY_PLUS_TEN, () => this.currentPlayerHasJersey && !this.jerseyIsNotPlayable],
[CARD_ID_JERSEY_PLUS_TEN, () => this.currentPlayerHasJersey && !this.jerseyIsNotPlayable && !this.is2PlayersMode()],
[CARD_ID_LEGENDS_BROOM_WAGON_PLUS_FIVE, () => this.currentPlayerHasLegendsBroomWagon && !this.legendsBroomWagonIsNotPlayable],
[CARD_ID_LEGENDS_EAGLE_ADD_ONE_OTHER_NUMBER, () => this.currentPlayerHasLegendsEagle && !this.legendsEagleIsNotPlayable && !this.currentPlayerHasJersey],
[CARD_ID_LEGENDS_PANDA_ADD_ONE_OTHER_COLOR, () => this.currentPlayerHasLegendsPanda && !this.legendsPandaIsNotPlayable && !this.currentPlayerHasJersey],
Expand Down

0 comments on commit 5f72a65

Please sign in to comment.