160 lines
4.4 KiB
PHP
160 lines
4.4 KiB
PHP
<?php
|
|
|
|
const GAME = true;
|
|
include_once('_incl_data/__config.php');
|
|
include_once('_incl_data/class/__db_connect.php');
|
|
$u = User::start();
|
|
|
|
if ($u->room['name'] != 'Îäíîðóêèé áàíäèò') {
|
|
die();
|
|
}
|
|
|
|
//Ðàçäàåì âûéãðûøè
|
|
|
|
|
|
function get2str($key = '', $val = '')
|
|
{
|
|
$get = $_GET;
|
|
if (is_array($key)) {
|
|
if (count($key) > 0) {
|
|
foreach ($key as $k => $v) {
|
|
$get[$k] = $v;
|
|
}
|
|
}
|
|
} else {
|
|
$get[$key] = $val;
|
|
}
|
|
if (count($get) > 0) {
|
|
foreach ($get as $k => $v) {
|
|
if (empty($v)) {
|
|
unset($get[$k]);
|
|
}
|
|
}
|
|
}
|
|
if (count($get) > 0) {
|
|
foreach ($get as $k => $v) {
|
|
$get[$k] = $k . '=' . urlencode($v);
|
|
}
|
|
return '?' . implode('&', $get);
|
|
}
|
|
}
|
|
|
|
$r = '';
|
|
|
|
if (isset($_GET['bet'])) {
|
|
$s = 1;
|
|
if ($_GET['bet'] == 2) {
|
|
$s = 2;
|
|
} elseif ($_GET['bet'] == 3) {
|
|
$s = 3;
|
|
}
|
|
if ($u->bank['money2'] >= $s) {
|
|
//Èãðàåì!
|
|
$w1 = rand(0, 4);
|
|
$w2 = rand(0, 4);
|
|
$w3 = rand(0, 4);
|
|
//
|
|
$win = 0;
|
|
$n = 99;
|
|
|
|
if ($w1 == 0 && $w2 == 0 && $w3 == 0) {
|
|
// 50 100 150
|
|
$win = 50;
|
|
$n = 0;
|
|
} elseif ($w1 == 1 && $w2 == 1 && $w3 == 1) {
|
|
// 20 40 60
|
|
$win = 20;
|
|
$n = 1;
|
|
} elseif ($w1 == 2 && $w2 == 2 && $w3 == 2) {
|
|
// 10 20 30
|
|
$win = 10;
|
|
$n = 2;
|
|
} elseif ($w1 == 3 && $w2 == 3 && $w3 == 3) {
|
|
// 4 8 12
|
|
$win = 4;
|
|
$n = 3;
|
|
} elseif ($w1 == 4 && $w2 == 4 && $w3 == 4) {
|
|
// 2 4 6
|
|
$win = 2;
|
|
$n = 4;
|
|
} elseif ($w1 == 4 && $w2 == 4) {
|
|
// 1 2 3
|
|
$win = 1;
|
|
$n = 5;
|
|
} elseif ($w1 == 4 && $w3 == 4 || $w2 == 4 && $w3 == 4) {
|
|
// 1 2 3
|
|
$win = 1;
|
|
$n = 5;
|
|
}
|
|
|
|
if (($n == 5 || $n == 4 || $n == 3) && rand(0, 100) >= 50) {
|
|
//Èãðàåì!
|
|
$w1 = rand(0, 2);
|
|
$w2 = rand(0, 3);
|
|
$w3 = rand(0, 3);
|
|
//
|
|
$win = 0;
|
|
$n = 99;
|
|
|
|
if ($w1 == 0 && $w2 == 0 && $w3 == 0) {
|
|
// 50 100 150
|
|
$win = 50;
|
|
$n = 0;
|
|
} elseif ($w1 == 1 && $w2 == 1 && $w3 == 1) {
|
|
// 20 40 60
|
|
$win = 20;
|
|
$n = 1;
|
|
} elseif ($w1 == 2 && $w2 == 2 && $w3 == 2) {
|
|
// 10 20 30
|
|
$win = 10;
|
|
$n = 2;
|
|
} elseif ($w1 == 3 && $w2 == 3 && $w3 == 3) {
|
|
// 4 8 12
|
|
$win = 4;
|
|
$n = 3;
|
|
} elseif ($w1 == 4 && $w2 == 4 && $w3 == 4) {
|
|
// 2 4 6
|
|
$win = 2;
|
|
$n = 4;
|
|
} elseif ($w1 == 4 && $w2 == 4) {
|
|
// 1 2 3
|
|
$win = 1;
|
|
$n = 5;
|
|
} elseif ($w1 == 4 && $w3 == 4 || $w2 == 4 && $w3 == 4) {
|
|
// 1 2 3
|
|
$win = 1;
|
|
$n = 5;
|
|
}
|
|
}
|
|
//
|
|
$u->bank['money2'] -= $s;
|
|
$u->bank['money2'] += $s * $win;
|
|
mysql_query(
|
|
'UPDATE `bank` SET `money2` = "' . $u->bank['money2'] . '" WHERE `id` = "' . $u->bank['id'] . '" LIMIT 1'
|
|
);
|
|
//
|
|
mysql_query(
|
|
'INSERT INTO `bandit` (`uid`,`time`,`room`,`s`,`wm`,`w`) VALUES (
|
|
"' . $u->info['id'] . '","' . time(
|
|
) . '","' . $u->info['room'] . '","' . $s . '","' . ($s * $win) . '","' . $w1 . $w2 . $w3 . '"
|
|
) '
|
|
);
|
|
$gid = mysql_insert_id();
|
|
//
|
|
if ($win > 0) {
|
|
mysql_query(
|
|
"INSERT INTO `chat` (`new`,`city`,`room`,`login`,`to`,`text`,`time`,`type`,`toChat`) VALUES ('1','" . $u->info['city'] . "','390','','','<small>[<b><font color=0066ff>Êðóïüå</font></b>] Èãðîê <b>" . mysql_real_escape_string(
|
|
$u->info['login']
|
|
) . "</b> âûèãðàë <b>" . ($s * $win) . ".00</b> åêð., ñòàâêà: " . $s . ".00 åêð., èãðà ¹" . $gid . "</small>','" . time(
|
|
) . "','6','0')"
|
|
);
|
|
}
|
|
//
|
|
$r .= 'cash=' . floor($u->bank['money2']);
|
|
$r .= '&w1=' . $w1 . '&w2=' . $w2 . '&w3=' . $w3 . '&n=' . $n . '&win=' . ($s * $win);
|
|
}
|
|
} else {
|
|
$r .= 'cash=' . floor($u->bank['money2']);
|
|
}
|
|
echo $r;
|