コード例 #1
0
 public function testGetIterator()
 {
     $cardCollection = new CardCollection();
     $this->assertInstanceOf(ArrayIterator::class, $cardCollection->getIterator());
 }
コード例 #2
0
ファイル: WarGame.php プロジェクト: bnowak/card-game
 /**
  * Get ont highest-rank card which is situated by players
  *
  * @return Card
  */
 protected function getOneHighestCardPutted() : Card
 {
     $this->gameTable->checkEveryPlayersHasSituatedCards();
     $this->checkIsOneHighestCardSituated();
     $lastPuttedCardsByPlayers = new CardCollection();
     foreach ($this->getPlayers() as $player) {
         if ($this->gameTable->getPlayerCards($player)->count() > 0) {
             $lastPuttedCardsByPlayers->append($this->gameTable->getPlayerCards($player)->getLast());
         }
     }
     foreach (array_reverse(self::ORDER_OF_FIGURES) as $orderedFigure) {
         if ($lastPuttedCardsByPlayers->hasCardWithFigure($orderedFigure)) {
             foreach ($lastPuttedCardsByPlayers as $card) {
                 if ($card->getFigure() === $orderedFigure) {
                     return $card;
                 }
             }
         }
     }
 }
コード例 #3
0
ファイル: GameTable.php プロジェクト: bnowak/card-game
 /**
  * Count cards which all players placed in pile
  *
  * @return int
  */
 public function countCardsSituatedInPile() : int
 {
     return $this->cardsPile->count();
 }