迷你二十一点游戏

时间:2015-03-10 14:54:16

标签: php

我在PHP的迷你游戏中工作,但我有分发经销商卡的问题

我为经销商提供了2个变量

$bank[0] = ace +11 // its the total of cards with ace = 11
$bank[1] = ace +1 // total with ace = 1

$stay = false;
if ($bank[0] == $bank[1]) {
    if ($bank[0] >= 17) {
        $stay = true;
    }
} 
else {
    if ($bank[1] >= 17) {
        $stay = true;
    } 
    else {
        if ($bank[0] >= 17 && $bank[0] <= 21) {
            $stay = true;
        }
    }
}

使用此脚本的经销商示例我有5张牌“6 + ACE(1)+ 2 + 4 + 6”= 19 但我需要脚本停止3张牌,如“6 + ACE(11)+ 2”= 19 感谢

1 个答案:

答案 0 :(得分:0)

试试这个:

$stay = false;
//it doesn't matter if $bank[0] == $bank[1]
if ($bank[0] >= 17 && $bank[0] <=21) {
    $stay = true;
}
else {
    if ($bank[1] >= 17 && $bank[1] <=21) {
        $stay = true;
    }
    else{
        if ($bank[0] > 21 && $bank[1] > 21) {
            //The bank lost
        }
        else{
            //stay is already false, as declared above
        }
    }
}