/** * Get royal flush in hand or false * * @return PokerHand|false */ private function getRoyalFlush() { if (isset($this->skipTypes['royal_flush'])) { return false; } // if we have a straight flush and the last (highest) card is an ace, we have a royal. $sFlush = $this->getStraightFlush(); if ($sFlush instanceof PokerHand && $this->last()->getRank() == CardNumber::getRank(CardNumber::ACE)) { return new PokerHand(HandType::ROYAL_FLUSH, $sFlush); } $this->skipTypes['royal_flush'] = true; return false; }
/** * Build and shuffle deck * * @throws GameLogicException If card count isn't right */ private function buildAndShuffleDeck() { $orderedDeck = []; foreach (CardSuit::getAll() as $suit) { foreach (CardNumber::getAll() as $number) { $orderedDeck[] = new Card($number, $suit); } } // heh. name's appropriate. // Who knows how "random" this really is but it works to illustrate the point here. shuffle($orderedDeck); foreach ($orderedDeck as $card) { $this->deck->addCard($card); } $this->assertDeckCount(52); }