Файл: public_html/modules/battleground/battle.php
Строк: 180
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
include_once ($root.'/core/base.php');
falseauth();
$header = "Поле боя";
include_once ($root.'/core/head.php');
if($u['battleground_id'] == 0) redirect('/battleground', 'Вы не участвуете в битве!');
$btl = $db->query("SELECT * FROM `battleground_battles` WHERE `id` = '".$u['battleground_id']."'");
if($btl->num_rows == 0)
{
$db->query("UPDATE `users` SET `battleground_id` = '0' WHERE `id` = '".$u['id']."'");
redirect('/battleground', 'Битва не найдена!');
}
$btl = $btl->fetch_object();
$players = $db->query("SELECT * FROM `battleground_players` WHERE `health` > '0' AND `battle` = '".$btl->id."'")->num_rows;
if($players == 1)
{
$db->query("UPDATE `battleground_battles` SET `status` = 'result' WHERE `id` = '".$btl->id."'");
redirect('/battleground/result');
}
if($btl->status == 'prepare') redirect('/battleground');
if($btl->status == 'result') redirect('/battleground/result');
if($btl->status == 'end') redirect('/battleground');
$my = $db->query("SELECT * FROM `battleground_players` WHERE `battle` = '".$btl->id."' AND `user` = '".$u['id']."'");
if($my->num_rows == 0)
{
$db->query("UPDATE `users` SET `battleground_id` = '0' WHERE `id` = '".$u['id']."'");
redirect('/battleground', 'Вы не участвуете в битве!');
}
$my = $my->fetch_object();
if($my->health > 0)
{
if($my->opponent == 0)
{
getRandOpponentForBattleground();
redirect("/battleground/battle");
}
}
$opponent = $db->query("SELECT * FROM `battleground_players` WHERE `battle` = '".$btl->id."' AND `user` = '".$my->opponent."'")->fetch_object();
$opponentUser = $db->query("SELECT * FROM `users` WHERE `id` = '".$opponent->user."'")->fetch_object();
$myHealthProgress = round(($my->health*100)/get_max_health($my->user));
$opponentHealthProgress = round(($opponent->health*100)/get_max_health($opponent->user));
if($opponent->health == 0)
{
getRandOpponentForBattleground(1);
redirect("/battleground/battle");
}
if(isset($_GET['attack']))
{
if($my->health > 0)
{
$myDamage = getDamage(get_power($u['id']), get_block($opponentUser->id));
if($myDamage >= $opponent->health)
{
$logMsg = who($u['id']).' убил '.who($opponentUser->id).'!';
$db->query("UPDATE `battleground_players` SET `damage` = `damage` + '".$myDamage."' WHERE `id` = '".$my->id."'");
$db->query("UPDATE `battleground_players` SET `health` = '0' WHERE `id` = '".$opponent->id."'");
$db->query("INSERT INTO `battle_logs` (`type`,`battle`,`msg`,`time`) VALUES ('battleground', '".$btl->id."', '".$logMsg."', '".time()."')");
redirect("/battleground/battle", 'Вы убили игрока!');
}
else
{
$logMsg = who($u['id']).' нанёс '.$myDamage.' урона '.who($opponentUser->id).'!';
$db->query("UPDATE `battleground_players` SET `damage` = `damage` + '".$myDamage."' WHERE `id` = '".$my->id."'");
$db->query("UPDATE `battleground_players` SET `health` = `health` - '".$myDamage."' WHERE `id` = '".$opponent->id."'");
$db->query("INSERT INTO `battle_logs` (`type`,`battle`,`msg`,`time`) VALUES ('battleground', '".$btl->id."', '".$logMsg."', '".time()."')");
redirect("/battleground/battle", 'Вы нанесли '.$myDamage.' урона!');
}
}
else redirect('/battleground/battle', 'Вы мертвы!');
}
if(isset($_GET['dodge']))
{
if($my->health > 0)
{
if($players > 2)
{
$randOpp = $db->query("SELECT * FROM `battleground_players` WHERE `opponent` = '".$u['id']."' AND `battle` = '".$btl->id."' ORDER BY RAND() LIMIT 1")->fetch_object();
$random = $db->query("SELECT * FROM `battleground_players` WHERE `battle` = '".$btl->id."' AND `user` != '".$u['id']."' AND `user` != '".$randOpp->user."' ORDER BY RAND() LIMIT 1")->fetch_object();
$db->query("UPDATE `battleground_players` SET `opponent` = '".$random->user."' WHERE `id` = '"
.$randOpp->id."'");
redirect('/battleground/battle', 'Вы увернулись от врага!');
}
else redirect('/battleground/battle', 'Мало игроков!');
}
else redirect('/battleground/battle', 'Вы мертвы!');
}
echo '<div class = "b"><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="38%" align="right" valign="top">';
echo " <center><big><font color = 'lime'>Вы</font></big>
<div style='height: 10px; border: 1px solid #000; background: #171410; position:relative; border-radius: 2px'>
<div style='height: 10px;background: #ee9200; width:".$myHealthProgress."%; max-width:100%;
position: absolute; left: 0px; top: 0px; border-radius: 2px; border-bottom-right-radius: 1px;border-top-right-radius: 1px;'>
<div style='height: 3px;background: #fba41b; width:98%; max-width:100%; position: absolute; left: 1%; top: 2px; border-radius: 2px; '>
</div>
</div>
</div></br>
</center></a><br><img src='/images/battleground/".$u['sex'].".png' width='100' height='100'
style='margin-right:3px;margin-top:-25px;'></a>
<td width='50%'>
<table width='80%' height='80%' border='0' cellpadding='0' cellspacing='0' align='center'><br> </br>
<tbody><tr align='center'>
<td width='33%' class='text-right'><font color = 'white'> ".get_power($u['id'])."</font></td>
<td> <img src='/images/str.png' width='30px'></td>
<td width='33%' class='text-left'><font color = 'white'>".get_power($opponentUser->id)."</font></td></tr>
<tr align='center'><td width='33%' class='text-right'><font color = 'white'>".get_block($u['id'])."</font></td>
<td width='15'> <img src='/images/def.png' width='30px'></td>
<td width='33%' class='text-left'><font color = 'white'>".get_block($opponentUser->id)."</font></td></tr>
<tr align='center'>
<td width='33%'><font color = 'white'>".get_max_health($u['id'])."</td>
<td><img src='/images/health.png' width='30px'></td>
<td width='33%' class='text-left'><font color = 'white'>".get_max_health($opponentUser->id)."</font></td>
</tr>
</font>
</tbody>
</table>
</div></td>
<td width='38%' align='left' valign='top'>
<center> <big><font color = 'red'>".$opponentUser->login."</font></big>
<div style='height: 10px; border: 1px solid #000; background: #171410; position:relative; border-radius: 2px'>
<div style='height: 10px;background: #ee9200; width:".$opponentHealthProgress."%; max-width:100%; position: absolute; left: 0px; top: 0px; border-radius: 2px; border-bottom-right-radius: 1px;border-top-right-radius: 1px;'>
<div style='height: 3px;background: #fba41b; width:98%; max-width:100%; position: absolute; left: 1%; top: 2px; border-radius: 2px; '>
</div>
</div>
</div></br>
</center></a><br><img src='/images/battleground/".$opponentUser->sex.".png' width='100' height='100' style='margin-right:3px;margin-top:-25px;'></td></tr></table>
<center><a href = '/battleground/battle/attack'> <img src='/images/battleground/attack.png'></a> <a
href = '/battleground/battle/dodge'><img
src='/images/battleground/not-me-attack.png'></a></center>
</div>";
$logs = $db->query("SELECT * FROM `battle_logs` WHERE `type` = 'battleground' AND `battle` = '".$btl->id."' ORDER BY `time` DESC LIMIT 10");
if($logs->num_rows > 0)
{
echo '<div class = "notice_container">
<div class = "gborder notice_alert alert-success">';
while($l = $logs->fetch_object())
{
echo $l->msg.'<br>';
}
echo '</div></div>';
}
include_once ($root.'/core/foot.php');
?>