From 5f72a65eb412196d46c3bb7be3e86bad68924883 Mon Sep 17 00:00:00 2001 From: Oliboy50 Date: Thu, 1 Feb 2024 12:08:17 +0100 Subject: [PATCH] fix: 2 players mode rules --- velonimo.game.php | 10 +++++++++- velonimo.js | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/velonimo.game.php b/velonimo.game.php index 20a775b..75d3e00 100644 --- a/velonimo.game.php +++ b/velonimo.game.php @@ -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'; @@ -403,6 +404,9 @@ function playCards( if (!$currentPlayerIsWearingJersey) { $this->throwPlayedCardNotInPlayerHand(); } + if ($this->is2PlayersMode($players)) { + $this->throwPlayedCardNotInPlayerHand(); + } } if ($cardsPlayedWithLegendsBroomWagon) { if ($this->isLegendsBroomWagonNotPlayable()) { @@ -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 diff --git a/velonimo.js b/velonimo.js index 408de1f..bb607e0 100644 --- a/velonimo.js +++ b/velonimo.js @@ -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],