<?
require_once '../core/system.php';
echo only_reg();
$health = 50;
if (isset($_GET['id']) && mysql_result(mysql_query("SELECT COUNT(*) FROM `boss` WHERE `id` = '".intval($_GET['id'])."'"),0) == true){
$boss = mysql_fetch_assoc(mysql_query("SELECT * FROM `boss` WHERE `id`  = '".intval($_GET['id'])."'"));
}else{
$_SESSION['err'] = "Босс не найден";
header('Location: index.php');
exit();
}
if($user['level'] < $boss[lvl]){
$_SESSION['err'] = "Необходим $boss[lvl] уровень!";
header('Location: index.php');
exit();
}else{
if($user['health'] < 20){
$_SESSION['light'] = $warning_boss_low_health;
header("Location: boss.php?id=$boss[id]");
exit();
}
if($user['mana'] < 350){
$_SESSION['light'] = $warning_boss_low_mana;
header("Location: boss.php?id=$boss[id]");
exit();
}else{
$header = 'Босс '.$boss['name'];
$bos_param = $boss[sila] + $boss[health] + $boss[lovk] + $boss[zashit];
$boss_param = $bos_param;
require_once H.'core/head.php';
$pets_param1 = $user[silapets] + $user[vinoslpets] + $user[healthpets];
$user_param = $user[sila] + $user[max_health] + $user[lovk] + $user[zashit] + $pets_param1;
if($boss_param > $user_param){

mysql_query("update `user` set `health` = '".($user['health']-$health)."',`mana`='".($user['mana']-350)."' where (`id` = '".$user['id']."')");
header("Location: boss.php?id=$boss[id]");
$_SESSION['light'] = "<h2 class='dred' style='font-weight:bold;'><img src='/images/icon/2hit.png' alt=''/> Поражение <img src='/images/icon/2hit.png' alt=''/></h2>";
exit();
}else{
if($user[prava] == 3){
$boss[gold] = $boss[gold] * 2;
$boss[exp] = $boss[exp] * 2;
}
mysql_query("update `user` set `exp` = '".($user['exp']+$boss[exp])."',`gold` = '".($user['gold']+$boss[gold])."',`health` = '".($user['health']-$health)."',`mana`='".($user['mana']-350)."' where (`id` = '".$user['id']."')");
mysql_query("UPDATE `user` SET `boss_pobed` = '".($user['boss_pobed']+1)."' WHERE `id` = '$user[id]' LIMIT 1");
header("Location: boss.php?id=$boss[id]");
$_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><img src='/images/icon/gold.png' alt=''/> ".$boss[gold]." золота <img src='/images/icon/exp.png' alt='exp'/> ".$boss[exp]." опыта";
exit();
}
}
}
require_once H.'core/foot.php';
?>