コード例 #1
0
ファイル: PlayerTest.php プロジェクト: bnowak/card-game
 public function testCheckPlayerHasCard()
 {
     $player = new Player('player name');
     $card = TestDataProvider::getCard2();
     $player->getCards()->append($card);
     $player->checkPlayerHasCard($card);
     $this->addToAssertionCount(1);
     $player->getCards()->clear();
     $expectedException = PlayerException::playerDoesNotHaveCard($player, $card);
     $this->expectException(get_class($expectedException));
     $this->expectExceptionMessage($expectedException->getMessage());
     $player->checkPlayerHasCard($card);
 }
コード例 #2
0
ファイル: WarGame.php プロジェクト: bnowak/card-game
 /**
  * When $winPlayer win round, it is collect all cards which are situated on GameTable
  *
  * @param Player $winPlayer
  */
 protected function collectCardsByWinnerPlayer(Player $winPlayer)
 {
     $winCardsCollection = new CardCollection();
     foreach ($this->getPlayers() as $player) {
         $winCardsCollection->appendMany($this->gameTable->getPlayerCards($player)->collectAll());
     }
     $winCardsCollection->setAllVisible(false);
     $winCardsCollection->shuffle();
     $winPlayer->getCards()->prependMany($winCardsCollection->collectAll());
 }
コード例 #3
0
ファイル: AbstractGame.php プロジェクト: bnowak/card-game
 /**
  * Add player to implemented game
  *
  * @param Player $player
  */
 private function addPlayer(Player $player)
 {
     $this->players[] = $player;
     $player->setGame($this);
     $player->getCards()->clear();
 }