コード例 #1
0
        $deck[] = array("face" => $face, "suit" => $suit, "value" => $value);
    }
}
shuffle($deck);
$card = array_shift($deck);
print_r($card['face'] . ' of ' . $card['suit'] . " => " . $card['value']);
function countCards()
{
}
function evaluateHand($hand)
{
    global $faces;
    $value = 0;
    foreach ($hand as $card) {
        if ($value > 11 && $card['face'] == 'Ace') {
            $value = $value + 1;
        } else {
            $value = intval($value) + intval($faces[$card['face']]);
        }
    }
    return $value;
}
$size = count($deck);
evaluateHand($card);
?>

    </p>

    </body>
</html>
コード例 #2
0
echo $handstr;
?>
' />
<input type='hidden' name='deckstr' value = '<?php 
echo $deckstr;
?>
' />
<input type='hidden' name='dealerstr' value = '<?php 
echo $dealerstr;
?>
' />
<?php 
foreach ($hand as $index => $card) {
    echo $card['face'] . ' of ' . $card['suit'] . "<br />";
}
?>
<p>You have : <?php 
echo evaluateHand($hand);
?>
</p>
<p>Dealer is showing the <?php 
echo $dealer[0]['face'];
?>
 of <?php 
echo $dealer[0]['suit'];
?>
</p> 
<input type='submit' name='submit' value='hit me' />
<input type='submit' name='submit' value='stay' />
</form>
<a href='3d10-simple-blackjack-dealer.php'>Try Again</a>