<?php
require_once ('../system/func.php');
$title = 'Снеговик';
require_once ('../system/header.php');
auth(); // Закроем от гостей
# Находим снеговика в базе #
$batle = mysql_query("SELECT * FROM `boser` WHERE `id` = '1' ORDER BY `id` LIMIT 1");
$batle = mysql_fetch_array($batle);
$myLog = mysql_query("SELECT * FROM `boser_log` WHERE `id_boser` = '$batle[id]' AND `id_user` = '$myID' AND `tipe` = 'user' ORDER BY `id` DESC LIMIT 1");
$myLog = mysql_fetch_array($myLog);
if($batle['health'] > $batle['max_health'])$batle['health'] = $batle['max_health'];
if($batle['health'] < 0)$batle['health'] = 0;
# Ремонт #
if(isset($_GET['sdfghjkl']) and $user['side'] == $batle['side']){
if($batle['health'] == $batle['max_health']){
$_SESSION['msg'] = "Локация ещё в порядке";
header('Location: ?');
}
}
# Атака игрока #
if(isset($_GET['qwertyuihgf'])){
$_hp = ceil($user['max_health']*10/100);
if($user['energy'] < 10 or $user['health'] < $_hp){
$_SESSION['msg'] = "Для нападения необходимо минимум ".ico('icons','health.png')." 10% здоровья и ".ico('icons','energy.png')." 10 запаса сил!<br><a href='/rinok?koldun2&url=hell/boser.php' class='link' data-ajax>Восстановить ".ico('icons','gold.png')."</a>";
header('Location: ?');
exit();
}else{
$opponent = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `online` > '".(time()-7200)."' AND `fix_mesto` = '$title' AND `side` != '$user[side]' ORDER BY RAND() LIMIT 1"));
if($opponent){
if($opponent['health'] > num($opponent['max_health']*2))$opponent['health'] = num($opponent['max_health']*2);
mysql_query("update `users` set `energy` = '".($user['energy']-10)."' where (`id` = '".$user['id']."')");
$_def_opp = rand(round($opponent['def']/12), round($opponent['def']/7));
$_str = $_str - $_def_opp;
if($_str < 0)$_str = 0;
mysql_query("INSERT INTO `boser_log` SET `id_user` = '$myID', `id_user2` = '$opponent[id]', `tipe` = 'users', `uron` = '".$_str."', `id_boser` = '$batle[id]'");
mysql_query("update `users` set `health` = '".($opponent['health']-$_str)."' where (`id` = '".$opponent['id']."')");
}
header("Location: ?$random");
exit();
}
}
# Атака #
if(isset($_GET['attack']) and $user['side'] != $batle['side']){
if(isset($myLog) and $myLog['time'] > time()){
header('Location: ?');
exit();
}
$_hp = ceil($user['max_health']*10/100);
if($user['health'] < 10 or $user['health'] < $_hp){
$_SESSION['msg'] = "Для нападения необходимо минимум ".ico('icons','health.png')." 10% здоровья!<br><a href='/rinok?koldun&url=/hell//boser.php' class='link' data-ajax>Восстановить ".ico('icons','gold.png')." 15 золота</a>";
header('Location: ?');
exit();
}
if(isset($batle) and $batle['time'] > time()){
header('Location: ?');
exit();
}
# Статы босса #
$batle_str = ceil($user['str']*180/100);
$batle_def = ceil($user['def']*85/100);
# Урон #
$_str_opp = rand(round($batle_str/6), round($batle_str/4));
$_def_opp = rand(round($batle_def/12), round($batle_def/7));
$_str_opp = $_str_opp - $_def;
if($_str_opp < 0)$_str_opp = 0;
$_str = $_str - $_def_opp;
if($_str < 0)$_str = 0;
mysql_query("INSERT INTO `boser_log` SET `id_user` = '$myID', `tipe` = 'boser', `uron` = '".$_str_opp."', `id_boser` = '$batle[id]'");
mysql_query("INSERT INTO `boser_log` SET `id_user` = '$myID', `tipe` = 'user', `uron` = '".$_str."', `time` = '".(time()+0)."', `id_boser` = '$batle[id]'");
mysql_query("update `boser` set `health` = '".($batle['health']-$_str)."' where (`id` = '".$batle['id']."')");
if($batle['health'] <= 0 or $_str > $batle['health']){
mysql_query("update `boser` set `health` = '".$batle['max_health']."' where (`id` = '".$batle['id']."')");
mysql_query("update `boser` set `time` = '".(time()+600)."' where (`id` = '".$batle['id']."')");
mysql_query("update `users` set `sne` = '".($user['sne']+100)."' where (`id` = '".$myID."')");
mysql_query("update `users` set `koronki` = '".($user['koronki']+10)."' where (`id` = '".$myID."')");
mysql_query("INSERT INTO `boser_log` SET `id_user` = '$myID', `tipe` = 'zahvat', `id_boser` = '$batle[id]'");
$_SESSION['msg'] = "<font color='green'><b>Вы убили снеговика</b></font><hr>Ваша награда: ".ico('','snowball.png')." 100 и ".ico('icons','korona.png')." 5";
}
mysql_query("update `users` set `health` = '".($user['health']-$_str_opp)."', `exp` = '".($user['exp']+ceil($_str*50/100))."' where (`id` = '".$myID."')");
header("Location:/hell/boser.php");
exit();
}
# Страничка боя #
echo "<div class='block'>";
if($batle[time] > time()){
echo "
<font color=lime>Снеговик воскреснет через </font>".tl($batle[time]-time());
}else{
echo "<center><img src=images/snew.png><span style='center'></br>".ico('icons','health.png')." ".round($batle['health']/$batle['max_health']*100,1)."%</span></center><br>";
if($user[level] >= 0) echo "<center><a href='?attack' class='link' data-ajax>Атаковать</center>";
if($myLog['time'] > time())echo "[".tl($myLog['time']-time())."]";
echo "</a>";
}
echo "</div>";
echo "<div class='line'></div>";
echo "<div class='block'>";
require_once ('boser_log.php');
echo "</div>";
require_once ('../system/footer.php');
?>