예제 #1
0
파일: Player.php 프로젝트: hkxnyc/php_poker
 /**
  * @param Dealer $dealer
  * @return SolutionHand|null
  */
 public function getWinningHand(Dealer $dealer)
 {
     $winningHand = null;
     $allCards = array_merge($this->getCards(), $dealer->getCards());
     $allCardCombos = $this->getCombinations($allCards, 5);
     foreach ($allCardCombos as $cardCombo) {
         $solutionHand = new SolutionHand($cardCombo);
         if (!$winningHand || $solutionHand->diff($winningHand) > 0) {
             $winningHand = $solutionHand;
         }
     }
     return $winningHand;
 }
예제 #2
0
 public function diff(SolutionHand $compHand)
 {
     if ($this->handType === $compHand->getHandType()) {
         return $this->getHighValue() - $compHand->getHighValue();
     }
     return $this->getHandType() - $compHand->getHandType();
 }