game/bandit.php

160 lines
4.5 KiB
PHP
Raw Permalink Normal View History

2022-06-06 21:30:34 +00:00
<?php
const GAME = true;
2022-06-06 21:30:34 +00:00
include_once('_incl_data/__config.php');
include_once('_incl_data/class/__db_connect.php');
$u = User::start();
2022-06-06 21:30:34 +00:00
2023-01-10 16:29:32 +00:00
if ($u->room['name'] != 'Однорукий бандит') {
die();
}
2023-01-10 16:29:32 +00:00
//Раздаем выйгрыши
function get2str($key = '', $val = '')
2022-06-06 21:30:34 +00:00
{
$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) {
2023-01-10 16:29:32 +00:00
//Играем!
$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) {
2023-01-10 16:29:32 +00:00
//Играем!
$w1 = rand(0, 2);
$w2 = rand(0, 3);
$w3 = rand(0, 3);
//
$win = 0;
$n = 99;
2022-06-06 21:30:34 +00:00
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(
2023-01-10 16:29:32 +00:00
"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']
2023-01-10 16:29:32 +00:00
) . "</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']);
2022-06-06 21:30:34 +00:00
}
echo $r;