Exemplo n.º 1
0
 public function beats(Hand $oHand)
 {
     return $this->getResult()->getScore() > $oHand->getResult()->getScore();
 }
Exemplo n.º 2
0
require dirname(__FILE__) . '/src/Util/Combinations.php';
require dirname(__FILE__) . '/src/Poker/Constants.php';
require dirname(__FILE__) . '/src/Poker/CardBag.php';
require dirname(__FILE__) . '/src/Poker/HandCombinations.php';
require dirname(__FILE__) . '/src/Poker/Hand.php';
require dirname(__FILE__) . '/src/Poker/Card.php';
require dirname(__FILE__) . '/src/Poker/Deck.php';
require dirname(__FILE__) . '/src/Poker/Result.php';
use Poker\Deck;
use Poker\Hand;
use Poker\HandCombinations;
if (false) {
    $aTestHands = array('TH TS TC KH KC', 'QH QS QC 2H 2C', 'TH TS TC KH AH', 'AH 2S 3C 4H 5H', 'TH TS QH KH AH', 'TH TS 9H 9S AS', 'TH TS KH KS AS', 'TH JH QH KH AH');
    $aTestHandsScores = array();
    foreach ($aTestHands as $s) {
        $o = new Hand(explode(' ', $s));
        $aTestHandsScores[$s] = array('hand' => $o->getResult()->getHand(), 'score' => $o->getResult()->getScore());
    }
    uasort($aTestHandsScores, function ($a, $b) {
        return $a['score'] - $b['score'];
    });
    print_r(array_reverse($aTestHandsScores));
    die;
}
$bDebug = true;
$aInput = array("TH JH QC QD QS QH KH AH 2S 6S" => "royal-flush");
foreach ($aInput as $sInput => $sExpectedResult) {
    $aCards = explode(" ", $sInput);
    $aHand = array_splice($aCards, 0, HAND_SIZE, array());
    $aDeck = array_splice($aCards, 0, HAND_SIZE, array());
    $oDeck = new Deck($aDeck);