private function serializeHand(Hand $hand = null)
 {
     if ($hand === null) {
         return null;
     }
     return ['value' => $hand->getValue(), 'canSplitHand' => $hand->canSplitPair(), 'cards' => $hand->getCards()->map(function (Card $card) {
         return $this->serializeCard($card);
     })->elements()];
 }
 private function serializeHand(Hand $hand = null)
 {
     if ($hand === null) {
         return null;
     }
     return ['value' => $hand->getValue(), 'cards' => $hand->getCards()->map(function (Card $card) {
         return ['rank' => $card->getRank(), 'suit' => $card->getSuit()];
     })->elements()];
 }
Example #3
0
 /**
  * Splits this pair into two decks containing single cards.
  *
  * @return Vector|Hand[]
  */
 public function splitPair()
 {
     if (!$this->canSplitPair()) {
         throw new \LogicException('Cannot split this hand.');
     }
     $hand1 = new Hand(false);
     $hand1->addCard($this->cards[0]);
     $hand2 = new Hand(false);
     $hand2->addCard($this->cards[1]);
     return new Vector([$hand1, $hand2]);
 }
Example #4
0
 private function computeWinningModifier(Hand $playerHand)
 {
     if ($playerHand->isInitialHand() && $playerHand->isBlackjack()) {
         // Blackjack pays 3:2
         return 1.5;
     }
     return 1;
 }