<?
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';



$set['title']='Гонка началась'; // заголовок страницы
include_once '../sys/inc/thead.php';
title();
aut();
include_once 'glava_gonki.php';

  include_once'navi.php';
if (isset($user))
{

echo "$verh";
if (isset($user) & $user['conditions']>=5)
{
if (isset($user) & $user['benzines']>=8)
{ 
if (isset($user) & $user['begin_racing_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)
{
$zona_racingg = ($user['zona_racingg'] = $get_speed);
mysql_query("UPDATE `user` SET `zona_racingg` = '" . $zona_racingg . "' WHERE `id` = '$user[id]' LIMIT 1");

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

$power_winner_c = ($user['kope_je'] + $get_power);
mysql_query("UPDATE `user` SET `kope_je` = '" . $power_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$fuel_winner_c = ($user['benzines'] - 7);
mysql_query("UPDATE `user` SET `benzines` = '" . $fuel_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$zaezd_winner_c = ($user['racing'] + 1);
mysql_query("UPDATE `user` SET `racing` = '" . $zaezd_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$zaezd_m_winner_c = ($user['racing_one'] + 1);
mysql_query("UPDATE `user` SET `racing_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 class='index6'>
	<table class='wdt msg-table'>
  <tbody>
    <tr>
      <td align='left' style='vertical-align: top; width: 10%'>
        <img src='images/face.png'>
      </td>
      <td align='left' style='vertical-align: top'>
			Ты проиграл эту гонку:
                 


			</td>
    </tr>
  </tbody>
  
</table></div>";
echo "<div class='index'>:-( Ты проиграл гонку: играй еще может раз может повезет </div>";
echo "<div class='index'><img src=\"images/ben.png\" alt=\"\" /> - 7  &nbsp; &nbsp; &nbsp;<img src=\"images/power.gif\" alt=\"\" /> -$get_power% &nbsp; &nbsp; &nbsp; <img src='images/power-ico.png'> ".$speed." км/ч  &nbsp; &nbsp; &nbsp;  <img src='images/money.png'>+3  </div>";
echo "<div class='index'><a href=\"gonki.php?begin_racing=over\">Слудующяя гонка</a> >>> </div>";
include_once '../sys/inc/tfoot.php';
}

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

if ($protivnik < $avto_user)
{
$power_winner_c = ($user['kope_je'] + $get_power);
mysql_query("UPDATE `user` SET `kope_je` = '" . $power_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$begin_racing_over_rezult = ($user['begin_racing_over_rezult'] = 1);
mysql_query("UPDATE `user` SET `begin_racing_over_rezult` = '" . $begin_racing_over_rezult . "' WHERE `id` = '$user[id]' LIMIT 1");
$begin_racing_over = ($user['begin_racing_over'] = 1);
mysql_query("UPDATE `user` SET `begin_racing_over` = '" . $begin_racing_over . "' WHERE `id` = '$user[id]' LIMIT 1");
$zona_racingg = ($user['zona_racingg'] = $get_speed);
mysql_query("UPDATE `user` SET `zona_racingg` = '" . $zona_racingg . "' WHERE `id` = '$user[id]' LIMIT 1");


$baks_winner_c = ($user['money_mone'] + $itogo_baks);
mysql_query("UPDATE `user` SET `money_mone` = '" . $baks_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$fuel_winner_c = ($user['benzines'] - 7);
mysql_query("UPDATE `user` SET `benzines` = '" . $fuel_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$zaezd_winner_c = ($user['racing'] + 1);
mysql_query("UPDATE `user` SET `racing` = '" . $zaezd_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$zaezd_m_winner_c = ($user['racing_one'] + 1);
mysql_query("UPDATE `user` SET `racing_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 class='index6'>
	<table class='wdt msg-table'>
  <tbody>
    <tr>
      <td align='left' style='vertical-align: top; width: 10%'>
        <img src='images/face-girl5.png'>
      </td>
      <td align='left' style='vertical-align: top'>
			Ты выйграл гонку получи свой приз! если хочешь отдохнуть иди в <a href='bar.php'>Бар</a>:
			</td>
    </tr>
  </tbody>
  
</table></div>";
echo "<div class='index'>";
echo "<img src=\"images/money.png\" alt=\"\" /> + $itogo_baks  &nbsp; &nbsp; &nbsp;<img src=\"images/ben.png\" alt=\"\" /> - 10  &nbsp; &nbsp; &nbsp; <img src=\"images/power.gif\" alt=\"\" /> -$get_power%</div>";
echo "<div class='index'><a href=\"gonki.php?begin_racing=over\">Следующая папка</a> >>></div>";
echo "</div>";
include_once '../sys/inc/tfoot.php';
}
//////////////////////////////////////////////Победа
if ($protivnik == $avto_user) {
$power_winner_c = ($user['kope_je'] + $get_power);
mysql_query("UPDATE `user` SET `kope_je` = '" . $power_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$begin_racing_over_rezult = ($user['begin_racing_over_rezult'] = 1);
mysql_query("UPDATE `user` SET `begin_racing_over_rezult` = '" . $begin_racing_over_rezult . "' WHERE `id` = '$user[id]' LIMIT 1");
$begin_racing_over = ($user['begin_racing_over'] = 1);
mysql_query("UPDATE `user` SET `begin_racing_over` = '" . $begin_racing_over . "' WHERE `id` = '$user[id]' LIMIT 1");
$zona_racingg = ($user['zona_racingg'] = $get_speed);
mysql_query("UPDATE `user` SET `zona_racingg` = '" . $zona_racingg . "' WHERE `id` = '$user[id]' LIMIT 1");

$baks_winner_c = ($user['money_mone'] + $itogo_baks);
mysql_query("UPDATE `user` SET `money_mone` = '" . $baks_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$fuel_winner_c = ($user['benzines'] - 7);
mysql_query("UPDATE `user` SET `benzines` = '" . $fuel_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$zaezd_winner_c = ($user['racing'] + 1);
mysql_query("UPDATE `user` SET `racing` = '" . $zaezd_winner_c . "' WHERE `id` = '$user[id]' LIMIT 1");
$zaezd_m_winner_c = ($user['racing_one'] + 1);
mysql_query("UPDATE `user` SET `racing_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 class='index6'>
	<table class='wdt msg-table'>
  <tbody>
    <tr>
      <td align='left' style='vertical-align: top; width: 10%'>
        <img src='images/face-girl5.png'>
      </td>
      <td align='left' style='vertical-align: top'>
			Ты выйграл гонку получи свой приз! если хочешь отдохнуть иди в <a href='bar.php'>Бар</a>:
			</td>
    </tr>
  </tbody>
  
</table></div>";
echo "<div class='index'>";
echo "<img src=\"images/money.png\" alt=\"\" /> + $itogo_baks  &nbsp; &nbsp; &nbsp;<img src=\"images/ben.png\" alt=\"\" /> - 10  &nbsp; &nbsp; &nbsp; <img src=\"images/power.gif\" alt=\"\" /> -$get_power%</div>";
echo "<div class='index'><a href=\"gonki.php?begin_racing=over\">Следующая папка</a> >>></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['begin_racing_over']==1)
{
if (isset($user) & $user['begin_racing_over_rezult']==1)
{
echo "<div class='index6'>
	<table class='wdt msg-table'>
  <tbody>
    <tr>
      <td align='left' style='vertical-align: top; width: 10%'>
        <img src='images/face-girl5.png'>
      </td>
      <td align='left' style='vertical-align: top'>
			Ты выйграл гонку получи свой приз! если хочешь отдохнуть иди в <a href='bar.php'>Бар</a>:
			</td>
    </tr>
  </tbody>
  
</table></div>";
echo "<div class='index'>";
echo "<img src=\"images/money.png\" alt=\"\" /> + $itogo_baks  &nbsp; &nbsp; &nbsp;<img src=\"images/ben.png\" alt=\"\" /> - 10  &nbsp; &nbsp; &nbsp; <img src=\"images/power.gif\" alt=\"\" /> -$get_power%</div>";

echo "</div>";
}
if (isset($user) & $user['begin_racing_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 "<a href=\"gonki.php?begin_racing=over\">Ехать дальше</a>";
echo "<div class=\"hr\"></div>";
}else{
echo "<div class='index'>У тебя закончился бензин иди в город и заправляйся потом ты сможешь продолжить гонку</div>";
echo "<div class=\"hr\"></div>";
}
}else{
echo "<div style=\"float:left; padding-right: 4px;\"><img src=\"img/girl.gif\" alt=\"\" /></div> ";
echo " состояние твоего авто не пригодно для заезда, тебе пора в автосервис.</br>";
}
}else{
echo "Сделай авторизация на сайте</b>!.";

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