コード例 #1
0
ファイル: BoardTest.php プロジェクト: JBuijgers/jb-ludo-game
 /** @test */
 public function playerCanFinish()
 {
     $this->board->moveToken(Player::$GREEN, new TokenNumber(1), new CheaterDice(6, 6));
     $this->board->moveToken(Player::$GREEN, new TokenNumber(1), new CheaterDice(6, 40));
     $this->board->moveToken(Player::$GREEN, new TokenNumber(2), new CheaterDice(6, 6));
     $this->board->moveToken(Player::$GREEN, new TokenNumber(2), new CheaterDice(6, 41));
     $this->board->moveToken(Player::$GREEN, new TokenNumber(3), new CheaterDice(6, 6));
     $this->board->moveToken(Player::$GREEN, new TokenNumber(3), new CheaterDice(6, 42));
     $this->board->moveToken(Player::$GREEN, new TokenNumber(4), new CheaterDice(6, 6));
     $this->board->moveToken(Player::$GREEN, new TokenNumber(4), new CheaterDice(6, 43));
     $this->assertTrue($this->board->hasFinished(Player::$GREEN));
 }
コード例 #2
0
ファイル: Game.php プロジェクト: JBuijgers/jb-ludo-game
 /**
  * @param Dice        $dice
  * @param TokenNumber $tokenToMove
  *
  * @throws DomainException If the game has finished
  */
 public function playTurn(Dice $dice, TokenNumber $tokenToMove)
 {
     if ($this->playersInGame->allPlayersFinished()) {
         throw new DomainException('All players finished, the game has ended.');
     }
     $this->currentTurn++;
     $player = $this->currentPlayer();
     $this->board->moveToken($player, $tokenToMove, $dice);
     if ($this->board->hasFinished($player)) {
         $this->playersInGame->finishPlayer($player);
     }
     if (!$dice->equals(6)) {
         $this->passTurn();
     }
 }