/** * @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; }
public function diff(SolutionHand $compHand) { if ($this->handType === $compHand->getHandType()) { return $this->getHighValue() - $compHand->getHighValue(); } return $this->getHandType() - $compHand->getHandType(); }