Файл: public_html/bashnya.php
Строк: 146
<?php
include './system/common.php';
include './system/functions.php';
include './system/user.php';
if(!$user) {
header('location: /');
exit;
}
$title = 'Башня бессмертных';
include './system/h.php';
# Находим башню в базе #
$batle = mysql_query("SELECT * FROM `bashna` WHERE `id` = '1' ORDER BY `id` LIMIT 2");
$batle = mysql_fetch_array($batle);
if($batle['health'] > $batle['max_health'])$batle['health'] = $batle['max_health'];
if($batle['health'] < 0)$batle['health'] = 0;
# Ремонт #
if(isset($_GET['remont']) and $user['r'] == $batle['side']){
if($user['kam'] < 5){
$_SESSION['err'] = "У вас не хватает ".(5-$user['kam'])."<img src='/images/icon/kam.png' alt='*'/> камня";
header("Location: /bashnya/");
exit();
}
else{
mysql_query("update `bashna` set `health` = '".($batle['health']+ceil($user['hp']*10000000/100000000))."' where (`id` = '".$batle['id']."')");
mysql_query("update `users` set `kam` = '".($user['kam']-5)."' where (`id` = '".$user['id']."')");
mysql_query("update `users` set `exp` = '".($user['exp']+10000)."' where (`id` = '".$user['id']."')");
mysql_query("INSERT INTO `bashna_log` SET `id_user` = '$user[id]', `tipe` = 'remont', `id_bashna` = '$batle[id]'");
header("Location: ?");
exit();
}
}
# Атака #
if(isset($_GET['attack']) and $user['r'] != $batle['side']){
$_hp = ceil($user['hp']*50/50);
if($user['mp'] < 50 or $user['hp'] < 50){
$_SESSION['err'] = "Для нападения необходимо минимум <img src='/images/icon/vit.png' alt='*'/> 50 жизни и <img src='/images/icon/mana.png' alt='*'/> 40 маны!";
header('Location: /bashnya/');
exit();
}else{
mysql_query("update `users` set `mp` = '".($user['mp']-50)."' where (`id` = '".$user['id']."')");
mysql_query("update `users` set `exp` = '".($user['exp']+500)."' where (`id` = '".$user['id']."')");
mysql_query("update `users` set `s` = '".($user['s']+1000)."' where (`id` = '".$user['id']."')");
mysql_query("UPDATE `clans` SET `4` = `4` + 1 WHERE `id` = ".$clan['id']."");
# Статы башни #
$batle_str = ceil($user['str']*5/50);
$batle_def = ceil($user['def']*5/10);
# Урон #
$_str_opp = rand(round($batle_str/1), round($batle_str/10));
$_def_opp = rand(round($batle_def/1), round($batle_def/70));
$_str = rand(round($user['str']/1), round($user['str']/10));
$_def = rand(round($user['def']/12), round($user['def']/70));
$_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 `https://yandex.ua/images/touch/search?p=2&text=%D0%B1%D0%B0%D1%88%D0%BD%D0%B8&img_url=https%3A%2F%2Fwww.diyphotography.net%2Fwordpress%2Fwp-content%2Fuploads%2F2016%2F05%2Fthe-gunslinger-supernatural-horror-book-cover-art.jpg&pos=52&rpt=simage` SET `id_user` = '$user[id]', `tipe` = 'bashna', `uron` = '".$_str_opp."', `id_bashna` = '$batle[id]'");
mysql_query("INSERT INTO `bashna_log` SET `id_user` = '$user[id]', `tipe` = 'user', `uron` = '".$_str."', `id_bashna` = '$batle[id]'");
mysql_query("update `bashna` set `health` = '".($batle['health']-$_str)."' where (`id` = '".$batle['id']."')");
if($batle['health'] <= 0){
mysql_query("update `bashna` set `side` = '".$user['r']."' where (`id` = '".$batle['id']."')");
mysql_query("update `bashna` set `health` = '".$batle['max_health']."' where (`id` = '".$batle['id']."')");
mysql_query("update `users` set `g` = '".($user['g']+1000)."' where (`id` = '".$user['id']."')");
mysql_query("update `users` set `exp` = '".($user['exp']+10000)."' where (`id` = '".$user['id']."')");
mysql_query("INSERT INTO `bashna_log` SET `id_user` = '$user[id]', `tipe` = 'zahvat', `id_bashna` = '$batle[id]'");
$_SESSION['err'] = "<b><span class='dgreen'>Вы захватили Башню бессмертных </span></b><br>Награда: <img src='/images/icon/gold.png' alt='*'/> 1000 золота и <img src='/images/icon/exp.png' alt='*'/> 10000 опыта";
}
mysql_query("update `users` set `hp` = '".($user['hp']-$_str_opp)."' where (`id` = '".$user['id']."')");
header("Location: /bashnya/");
exit();
}
}
# Страничка башни #
echo "<div class='block_zero center'><img src='https://od.barbars.ru/images/castle/7.jpg'></div><div class='dot-line'></div>";
echo "<div class='block_zero'>";
echo "<span style='float:right'><img src='/images/icon/vit.png'> ".round($batle['health']/$batle['max_health']*100)."%</span>";
echo "Владельцы: ";
if($batle[side] == '1')echo "<img src='/images/icon/race/1.png' alt='*'/><font color='green'> Борея</font>";
else echo "<img src='/images/icon/race/0.png' alt='*'/><font color='red'> Асура</font>";
echo "<hr>";
echo "<div class='center'>";
if($user['r'] != $batle['side'])echo "<a href='?attack' class='btn'><span class='end'><span class='label'>Атаковать</span></span></a>";
else echo "<a href='?remont' class='btn'><span class='end'><span class='label'>Укрепить башню <img src='/images/icon/kam.png' alt='*'/> 5 камней</span></span></a>";
echo "</div>";
echo "</div>";
echo "<div class='mini-line'></div>";
echo "<div class='block_zero'>";
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `bashna_log` WHERE `id_bashna` = '$batle[id]'"),0);
$q = mysql_query("SELECT * FROM `bashna_log` WHERE `id_bashna` = '$batle[id]' ORDER BY `id` DESC LIMIT 10");
if($k_post == 0) echo "Логов не найдено...";
while($post = mysql_fetch_assoc($q)) {
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = $post[id_user] LIMIT 1"));
if($post['tipe'] == 'user'){
echo " <a href='/user/$ank[id]'>$ank[login]</a> <img src='/images/icon/sumstat.png'> Атаковал башню на $post[uron]<br>";
}elseif($post['tipe'] == 'bashna'){
echo " Враги <img src='/images/icon/tournament.png'> ударили <a href='/user/$ank[id]'>$ank[login]</a> на $post[uron]<br>";
}elseif($post['tipe'] == 'zahvat'){
echo " <a href='/user/$ank[id]'>$ank[login]</a> <img src='/images/icon/premium.png'> Захватил башню | награда <img src='/images/icon/gold.png' alt='*'/> 1000 золота и <img src='/images/icon/exp.png' alt='*'/> 10000 опыта<br>";
}elseif($post['tipe'] == 'remont'){
echo " <a href='/user/$ank[id]'>$ank[login]</a> <img src='/images/icon/settings.png'> Укрепил башню <br>";
}
}
echo "</div>";
echo "<div class='mini-line'>";
echo "<div class='menuList'>";
echo "<li><a href='/fights/'><img src='/images/icon/arrow_b.png' alt='*'/>Вернуться в сражения</a></li></div>";
include './system/f.php';
?>