<?php

require_once 'core/system.php';


head('Путь Героя');



reg();
$bat=$dbc->query("SELECT * FROM `way`where `user`= '".$user['id']."' ")->fetch_assoc();

if($bat['user']==0){ header('location: index.php');exit;}



$heal = $bat['hp']/$bat['max']*100;


$my = $bat['us_hp']/$bat['us_max']*100;


if(isset($_GET['at'])){  $my_udar = $user['strength']-$bat['prot']+mt_rand(5,10);    $vrag_udar = $bat['strong']-$user['defense']+mt_rand(1,5); if($vrag_udar<1){ $vrag_udar = mt_rand(1,5);} if($my_udar<1){ $my_udar = mt_rand(1,5);} $_SESSION['my']='<span class="info"> - '.$my_udar.'</span>'; $_SESSION['vrag']='<font color="red"> - '.$vrag_udar.'</font>';                                                                                                           










$se = $bat['sera']/2; $se = ceil($se);

$dell = $bat['hp']-$my_udar; $des = $bat['us_hp']-$vrag_udar;



//if($des<=0){
if($vrag_udar>=$bat['us_hp']){







                                                                $dbc->query("update `users` set `serebro`=`serebro`+'".$se."' where `id`= '".$user['id']."'");

                                                                $dbc->query("update `dop` set `st_way`=0 , `etap_way`=0 where `user`= '".$user['id']."'");



$_SESSION['info']='<center><font color=red>Поражение</font> <img src="img/stat/sera.png"> '.$se.'</center>';


$until = 3600 + TIME;
$dbc->query("update `dop` set `time_way` = ".$until." where `user` = '".$user['id']."'");


$dbc->query("delete from `way` where `user`='".$user['id']."'");



                                   header('location: way.php');exit;}

if($dell>0){
                                                                $dbc->query("update `way` set `hp`=`hp`-'".$my_udar."', `us_hp`=`us_hp`-'".$vrag_udar."' where `user`= '".$user['id']."'");



Oput($my_udar);

}
if($dell<=0){ 



                                                                $dbc->query("update `dop` set `etap_way`=`etap_way`+1, `st_way`=0 where `user`= '".$user['id']."'");


                                                                $dbc->query("update `users` set `serebro`=`serebro`+'".$bat['sera']."' where `id`= '".$user['id']."'");


$dop=$dbc->query("SELECT `etap_way` FROM `dop`where `user`= '".$user['id']."' ")->fetch_assoc();

if($dop['etap_way']==4){ $dbc->query("update `user` set `rubin`=`rubin`+10 where `id`='".$user['id']."'"); }


if($dop['etap_way']==7){ $dbc->query("update `dop` set `box1`=`box1`+1 where `user`='".$user['id']."' ");      }




if($dop['etap_way']==10){ $dbc->query("update `dop` set `box2`=`box2`+1 ,`etap_way`=0 where `user`='".$user['id']."' ");      }


if($user['ob']==8){
$dbc->query("UPDATE `users` SET `ob`=`ob`+1 WHERE `id`='".$user['id']."'");}


$_SESSION['info']='<center><span class="info">Победа</span> <img src="img/stat/sera.png"> '.$bat['sera'].'</center>';


$until = 3600 + TIME;
$dbc->query("update `dop` set `time_way` = ".$until." where `user` = '".$user['id']."'");

$dbc->query("UPDATE `rang` SET  `way`=`way`+1 WHERE `user`='".$user['id']."'");




$dbc->query("delete from `way` where `user`='".$user['id']."'");



                                   header('location: way.php');exit;}





}




$batt=$dbc->query("SELECT `us_hp`,`max`,`hp`,`us_max` FROM `way`where `user`= '".$user['id']."' ")->fetch_assoc();





$heal = $batt['hp']/$batt['max']*100;


$my = $batt['us_hp']/$batt['us_max']*100;





?><div class="b-panel-new dblue-panel bordered mt2"><div class="panel-inner-2"><img src="img/mon_sag/<?=$bat['img']?>.png"><?=$bat['name']?> <img
src="/img/stat/
AKulak.png"><?=$bat['strong']?><img src="images/icons/armor.png"><?=$bat['prot']?> <img src="img/stat/hp.png"><?=$batt['hp']?><?=$_SESSION['my']?> <div class="enemy-hp2">




<div class="enemy-hp-remain2 hp-green" style="width:<?=$heal?>%"></div>

</div></div></div><?



?><div class="combat-line"><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td width="50%"><a href="/way_bat.php?at" class="btn-red"><img class="link-icon" src="/images/icons/sword1.png" alt="" width="12" height="12"><span>Атаковать</span></a></td><td width="50%"><a href="?" class="btn-red"><span>Обновить</span></a></td></tr></table></div><? 










?><div class="b-panel-new dblue-panel bordered mt2"><div class="panel-inner-2"><img src="/img/auser/<?=$user['storona']?>/<?=$user['pers']?>/pers.png" width="32" height="32" alt="."/><?=$user['login']?> <img
src="/img/stat/
AKulak.png"><?=$user['strength']?><img src="images/icons/armor.png"><?=$user['defense']?> <img src="img/stat/hp.png"><?=$batt['us_hp']?><?=$_SESSION['vrag']?><div class="enemy-hp2">





<div class="enemy-hp-remain2 hp-green" style="width:<?=$my?>%"></div> ><br/></div></div><?


?><div class="lblue-panel"><div class="panel-inner-2"><div class="font-small text-italic c-verygray">При поражении вас перенесет на начальный этап</div></div></div></div><?


$_SESSION['my']=null; $_SESSION['vrag']=null;

foot(); 

