Файл: public_html/modules/campaign/battle.php
Строк: 46
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
include_once ($root.'/core/base.php');
falseauth();
$header = "Поход";
include_once ($root.'/core/head.php');
$issetCampaign = $db->query("SELECT * FROM `campaign_battle` WHERE `user` = '".$u['id']."'");
if($issetCampaign->num_rows == 0) redirect('/trip');
$iC = $issetCampaign->fetch_object();
if($iC->status == 'found') redirect('/trip/found');
if(($iC->attacks <= 0) && ($iC->mob_health > 0 && $iC->health <= 0))
{
$db->query("UPDATE `campaign_battle` SET `status` = 'result-lose' WHERE `id` = '".$iC->id."'");
redirect('/trip/result');
}
if($iC->time < time() )
{
$db->query("UPDATE `campaign_battle` SET `status` = 'result-lose' WHERE `id` = '".$iC->id."'");
redirect('/trip/result');
}
if($iC->attacks <= 0)
{
$db->query("UPDATE `campaign_battle` SET `status` = 'result-lose' WHERE `id` = '".$iC->id."'");
redirect('/trip/result');
}
if($iC->attacks > 0 && ($iC->mob_health <= 0 && $iC->health > 0))
{
$db->query("UPDATE `campaign_battle` SET `status` = 'result-win' WHERE `id` = '".$iC->id."'");
redirect('/trip/result');
}
if($iC->attacks > 0 && ($iC->mob_health <= 0 && $iC->health <= 0))
{
$db->query("UPDATE `campaign_battle` SET `status` = 'result-win' WHERE `id` = '".$iC->id."'");
redirect('/trip/result');
}
$types = ['Орк', 'Гоблин', 'Драгс', 'Гном'];
echo '<div class="b">
<center>
<b><big>'.$types[$iC->type].'</big></b> <img src="/images/health.png" width="35" height="30"> <b><big>'.$iC->mob_health.'</big></b></br>
<div class = "examples">
<a href="?attack"><img src="/images/campaign/mob-'.$iC->type.'.png" width="50%"><br></br></a>
<center> <a href="?attack"><img src="/images/battleground/attack.png"></a></center>
</center>
</div></div>';
echo '<div class="notice_container"><div class="gborder notice_alert alert-success">
<center>
<font color = "lime">Моё здоровье: <img src="/images/health.png" width="35" height="30"> '.$iC->health.'
<img src="/images/str.png" width="30" height="25"> '.$iC->attacks.'</font>
</center>';
if(isset($_GET['attack']))
{
$damage = getDamage(get_power($u['id']), $iC->mob_block);
$mobDamage = getDamage($iC->mob_attack, get_block($u['id']));
$myLog = "Вы нанесли ".$damage." урона ".$types[$iC->type]."";
$mobLog = $types[$iC->type]." нанёс вам ".$mobDamage." урона";
$db->query("UPDATE `campaign_battle` SET `health` = `health` - '".$mobDamage."', `mob_health` = `mob_health` - '".$damage."', `attacks` = `attacks` - '1' WHERE `id` = '".$iC->id."'");
$db->query("INSERT INTO `battle_logs` (`type`,`battle`,`msg`,`time`) VALUES ('trip', '".$iC->id."', '".$myLog."', '".time()."')");
$db->query("INSERT INTO `battle_logs` (`type`,`battle`,`msg`,`time`) VALUES ('trip', '".$iC->id."', '".$mobLog."', '".time()."')");
redirect('/trip/battle');
}
$log = $db->query("SELECT * FROM `battle_logs` WHERE `type` = 'trip' AND `battle` = '".$iC->id."' ORDER BY `time` DESC");
if($log->num_rows > 0)
{
while($l = $log->fetch_object())
{
echo $l->msg.'<br>';
}
}
echo '</br><center><font color = "lime">Осталось '.$iC->attacks.' ходов</font></center>';
echo '</div></div>';
include_once ($root.'/core/foot.php');