本文整理汇总了PHP中Bank::getHandValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Bank::getHandValue方法的具体用法?PHP Bank::getHandValue怎么用?PHP Bank::getHandValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bank
的用法示例。
在下文中一共展示了Bank::getHandValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
<?php
require_once 'game.php';
require_once 'joueurs.';
require_once 'card.php';
require_once 'deck.php';
class Bank extends Player
{
public function __construct()
{
parent::__construct("Banque");
}
}
//SCENARIO 1
$deck = new Deck();
$deck->shuffle();
$bank = new Bank();
$bank->take($deck->deal(2));
//tire 2 cartes du deck, la banque les prends
while ($bank->getHandValue() < 17) {
$bank->take($deck->deal(1));
}
if ($bank->getHandValue() > 21) {
echo "La banque perd";
} else {
echo "La banque a " . $bank->getHandValue();
}
示例2: getHandValue
}
}
public function getHandValue()
{
$panier = 0;
foreach ($this->hand as $card) {
$panier += $card->getValue();
}
return $panier;
}
}
class Bank extends Player
{
public function __construct()
{
parent::__construct("Banque");
}
}
//SCENARIO 1
$deck = new Deck();
$deck->shuffle();
$bank = new Bank();
$bank->take($deck->deal(2));
while ($bank->getHandValue() < 16) {
$bank->take($deck->deal(1));
}
if ($bank->getHandValue() > 21) {
echo "La banque perd " . $bank->getHandValue();
} else {
echo "La banque a " . $bank->getHandValue();
}
示例3: Deck
<?php
session_start();
require_once "classes/indexClasses.php";
require_once "classes/cardClasses.php";
$deck = new Deck();
$deck->shuffle();
$player = new Bank();
$player->take($deck->deal(2));
//Le joueur se voit distribué 2 cartes
echo "Tu as tiré 2 cartes et tu as " . $player->getHandValue();
if (isset($_POST['choice'])) {
while ($player->getHandValue() < 17) {
$player->take($deck->deal(1));
}
if ($player->getHandValue() > 21) {
echo "<br>Tu as perdu avec " . $player->getHandValue();
session_unset();
} else {
echo "<br>Tu as gagné avec " . $player->getHandValue();
session_unset();
}
}
if (isset($_POST['pass'])) {
$deck = new Deck();
$deck->shuffle();
}
if (isset($_POST['reset'])) {
session_unset();
session_destroy();
//header("Location:/");