<?php
require_once 'core/system.php';

head('Охота');
reg(); 









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

 $max = array (0,200,500,1000,2000,4000,5000,7000,11000,15000,25000,40000,60000,90000,130000,180000); 


$desi = $max[$dop['ohot_lvl']];


if(isset($_GET['inf']) and !empty($_GET['id'])){
    $item_tip = int($_GET['id']);

if($item_tip ==1){ $kes ='iSuperior';}
if($item_tip ==2){ $kes ='iEpic';}
if($item_tip ==3){ $kes ='iLegendary';}




$gg=$dbc->query("SELECT * FROM `uart` where `class`='".$user['pers']."' and `lite`='".$kes."'");

?><center>Возможный дроп с этого противника</center><?

while($inf=$gg->fetch_assoc()){ 


?>



<a href="items.php?ids=<?=$inf['id']?>" class="<?=$inf['lite']?>"><?=$inf['nik']?></a>,



</div>




<?




}








foot();exit;




































}


if(isset($_GET['bat'])){

$mob=$dbc->query("SELECT * FROM `fduel`where id= '".$dop['ohot']."' ")->fetch_assoc();




if($dop['boi']<=0){ $_SESSION['bat']='<center>У вас нет свитков охотника</center>'; header('location: ohot.php');exit;}






$level = 20*$user['level'];


if($mob['lite']=='iSuperior'){ $bon=2; $itrand =mt_rand(1,15); } if($mob['lite']=='iEpic'){ $bon=3; $itrand=mt_rand(1,54);} if($mob['lite']=='iLegendary'){ $bon=4; $itrand=mt_rand(1,120);}




$doble  = 30*$user['level'];

$doblle  = 250*$user['level'];




$sila  = $mob['strong']+$doble;
$hp  = $mob['hp']+$doblle;
$prot  = $mob['prot']+$doble;


$vrag = $sila+$hp+$prot;


$sera = 50+$level*$bon;  $exp = 40+$level*$bon;


$me = $user['strength']+$user['health']+$user['defense'];
if($me>$vrag){    


$dbc->query("update `dop` set `boi`=`boi`-1 where `user`='".$user['id']."' ");

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

Oput($exp);

$nes = mt_rand(11,50);

$dbc->query("UPDATE `dop` SET `ohot_exp`=`ohot_exp`+'".$nes."' WHERE `user`='".$user['id']."'"); 

if($itrand==5){


$buy=$dbc->query("SELECT * FROM `uart` where `class`='".$user['pers']."' and `lite`='".$mob['lite']."' order by rand() ")->fetch_assoc();





$dbc->query("INSERT INTO `artefact` (user_id,status,nik,strong,hp,prot,crit,regen,level,tip,class,lite,coin,img) values('".$user['id']."','".$buy['status']."','".$buy['nik']."','".$buy['strong']."','".$buy['hp']."','".$buy['prot']."','".$buy['crit']."','".$buy['regen']."','".$buy['level']."','".$buy['tip']."','".$buy['class']."','".$buy['lite']."','".$buy['coin']."','".$buy['img']."')");
$_SESSION['item']='<center><span class="info">Вы нашли Вещь</span>  <span class="'.$buy[lite].'">'.$buy[nik].'</span></center>';










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


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



$_SESSION['bat']='<center><span class="info">Победа</span><br><img src="img/stat/exp.png">'.$exp.' <img src="img/stat/sera.png">'.$sera.'</center>'; header('location: ohot.php?');exit;




}
else{

$sera = $sera/2; $sera=ceil($sera);   $exp = $sera/2; $exp=ceil($exp);
$dbc->query("update `dop` set `boi`=`boi`-1 where `user`='".$user['id']."' ");

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

Oput($exp);


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




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




 header('location: ohot.php?');exit;


}
}
$mon=$dbc->query("SELECT * FROM `fduel` order by rand() ")->fetch_assoc();



$dbc->query("update `dop` set `ohot`='".$mon['id']."'where `user`='".$user['id']."' ");






if($mon['lite'] =='iSuperior'){ $ken =1;}

if($mon['lite'] =='iEpic'){ $ken =2;}

if($mon['lite'] =='iLegendary'){ $ken =3;}










$gen  = 30*$user['level'];


$sila  = $mon['strong']+$gen;



$genn = 250*$user['level'];


$hp  = $mon['hp']+$genn;

$prot  = $mon['pet']+$gen;


?><div class="cito-name">


    Охота (<?=$dop['boi']?> Свитков Охотника)</div>




<?
  if (isset($_SESSION['bat'])){?><div style="clear:both;"></div><div class="b-notice trsmgr"><div class="notify-inner"><?=$_SESSION[bat]?></div></div><?   $_SESSION['bat']=NULL; }

  if (isset($_SESSION['item'])){?><div style="clear:both;"></div><div class="b-notice trsmgr"><div class="notify-inner"><?=$_SESSION[item]?></div></div><?   $_SESSION['item']=NULL; }


?>
<center>
<div class="gr-panel panel-inner-2 mb2">

        <div class="t">
            <a href="?bat&r=860">

<center><div class="example3" style="text-align:center">
                <img src="img/hun/<?=$mon['img']?>.png">

<div class="example_text">Атаковать</a></div></div></center>

                    <i></i>
                </span>
            </a>
            <p>
                <span class="<?=$mon['lite']?>"><?=$mon['name']?></span>  </br>














                <img src="/img/stat/AKulak.png"><span class="high"><?=$sila?></span>





                <img src="img/stat/hp.png"><span class="high"><?=$hp?></span>





               <img src="/images/icons/armor.png"><span class="high"><?=$prot?></span><br />




            </p>
        </div>
        <div class="wrapper-btn">
            <a class="btn _red" href="ohot.php?">Сменить Противника</a>


<img src="/img/avatar/<?=$user['sex']?>/<?=$user['avatar']?>.png"   
style="box-shadow: 0px 0px 26px violet; margin: 10px;">

</br><img src="/img/stat/AKulak.png"><span class="high"><?=$user['strength']?></span>




                <img src="img/stat/hp.png"><span class="high"><?=$user['health']?></span>





               <img src="/images/icons/armor.png"><span class="high"><?=$user['defense']?></span><br />




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























  $new_dop=$dbc->query("SELECT * FROM `dop`where `user`= '".$user['id']."' ")->fetch_assoc();
if($new_dop['ohot_exp']>=$desi){

$dbc->query("UPDATE `users` SET `max_health`=`max_health`+50, `strength`=`strength`+10, `defense`=`defense`+10, `gold`=`gold`+50 WHERE `id`='".$user['id']."'");

$dbc->query("UPDATE `dop` SET `ohot_lvl`=`ohot_lvl`+1 , `ohot_exp`=0 WHERE `user`='".$user['id']."'");
$_SESSION['message'] = 'Навык Охотника Повышен! получено 50 золота';

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

?><a class="btn" href ="ohot.php?inf&id=<?=$ken?>"> Дроп с Монстра </a> <?

foot();
