Файл: public_html/modules/demons/mobs.php
Строк: 176
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
include_once ($root.'/core/base.php');
falseauth();
$header = "Вторжение демонов";
include_once ($root.'/core/head.php');
?>
<style>
.example3 .examples_text-1 {
display: block;
position: absolute;
font-size: 20px;
left: 0;
bottom: 31%;
width: 100%;
height: 10%;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
color: #fff;
padding: 0px;
}
.example3 {
display: inline-block;
position: relative;
width: 100%;
}
.example3 .examples_text-9 {
display: block;
position: absolute;
font-size: 45px;
left: 0;
bottom: 61%;
width: 98%;
height: 5%;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
color: #fff;
}
.exam {
display: inline-block;
position: relative;
}
.exam .exam_text {
display: block;
position: absolute;
left: 15px;
height: 45px;
bottom: -13px;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
color: #fff;
padding: 0px;
}
</style>
<?
$btl = $db->query("SELECT * FROM `demons_battles` WHERE `status` = 'battle' ORDER BY `id` DESC LIMIT 1");
if($btl->num_rows == 0) redirect('/demons');
$btl = $btl->fetch_object();
if($btl->stage == 'boss') redirect('/demons/boss');
if($btl->stage == 'players') redirect('/demons/players');
$myPlayer = $db->query("SELECT * FROM `demons_players` WHERE `user` = '".$u['id']."' AND `battle` = '".$btl->id."'");
if($myPlayer->num_rows == 0) redirect('/demons');
$myPlayer = $myPlayer->fetch_object();
$players = $db->query("SELECT * FROM `demons_players` WHERE `battle` = '".$btl->id."'")->num_rows;
$mobs = $db->query("SELECT * FROM `demons_mobs` WHERE `battle` = '".$btl->id."' AND `stage` = 'mobs'")->num_rows;
$alivePlayers = $db->query("SELECT * FROM `demons_players` WHERE `battle` = '".$btl->id."' AND `health` > '0'")->num_rows;
$aliveMobs = $db->query("SELECT * FROM `demons_mobs` WHERE `battle` = '".$btl->id."' AND `health` > '0' AND `stage` = 'mobs'")->num_rows;
if($alivePlayers > 0 && $aliveMobs <= 0)
{
setStage('boss', $btl->id);
redirect('/demons/boss');
}
elseif($alivePlayers <= 0 && $aliveMobs > 0)
{
$db->query("UPDATE `demons_battles` SET `status` = 'result-lose-mobs' WHERE `id` = '".$btl->id."'");
redirect('/demons/result');
}
elseif($alivePlayers <= 0 && $aliveMobs <= 0)
{
$db->query("UPDATE `demons_battles` SET `status` = 'result-lose-mobs' WHERE `id` = '".$btl->id."'");
redirect('/demons/result');
}
if($myPlayer->opponent == 0)
{
$randOpponent = $db->query("SELECT * FROM `demons_mobs` WHERE `battle` = '".$btl->id."' AND `stage` = 'mobs' AND `health` > '0' ORDER BY RAND() LIMIT 1")->fetch_object();
$db->query("UPDATE `demons_players` SET `opponent` = '".$randOpponent->id."' WHERE `id` = '".$myPlayer->id."'");
redirect('/demons/mobs');
}
$opponent = $db->query("SELECT * FROM `demons_mobs` WHERE `id` = '".$myPlayer->opponent."'")->fetch_object();
if($opponent->health <= 0)
{
$db->query("UPDATE `demons_players` SET `opponent` = '0' WHERE `id` = '".$myPlayer->id."'");
redirect('/demons/mobs');
}
if(isset($_GET['attack']))
{
if($myPlayer->health <= 0) redirect('/demons/mobs');
$damage = getDamage(get_power($u['id']), $opponent->defense);
$cooldown_time = $myPlayer->attack_cd-time();
if($cooldown_time >= 2) $finalDamage = 0;
elseif($cooldown_time == 0 && $cooldown_time == 1) $finalDamage = round($damage*(rand(1,50)/100));
else $finalDamage = $damage;
if($finalDamage != 0) $db->query("UPDATE `demons_players` SET `attack_cd` = '".(time()+3)."', `damage` = `damage` + '".$finalDamage."' WHERE `id` = '".$myPlayer->id."'");
$db->query("UPDATE `demons_mobs` SET `health` = `health` - '".$finalDamage."' WHERE `id` = '".$opponent->id."'");
if($finalDamage == 0) $logMsg = name($u['id']).' промахнулся по прислужнику Демона.';
else
{
if($finalDamage >= $opponent->health) $logMsg = name($u['id']).' убил прислужника Демона.';
else $logMsg = name($u['id']).' ударил прислужника Демона на '.$finalDamage.'.';
}
$db->query("INSERT INTO `battle_logs` (`type`,`battle`,`msg`,`time`) VALUES ('demons-mobs', '".$btl->id."', '".$logMsg."', '".time()."')");
redirect('/demons/mobs');
}
if(isset($_GET['heal']))
{
if($myPlayer->health <= 0) redirect('/demons/mobs');
if($myPlayer->heal_cd > time()) redirect('/demons/mobs');
if($myPlayer->health >= get_health($u['id'])) redirect('/demons/mobs');
$healBonus = getSkillBonus('heal');
if($healBonus+$myPlayer->health > get_health($u['id'])) $hp = get_health($u['id']);
else $hp = $myPlayer->health+$healBonus;
$db->query("UPDATE `demons_players` SET `health` = '".$hp."', `heal_cd` = '".(time()+30)."' WHERE `id` = '".$myPlayer->id."'");
redirect('/demons/mobs');
}
if(isset($_GET['arrow']))
{
if($myPlayer->health <= 0) redirect('/demons/mobs');
$damage = getDamage(getSkillBonus('arrow'), $opponent->defense);
if($myPlayer->arrow_cd > time()) redirect('/demons/mobs');
$finalDamage = $damage;
$db->query("UPDATE `demons_players` SET `arrow_cd` = '".(time()+40)."', `damage` = `damage` + '".$finalDamage."' WHERE `id` = '".$myPlayer->id."'");
$db->query("UPDATE `demons_mobs` SET `health` = `health` - '".$finalDamage."' WHERE `id` = '".$opponent->id."'");
if($finalDamage >= $opponent->health) $logMsg = name($u['id']).' убил прислужника Демона навыком "Разряд".';
else $logMsg = name($u['id']).' ударил прислужника Демона навыком "Разряд" на '.$finalDamage.'.';
$db->query("INSERT INTO `battle_logs` (`type`,`battle`,`msg`,`time`) VALUES ('demons-mobs', '".$btl->id."', '".$logMsg."', '".time()."')");
redirect('/demons/mobs');
}
echo '<div class="example3">
<div class="b">
<div class="examples_text-9"><center>'.$aliveMobs.'</center></div>
<div class="examples_text-1">
<center>
<a href="?attack"><img src="/images/b-ok.png" width="17%"></a>
</center>
</div>
<center>
<font color = "lime"><b><big>
Слуга демона <img src="/images/health.png" width="35" height="30"> '.$opponent->health.'
</b></big></font>
</center>
<center><img src="/modules/demons/mob-min.png" width="50%"></center>
</div>';
echo '<div class="b"><center><big>Живых игроков: <img src="/images/users.png" width="35px"> '.$alivePlayers.'</center></big></div>';
echo '<div class="b-mini"><center>
<font color = "lime"><b><big><img src="/images/users.png" width="35px"> Вы
<img src="/images/health.png" width="35" height="30">
'.$myPlayer->health.' </font>
</b></big></center>
<div style="height: 8px; border: 1px solid #000; position:relative; border-radius: 4px">
<div style="height: 8px; background: #00A4D9; width:56%; position: absolute; left: 0px; top: 0px; border-radius: 2px; border-bottom-right-radius: 1px;border-top-right-radius: 1px;">
</div>
</div>
</div>
';
echo'<div class = "b-mini">';
echo'
<table style="width:100%;">
<tr>
<td style="width: 33%;" class="center">';
if($myPlayer->heal_cd > time())
{
echo'
<input type="submit" value="Исцеление ('.tl($myPlayer->heal_cd-time()).')">
</td>';
}
else
{
echo '<a href="?heal"><input type="submit" value="Исцеление"></a>
</td>';
}
echo'
<td style="width:33%;" class="center">';
if($myPlayer->arrow_cd > time())
{
echo '<input type="submit" value="Разряд ('.tl($myPlayer->arrow_cd-time()).')">
</td>
</tr>
</table>
';
}
else
{
echo '<a href="?arrow"><input type="submit" value="Разряд"></a>
</td>
</tr>
</table>
';
}
echo'</td>
</tr>
</table>';
echo '</div></div>
';
$log = $db->query("SELECT * FROM `battle_logs` WHERE `type` = 'demons-mobs' AND `battle` = '".$btl->id."' ORDER BY `time` DESC LIMIT 10");
if($log->num_rows > 0)
{
echo '<div class="b">';
while($l = $log->fetch_object())
{
echo $l->msg.'<br>';
}
echo '</div>';
}
include_once ($root.'/core/foot.php');