<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';
include_once 'config.php';
$set['title']='Speed Of Race - Гонка'; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
aut();
echo "<div style=\" background-color: #0b0f2e; color: #ffffff;\">";
if (isset($user))
{

echo "$verh";
if (isset($user) & $user['cilynders_power']>=5)
{
if (isset($user) & $user['cilynders_fuel']>=8)
{ 
if (isset($user) & $user['game_over']!=1)
{ 
$act = isset($_GET['act']) ? $_GET['act'] : '';
$rand = mt_rand(100, 999);
switch ($act) {
case "go":


$get_baks = mt_rand(3, 7);
$get_baks2 = mt_rand(1, 9);
$itogo_baks = "$get_baks$get_baks2";

$get_ratingg = mt_rand(1, 3);
$get_ratingg2 = mt_rand(1, 9);
$itogo_ratingg = "$get_ratingg$get_ratingg2";

$get_rating = mt_rand(1, 4);
$get_rating2 = mt_rand(1, 9);
$itogo_rating = "$get_rating$get_rating2";
$get_speed = mt_rand(1, 15);
$get_power = mt_rand(1, 3);
$ta4ka_user = mt_rand(1, 6);
$ta4ka_bot = mt_rand(1, 6);
$protivnik = $ta4ka_user;
$avto_user = $ta4ka_bot;

//////////////////////////////////////////////Проигрыш

if ($protivnik > $avto_user)
{
$zaezd_rezult = ($user['zaezd_rezult'] = $get_speed);
mysql_query("UPDATE `user` SET `zaezd_rezult` = '" . $zaezd_rezult . "' WHERE `id` = '$user[id]' LIMIT 1");

$game_over_rezult = ($user['game_over_rezult'] = 2);
mysql_query("UPDATE `user` SET `game_over_rezult` = '" . $game_over_rezult . "' WHERE `id` = '$user[id]' LIMIT 1");
$game_over = ($user['game_over'] = 1);
mysql_query("UPDATE `user` SET `game_over` = '" . $game_over . "' WHERE `id` = '$user[id]' LIMIT 1");

$power_winner_c = ($user['winner_power'] + $get_power);
mysql_query("UPDATE `user` SET `winner_power` = '" . $power_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$fuel_winner_c = ($user['cilynders_fuel'] - 7);
mysql_query("UPDATE `user` SET `cilynders_fuel` = '" . $fuel_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$zaezd_winner_c = ($user['cilynders_zaezd'] + 1);
mysql_query("UPDATE `user` SET `cilynders_zaezd` = '" . $zaezd_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$zaezd_m_winner_c = ($user['cilynders_zaezd_one'] + 1);
mysql_query("UPDATE `user` SET `cilynders_zaezd_one` = '" . $zaezd_m_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$rating_winner_c = ($user['winner_rating'] - $itogo_ratingg);
mysql_query("UPDATE `user` SET `winner_rating` = '" . $rating_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");


echo "<div style=\"float:left; padding-right: 4px;\"><img src=\"img/girl.gif\" alt=\"\" /></div>
 - $user[nick], не повезло, ты проиграл. Возможно в следующий раз ты окажешься сильнее.</br>";
 echo "<div style=\"display:block; padding:4px; background:url(img/hr.png) repeat-x scroll 0 0 #504F6E;\"></div>";
echo "<center>
<img src=\"img/loser.gif\" alt=\"\" /></br>";
echo "Отстал:  $get_speed М.</br>";
echo "<img src=\"img/rating.gif\" alt=\"\" /> - $itogo_ratingg ";
echo "<img src=\"img/fuel.gif\" alt=\"\" /> - 7 </br><img src=\"img/power.gif\" alt=\"\" /> -$get_power%</center>";
echo "<div style=\"display:block; padding:4px; background:url(img/hr.png) repeat-x scroll 0 0 #504F6E;\"></div>";
echo "<a href=\"start.php?game=over\"><div style=\"background-image: url('img/menu.png');color:#ffffff;font-size:16px; padding-left: 4px; padding:1px;\"><img width=\"24\" height=\"24\" src=\"img/next.gif\"  alt=\"\" /> Далее</div></a>";
echo "<div class=\"hr\"></div>";
echo "</div>";
include_once '../sys/inc/tfoot.php';
}

//////////////////////////////////////////////Победа

if ($protivnik < $avto_user)
{
$power_winner_c = ($user['winner_power'] + $get_power);
mysql_query("UPDATE `user` SET `winner_power` = '" . $power_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$game_over_rezult = ($user['game_over_rezult'] = 1);
mysql_query("UPDATE `user` SET `game_over_rezult` = '" . $game_over_rezult . "' WHERE `id` = '$user[id]' LIMIT 1");
$game_over = ($user['game_over'] = 1);
mysql_query("UPDATE `user` SET `game_over` = '" . $game_over . "' WHERE `id` = '$user[id]' LIMIT 1");
$zaezd_rezult = ($user['zaezd_rezult'] = $get_speed);
mysql_query("UPDATE `user` SET `zaezd_rezult` = '" . $zaezd_rezult . "' WHERE `id` = '$user[id]' LIMIT 1");


$baks_winner_c = ($user['winner_baks'] + $itogo_baks);
mysql_query("UPDATE `user` SET `winner_baks` = '" . $baks_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$fuel_winner_c = ($user['cilynders_fuel'] - 7);
mysql_query("UPDATE `user` SET `cilynders_fuel` = '" . $fuel_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$zaezd_winner_c = ($user['cilynders_zaezd'] + 1);
mysql_query("UPDATE `user` SET `cilynders_zaezd` = '" . $zaezd_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$zaezd_m_winner_c = ($user['cilynders_zaezd_one'] + 1);
mysql_query("UPDATE `user` SET `cilynders_zaezd_one` = '" . $zaezd_m_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$rating_winner_c = ($user['winner_rating'] + $itogo_rating);
mysql_query("UPDATE `user` SET `winner_rating` = '" . $rating_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");

echo "<div style=\"float:left; padding-right: 4px;\"><img src=\"img/girl.gif\" alt=\"\" /></div>
 - $user[nick], ты выиграл! Забирай свою награду, теперь твой рейтинг стал еще выше.</br>";
 echo "<div style=\"display:block; padding:4px; background:url(img/hr.png) repeat-x scroll 0 0 #504F6E;\"></div>";
echo "<center>
<img src=\"img/winner.gif\" alt=\"\" /></br>";
echo "Отрыв:  $get_speed М.</br>";
echo "<img src=\"img/baks.gif\" alt=\"\" /> + $itogo_baks ";
echo "<img src=\"img/rating.gif\" alt=\"\" /> + $itogo_rating ";
echo "<img src=\"img/fuel.gif\" alt=\"\" /> - 7 <br /> <img src=\"img/power.gif\" alt=\"\" /> -$get_power%</center>";
echo "<div style=\"display:block; padding:4px; background:url(img/hr.png) repeat-x scroll 0 0 #504F6E;\"></div>";
echo "<a href=\"start.php?game=over\"><div style=\"background-image: url('img/menu.png');color:#ffffff;font-size:16px; padding-left: 4px; padding:1px;\"><img width=\"24\" height=\"24\" src=\"img/next.gif\"  alt=\"\" /> Далее</div></a>";
echo "<div class=\"hr\"></div>";
echo "</div>";
include_once '../sys/inc/tfoot.php';
}
//////////////////////////////////////////////Победа
if ($protivnik == $avto_user) {
$power_winner_c = ($user['winner_power'] + $get_power);
mysql_query("UPDATE `user` SET `winner_power` = '" . $power_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$game_over_rezult = ($user['game_over_rezult'] = 1);
mysql_query("UPDATE `user` SET `game_over_rezult` = '" . $game_over_rezult . "' WHERE `id` = '$user[id]' LIMIT 1");
$game_over = ($user['game_over'] = 1);
mysql_query("UPDATE `user` SET `game_over` = '" . $game_over . "' WHERE `id` = '$user[id]' LIMIT 1");
$zaezd_rezult = ($user['zaezd_rezult'] = $get_speed);
mysql_query("UPDATE `user` SET `zaezd_rezult` = '" . $zaezd_rezult . "' WHERE `id` = '$user[id]' LIMIT 1");

$baks_winner_c = ($user['winner_baks'] + $itogo_baks);
mysql_query("UPDATE `user` SET `winner_baks` = '" . $baks_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$fuel_winner_c = ($user['cilynders_fuel'] - 7);
mysql_query("UPDATE `user` SET `cilynders_fuel` = '" . $fuel_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$zaezd_winner_c = ($user['cilynders_zaezd'] + 1);
mysql_query("UPDATE `user` SET `cilynders_zaezd` = '" . $zaezd_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$zaezd_m_winner_c = ($user['cilynders_zaezd_one'] + 1);
mysql_query("UPDATE `user` SET `cilynders_zaezd_one` = '" . $zaezd_m_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$rating_winner_c = ($user['winner_rating'] + $itogo_rating);
mysql_query("UPDATE `user` SET `winner_rating` = '" . $rating_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");

echo "<div style=\"float:left; padding-right: 4px;\"><img src=\"img/girl.gif\" alt=\"\" /></div>
 - $user[nick], ты выиграл! Забирай свою награду, теперь твой рейтинг стал еще выше.</br>";
 echo "<div style=\"display:block; padding:4px; background:url(img/hr.png) repeat-x scroll 0 0 #504F6E;\"></div>";
echo "<center>
<img src=\"img/winner.gif\" alt=\"\" /></br>"; 
echo "Отрыв:  $get_speed М.</br>";
echo "<img src=\"img/baks.gif\" alt=\"\" /> + $itogo_baks ";
echo "<img src=\"img/rating.gif\" alt=\"\" /> + $itogo_rating ";
echo "<img src=\"img/fuel.gif\" alt=\"\" /> - 7</br><img src=\"img/power.gif\" alt=\"\" /> -$get_power%</center>";
echo "<div style=\"display:block; padding:4px; background:url(img/hr.png) repeat-x scroll 0 0 #504F6E;\"></div>";

echo "<a href=\"start.php?game=over\"><div style=\"background-image: url('img/menu.png');color:#ffffff;font-size:16px; padding-left: 4px; padding:1px;\"><img width=\"24\" height=\"24\" src=\"img/next.gif\"  alt=\"\" /> Далее</div></a>";
echo "<div class=\"hr\"></div>";
echo "</div>";
include_once '../sys/inc/tfoot.php';
}




echo '<br/><br/><b><a href="go.php?act=go&amp;rand=' . $rand .'">Играть</a></b><br/><br/>';

sleep(2);


break;

default:

echo '<b><a href="index.php?act=go&amp;rand=' . $rand .'">Играть</a></b><br/><br/>
<a href="index.php?act=faq&amp;">Помощь</a><br/>';
echo "Баллы: $user[balls]<br />\n";
echo "<a href=\"index.php\">&#187;Назад</a>\n";
break;
}
}
if (isset($user) & $user['game_over']==1)
{
if (isset($user) & $user['game_over_rezult']==1)
{
echo "<div style=\"float:left; padding-right: 4px;\"><img src=\"img/girl.gif\" alt=\"\" /></div>
 - $user[nick], ты выиграл! Забирай свою награду, теперь твой рейтинг стал еще выше.</br>";
echo "<center>
<img src=\"img/winner.gif\" alt=\"\" /></br>"; 
echo "Отрыв:  $user[zaezd_rezult] М.</br>";
echo "<img src=\"img/baks.gif\" alt=\"\" /> + $user[winner_baks] ";
echo "<img src=\"img/rating.gif\" alt=\"\" /> + $user[winner_rating] ";
echo "<img src=\"img/fuel.gif\" alt=\"\" /> - 7<br/><img src=\"img/power.gif\" alt=\"\" /> $user[winner_power]%</center>";
}
if (isset($user) & $user['game_over_rezult']==2)
{
echo "<div style=\"float:left; padding-right: 4px;\"><img src=\"img/girl.gif\" alt=\"\" /></div>
 - $user[nick], не повезло, ты проиграл. Возможно в следующий раз ты окажешься сильнее.</br>";
 echo "<div style=\"display:block; padding:4px; background:url(img/hr.png) repeat-x scroll 0 0 #504F6E;\"></div>";

echo "<center>
<img src=\"img/loser.gif\" alt=\"\" /></br>";
echo "Отстал:  $user[zaezd_rezult] М.</br>";
echo "<img src=\"img/rating.gif\" alt=\"\" /> $user[winner_rating] ";
echo "<img src=\"img/fuel.gif\" alt=\"\" /> - 7<br/><img src=\"img/power.gif\" alt=\"\" /> $user[winner_power]%</center>";
}
}
echo "<div style=\"display:block; padding:4px; background:url(img/hr.png) repeat-x scroll 0 0 #504F6E;\"></div>";

echo "<a href=\"start.php?game=over\"><div style=\"background-image: url('img/menu.png');color:#ffffff;font-size:16px; padding-left: 4px; padding:1px;\"><img width=\"24\" height=\"24\" src=\"img/next.gif\"  alt=\"\" /> Далее</div></a>";
echo "<div class=\"hr\"></div>";
}else{
echo "<div style=\"float:left; padding-right: 4px;\"><img src=\"img/girl.gif\" alt=\"\" /></div>
 - <b>$user[nick]</b>, ";
echo " у тебя мало бензина, поэтому ты не можешь учавствовать в заезде, езжай на заправку - Для участия в заезде, тебе необходимо иметь 8 литров в баке, как заправишься приезжай еще.</br>";
echo "<div style=\"display:block; padding:4px; background:url(img/hr.png) repeat-x scroll 0 0 #504F6E;\"></div>";

echo "<a href=\"avtozap.php\"><div style=\"background-image: url('img/menu.png');color:#ffffff;font-size:16px; padding-left: 4px; padding:1px;\"><img width=\"24\" height=\"24\" src=\"img/zapr.gif\"  alt=\"\" /> Автозаправка</div></a>";
echo "<div class=\"hr\"></div>";

echo "<a href=\"index.php\"><div style=\"background-image: url('img/menu.png');color:#ffffff;font-size:16px; padding-left: 4px; padding:1px;\"><img width=\"24\" height=\"24\" src=\"img/cityss.gif\"  alt=\"\" /> Город</div></a>";

echo "<div class=\"hr\"></div>";
echo "<a href=\"profil.php\"><div style=\"background-image: url('img/menu.png');color:#ffffff;font-size:16px; padding-left: 4px; padding:1px;\"><img width=\"24\" height=\"24\" src=\"img/profiles.gif\"  alt=\"\" /> Профиль</div></a>";


echo "<div class=\"hr\"></div>";
echo "<a href=\"garage.php\"><div style=\"background-image: url('img/menu.png');color:#ffffff;font-size:16px; padding-left: 4px; padding:1px;\"><img width=\"24\" height=\"24\" src=\"img/garages.gif\"  alt=\"\" /> В гараж</div></a>";

}
}else{
echo "<div style=\"float:left; padding-right: 4px;\"><img src=\"img/girl.gif\" alt=\"\" /></div>
 - <b>$user[nick]</b>, ";
echo " состояние твоего авто не пригодно для заезда, тебе пора в автосервис.</br>";
echo "<div style=\"display:block; padding:4px; background:url(img/hr.png) repeat-x scroll 0 0 #504F6E;\"></div>";

echo "<a href=\"avtoservis.php\"><div style=\"background-image: url('img/menu.png');color:#ffffff;font-size:16px; padding-left: 4px; padding:1px;\"><img width=\"24\" height=\"24\" src=\"img/servis.gif\"  alt=\"\" /> Автосервис</div></a>";
echo "<div class=\"hr\"></div>";

echo "<a href=\"index.php\"><div style=\"background-image: url('img/menu.png');color:#ffffff;font-size:16px; padding-left: 4px; padding:1px;\"><img width=\"24\" height=\"24\" src=\"img/cityss.gif\"  alt=\"\" /> Город</div></a>";

echo "<div class=\"hr\"></div>";
echo "<a href=\"profil.php\"><div style=\"background-image: url('img/menu.png');color:#ffffff;font-size:16px; padding-left: 4px; padding:1px;\"><img width=\"24\" height=\"24\" src=\"img/profiles.gif\"  alt=\"\" /> Профиль</div></a>";


echo "<div class=\"hr\"></div>";
echo "<a href=\"garage.php\"><div style=\"background-image: url('img/menu.png');color:#ffffff;font-size:16px; padding-left: 4px; padding:1px;\"><img width=\"24\" height=\"24\" src=\"img/garages.gif\"  alt=\"\" /> В гараж</div></a>";

}
}else{
echo "<div style=\"float:left; padding-right: 4px;\"><img src=\"img/girl.gif\" alt=\"\" /></div>
 - Приветствую тебя Гость,
добро пожаловать в захватывающию онлайн игру <b>Speed Of Race</b>.</br>В игре тебя ждет захватывающая гонка, в которой ты можешь заработать денег, 
и стать лидером среди участников гонки!</br>
 - Гость, я вижу 
 что ты еще не зарегистрироан, пройди <a href=\"/reg.php\">регистрацию</a> на этом сайте, и тогда тебе будет доступна игра <b>Speed Of Race</b>!.";

}
echo "</div>";
include_once '../sys/inc/tfoot.php';
?>