Ejemplo n.º 1
0
 private function assertPlayerStoneCount($stoneCount, Player $player)
 {
     $this->assertCount($stoneCount, $player->getStones());
 }
Ejemplo n.º 2
0
 /**
  * @param Player $player
  * @param Move   $move
  */
 public function addMove(Player $player, Move $move)
 {
     if (!$this->getState()->isStarted()) {
         throw new InvalidMoveException('Game has not started or is already finished');
     }
     if ($move->getTurnNumber() !== $this->getCurrentTurn()->getNumber()) {
         throw new InvalidMoveException('Turn number move does not match current game turn number');
     }
     if ($player->getNumber() !== $this->getCurrentTurn()->getPlayerNumber()) {
         throw new InvalidMoveException('player cannot move at the current turn (current player is ' . $this->getCurrentTurn()->getPlayerNumber() . ')');
     }
     $this->nextTurn();
 }
Ejemplo n.º 3
0
 private function assertPlayerDoesNotHaveStone(Player $player, Stone $stone)
 {
     $this->assertFalse($player->hasStone($stone), 'player does not have stone ' . $stone);
 }
Ejemplo n.º 4
0
 private function assertPlayerHasStones(Player $player, array $stoneValues)
 {
     $stones = $player->getStones();
     $this->assertEquals(count($stoneValues), count($stones), 'player should have ' . count($stoneValues) . ' stone(s)');
     reset($stoneValues);
     foreach ($stones as $stone) {
         $values = current($stoneValues);
         $topValue = $values[0];
         $bottomValue = $values[1];
         $this->assertEquals($topValue, $stone->getTopValue());
         $this->assertEquals($bottomValue, $stone->getBottomValue());
         next($stoneValues);
     }
 }