Beispiel #1
0
 /**
  * @param HandInterface $hand
  *
  * @return HandInterface
  */
 public function find(HandInterface $hand)
 {
     if (count($hand->getCards()) < 5) {
         return null;
     }
     $cards = $hand->getCards();
     foreach ($cards as $card) {
         $start = max($card->getFaceValue() - 4, 1);
         $end = min($card->getFaceValue() + 4, 14);
         $flushCards = [];
         for ($faceValueCounter = $start; $faceValueCounter <= $end; ++$faceValueCounter) {
             $matchingHand = $this->handSearch->search(new Card($faceValueCounter == 1 ? 14 : $faceValueCounter, Suit::diamonds()), $hand);
             if ($matchingHand && count($matchingHand->getCards())) {
                 $flushCards[] = $matchingHand->getCards()[0];
             }
             if (count($flushCards) == 5) {
                 return new Hand(...$flushCards);
             }
         }
     }
     return null;
 }
Beispiel #2
0
 public static function three_of_a_kind_actual_three()
 {
     return [new Card(2, Suit::spades()), new Card(2, Suit::flowers()), new Card(2, Suit::diamonds())];
 }