<?
require_once 'core/system.php';
echo only_reg();
require_once 'core/head.php';
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `user` WHERE `id`  = '".intval($_GET['id'])."'"));

?>






<?
$kount = mysql_result(mysql_query("SELECT COUNT(*)  FROM `user`"),0);
$health = rand(1,$user[level]);
if($_GET['attack'])
{
if($user['health'] < 20){
$_SESSION['light'] = "<span class='dred'>Для нападения нужно <img src='/images/icon/health.png' alt=''/> 20 Здоровья</span><br/>Здоровье восстанавливается со временем или за фиксы<br><div class='separ'></div><a class='btn' href='/moduls/ckoldun.php?act=ok'><span class='end'><span class='label'>Восстановить <img src='/images/icon/health.png' alt=''/> 100% здоровья</span></span></a><br><span class='grey'>Цена: <img src='/images/icon/gold.png' alt=''/> 10 фикс</span>";
header('Location: ?');
exit();
}
if($user['mana'] < 50)
{
$_SESSION['light'] = "<span class='dred'>Для нападения нужно <img src='/images/icon/mana.png' alt=''/> 50 Энергии</span><br/>Энергия восстанавливается со временем или за фиксы<br><div class='separ'></div><a class='btn' href='/moduls/ckoldun.php?act=ok'><span class='end'><span class='label'>Восстановить <img src='/images/icon/mana.png' alt=''/> 100% Энергии</span></span></a><br><span class='grey'>Цена: <img src='/images/icon/gold.png' alt=''/> 10 фикс</span>";
header('Location: ?');
exit();
}else{
$ank = mysql_fetch_array(mysql_query("select * from `user` where (`id` = '".abs(intval($_GET['attack']))."')"));
$ank_param = rand($ank[param],$ank[param]*1,5);
if($ank_param > $user[param]){
mysql_query("update `user` set `health` = '".($user['health']-$health)."',`exp` = '".($user['exp']+1)."',`silver`='".($user['silver']+10)."',`mana`='".($user['mana']-50)."' where (`id` = '".$user['id']."')");
header('Location: ?');
$_SESSION['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>";
exit();
}else{
$silver = rand(1,100);
$exp = rand($ank[level],$ank[level]*2);
mysql_query("update `user` set `health` = '".($user['health']-$health)."',`exp` = '".($user['exp']+$exp)."',`silver`='".($user['silver']+$silver)."',`mana`='".($user['mana']-50)."' where (`id` = '".$user['id']."')");
header('Location: ?');
$_SESSION['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='?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>";
exit();
}
}
}
echo "<div class='player center blue'>Побеждай врагов и становись сильнее!</div>

<div class='mini-line'></div>";

echo "<div class='player'>

<h2>Доступный противник</h2>

</div>";

if($kount < 2)echo "<div class='dot-line'></div><div class='player grey'>Нет противников!</div>";

$opponents = mysql_query("SELECT * FROM `user` WHERE `id` != '".$user['id']."' AND `level` <= '".$user['level']."' ORDER BY RAND() DESC LIMIT 1");
while($opponent = mysql_fetch_array($opponents))
{

echo "<div class='block_zero'><div class='float-left'>

<a href='/arena.php?attack=$opponent[id]'><img src='/style/avatar/".($opponent['pol'] == 0 ? "zj" : "m")."/$opponent[avatar].png' width='120' height='160' style='margin-right:10px;float:left;' alt=''/></a></div>

<img src='/images/icon/user.png' alt=''/> $opponent[nick]
<br><br>

<img src='/images/icon/str.png' alt='str'/> Сила: $opponent[sila]
<br>

<img src='/images/icon/vit.png' alt='vit'/> Здоровье: $opponent[max_health]
<br>

<img src='/images/icon/agi.png' alt='agi'/> Ловкость: $opponent[lovk]
<br>

<img src='/images/icon/def.png' alt='def'/> Защита: $opponent[zashit]
<br><br>

<a class='btn' href='/arena.php?attack=$opponent[id]'><span class='end'><span class='label'>Атакoвать</span></span></a>

<br>

<div style='clear:both;'></div>
</div>";
}
echo "<div class='dot-line'></div>

<div class='player center'>
<a class='btn' href='/arena.php'><span class='end'><span class='label'>Другие противники</span></span></a>
</div>";
echo "<div class='mini-line'></div>
<div class='player'>Ваши параметры:
<br>
<img src='/images/icon/str.png' alt='str'/> $user[sila] <img src='/images/icon/vit.png' alt='vit'/> $user[max_health] <img src='/images/icon/agi.png' alt='agi'/> $user[lovk] <img src='/images/icon/def.png' alt='def'/> $user[zashit]
<br>
</div>
<div class='mini-line'></div>
<ul class='hint'>
<li>Чем больше уровень противника, тем больше опыта получишь за победу!</li>
</ul>";
require_once 'core/foot.php';
?>