Esempio n. 1
0
} elseif ($_GET['action'] == "new" and $_SESSION['game'] != "running") {
    $_SESSION['credit'] -= $_SESSION['bet'];
    $_SESSION['cards'] = NULL;
    $_SESSION['hand'] = NULL;
    $_SESSION['bank'] = NULL;
    $_SESSION['game'] = 'running';
}
if ($_SESSION['game'] == "end") {
    $_SESSION['cards'] = NULL;
    $_SESSION['hand'] = NULL;
    $_SESSION['bank'] = NULL;
    $_SESSION['game'] = 'running';
}
// shuffle cards and add them to the session
if (!$_SESSION['cards']) {
    $_SESSION['cards'] = shufflecards32();
    $_SESSION['hand'][1] = $_SESSION['cards'][1];
    $_SESSION['bank'][1] = $_SESSION['cards'][2];
    $_SESSION['card'] = 2;
}
if ($_GET['action'] == "hit" and $_SESSION['game'] == 'running') {
    $i = 0;
    do {
        $i++;
    } while ($_SESSION['hand'][$i]);
    $_SESSION['card']++;
    $_SESSION['hand'][$i] = $_SESSION['cards'][$_SESSION['card']];
    if (score() >= 22) {
        $_SESSION['game'] = '<font color="red">busted</font>';
        $i = 0;
        do {
Esempio n. 2
0
            }
            break;
        default:
            break;
    }
    if ($row['payout_offender'] and $row['payout_defender']) {
        mysql_query("DELETE FROM `cards` WHERE `gid` = '" . $row['gid'] . "' LIMIT 1;");
    }
}
$game = mysql_fetch_array(mysql_query("SELECT * FROM `cards` WHERE `offender` = '" . $_SESSION['user']['omni'] . "' and `status` = '0' LIMIT 1;"));
if (!$game) {
    $game = mysql_fetch_array(mysql_query("SELECT * FROM `cards` WHERE `defender` = '" . $_SESSION['user']['omni'] . "' and `status` = '2' LIMIT 1;"));
}
// neues game starten
if ($_POST['ubl'] and $_POST['bet'] < $ressis['gold'] and $_POST['bet'] > 0 and !$game) {
    $stack = shufflecards32();
    $card = rand(1, 32);
    $hand[0] = $stack[$card];
    unset($stack[$card]);
    sort($stack);
    mysql_query("INSERT INTO `cards` ( `gid` , `offender` , `defender` , `timestamp` , `bet` , `status` , `stack` , `hand_offender` , `hand_defender` ) VALUES ('', '" . $_SESSION['user']['omni'] . "', '" . intval($_POST['ubl']) . "', '" . time() . "', '" . intval($_POST['bet']) . "', '0', '" . implode(':', $stack) . "', '" . implode(':', $hand) . "', '');");
    mysql_query("UPDATE `ressis` SET gold=gold-" . intval($_POST['bet']) . " WHERE `omni` = " . $_SESSION['user']['omni'] . " LIMIT 1;");
    $game = mysql_fetch_array(mysql_query("SELECT * FROM `cards` WHERE `offender` = '" . $_SESSION['user']['omni'] . "' and `status` = '0' LIMIT 1;"));
}
// herausforderung annehmen
if ($_GET['gid'] and $_GET['accept'] == 1 and !$game) {
    $game = mysql_fetch_array(mysql_query("SELECT * FROM `cards` WHERE `defender` = '" . $_SESSION['user']['omni'] . "' and `status` = '1' and `gid` = '" . intval($_GET['gid']) . "' LIMIT 1;"));
    if ($game and $ressis['gold'] >= $game['bet']) {
        mysql_query("UPDATE `ressis` SET gold=gold-" . intval($game['bet']) . " WHERE `omni` = " . $_SESSION['user']['omni'] . " LIMIT 1;");
        mysql_query("UPDATE `cards` SET `status` = '2' WHERE `defender` = '" . $_SESSION['user']['omni'] . "' and `gid` = '" . intval($_GET['gid']) . "' LIMIT 1;");
        $game['status'] = 2;