Файл: arena.php
Строк: 296
<?
include_once('./inc/head.php');
$profil = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$id_us."'"));
echo '<div class="title"><b>'.$uinf['login'].' <a href="./privat.php?privat=vhod"><img src="http://144.76.127.94/view/image/icons/post.png" height="15" width="15" align="top" alt="ic">'.$new_msg.'</a> | '.$profil['hp'].'<img src="http://warbk.com/graph/ico/hp.png" width="16" height="16" > | <img src="http://warbk.com/img/lvl.png" width="16" height="16" > '.$profil['lvl'].'</b> | <b>Золото: </b> '.$profil['zoloto'].' <img src="./theme/gold.png" height="16" width="16" align="top" alt="ic"> | <b>Рубли: </b> '.$profil['rub'].' <img src="http://144.76.127.94/view/image/icons/buy_gold.png" height="16" width="16" align="top" alt="ic"></div>';
<div class='mini-line'></div>";
if($_GET['attack'])
{
if($user['mana'] < 50)
{
echo "<div class='block_light center'>
<span class='dred'>Для нападения нужно <img src='/images/icon/mana.png' alt=''/> 50 маны</span><br/>Мана восстанавливается со временем или за золото
<br>
<div class='separ'></div>
<a class='btn' href=''><span class='end'><span class='label'>Восстановить <img src='/images/icon/mana.png' alt=''/> 1000 маны</span></span></a>
<br>
<span class='grey'>Цена: <img src='/images/icon/gold.png' alt=''/>150 золота</span>
</div>";
}
else
{
$_GET['attack'] = trim((int) $_GET['attack']);
$opponent = mysql_fetch_array(mysql_query("select * from `user` where (`id` = '".$_GET['attack']."')"));
if($opponent == 0)
{
header("location: /arena.php");
exit;
}
$opponent_params = $opponent['str']+$opponent['vit']+$opponent['agi']+$opponent['def'];
$opponent_domination = 0;
$user_params = $user['str']+$user['vit']+$user['agi']+$user['def'];
$user_domination = 0;
if($opponent_params > $user_params)
{
$opponent_domination = ($opponent_domination+1);
}
elseif($opponent_params == $user_params)
{
$opponent_domination = ($opponent_domination+1);
$user_domination = ($user_domination+1);
}
else
{
$user_domination = ($user_domination+1);
}
if($opponent['skill'] > $user['skill'])
{
$opponent_domination = ($opponent_domination+1);
}
elseif($opponent['skill'] == $user['skill'])
{
$opponent_domination = ($opponent_domination+1);
$user_domination = ($user_domination+1);
}
else
{
$user_domination = ($user_domination+1);
}
$opponent_dmg = rand($opponent['dmg'],$opponent['max_dmg']);
$opponent_dmg_absorpion = rand($opponent['dmg_absorpion'],$opponent['max_dmg_absorpion']);
$user_dmg = rand($user['dmg'],$user['max_dmg']);
$user_dmg_absorpion = rand($user['dmg_absorpion'],$user['max_dmg_absorpion']);
if($opponent_dmg > $user_dmg_absorpion)
{
$opponent_domination = ($opponent_domination+1);
}
elseif($opponen_dmg == $user_dmg_absorpion)
{
$opponent_domination = ($opponent_domination+1);
$user_domination = ($user_domination+1);
}
else
{
$user_domination = ($user_domination+1);
}
if($opponent_domination > $user_domination)
{
echo "<div class='center'>
<div class='block_light'>
<h2 class='dred' style='font-weight:bold;'><img src='/images/icon/2hit.png' alt=''/> Поражение <img src='/images/icon/2hit.png' alt=''/></h2>
<div class='separ'></div>
<a class='btn' href='/arena.php?attack=$_GET[attack]'><span class='end'><span class='label'>Новый бой</span></span></a>
<div class='separ'></div>
<img src='/images/icon/silver.png' alt=''/> 10 серебра <img src='/images/icon/exp.png' alt='exp'/> 1 опыта
<br>
</div>
</div>";
mysql_query("update `user` set `max_health` = '".($opponent_dmg > $user['health'] ? 0 : $opponent_dmg)."',`exp` = '".($user['exp']+1)."',`silver`='".($user['silver']+10)."',`mana`='".($user['mana']-50)."' where (`id` = '".$user['id']."')");
}
else
{
$silver = rand(1,100);
$exp = rand(1,($user['level']*10));
echo "<div class='center'>
<div class='block_light'>
<h2 class='dgreen' style='font-weight:bold;'><img src='/images/icon/2hit.png' alt=''/> Победа <img src='/images/icon/2hit.png' alt=''/></h2>
<div class='separ'></div>
<a class='btn' href='/arena.php?attack=$_GET[attack]'><span class='end'><span class='label'>Новый бой</span></span></a>
<div class='separ'></div>
<img src='/images/icon/silver.png' alt=''/> ".$silver." серебра <img src='/images/icon/exp.png' alt='exp'/> ".$exp." опыта
<br>
</div>
</div>";
mysql_query("update `user` set `health` = '".($opponent_dmg > $user['health'] ? 0 : $opponent_dmg)."',`exp` = '".($user['exp']+$exp)."',`silver`='".($user['silver']+$silver)."',`mana`='".($user['mana']-50)."' where (`id` = '".$user['id']."')");
}
}
}
else
{
echo "<div class='block_zero center blue'>
Побеждай врагов и становись сильнее!
<br>
</div>
<div class='mini-line'></div>";
}
echo "<div class='block_zero'>
<h2 style='font-weight:bold'>Доступный противник</h2>
</div>
<div class='block_zero'>";
$opponents = mysql_query("select * from `user` where (`id` != '".$user['id']."' and `level` <= '".$user['level']."') ORDER BY RAND() limit 1");
while($opponent = mysql_fetch_array($opponents))
{
echo "<div class='float-left'>
<a href='/arena.php?attack=$opponent[id]'><img src='' width='120' height='160' style='margin-right:10px;margin-top:3px;' alt=''/></a>
</div>
<img src='/images/icon/race/$opponent[race].png' alt=''/> $opponent[login]
<br><br>
<img src='/images/icon/str.png' alt='str'/> Сила: $opponent[str]
<br>
<img src='/images/icon/vit.png' alt='vit'/> Здоровье: $opponent[vit]
<br>
<img src='/images/icon/agi.png' alt='agi'/> Ловкость: $opponent[agi]
<br>
<img src='/images/icon/def.png' alt='def'/> Защита: $opponent[def]
<br><br>
<a class='btn' href='/arena.php?attack=$opponent[id]'><span class='end'><span class='label'>Атакoвать</span></span></a>
<div style='clear:both;'></div>
</div>";
}
echo "<div class='dot-line'></div>
<div class='block_zero center'>
<a class='btn' href='/arena.php'><span class='end'><span class='label'>Другие противники</span></span></a>
</div>
<div class='mini-line'></div>
<div class='block_zero'>Ваши параметры:
<br>
<img src='/images/icon/str.png' alt='str'/> $user[str] <img src='/images/icon/vit.png' alt='vit'/> $user[vit] <img src='/images/icon/agi.png' alt='agi'/> $user[agi] <img src='/images/icon/def.png' alt='def'/> $user[def]
<br>
</div>
<div class='mini-line'></div>
<ul class='hint'>
<li>Чем сильнее противник, тем больше опыта и серебра получишь за победу!</li>
</ul>";
include "sys/f.php";
?>