<?php

//include_once 'core/class.php';

require_once 'core/system.php';








head('Сражение');




reg();



$weapo = $user['strength']+$user['dobav'];









$tanki='';






if($user['vip']==1){ $shans =70; }else{ $shans = 40;}
if($user['vip']==1){ $shans1 =100; }else{ $shans1 = 30;}











$weapon = $weapo;
if($user['level']<30){ $weapon = $weapon+200;}





$bb = mt_rand(1,100);
$crit = ($bb<=$user['crit']) ? true : false;


$bbb = mt_rand(1,100);
$sok = ($bbb<=30) ? true : false;





if($sok==1){ $takt= $weapon * $user['sokru'] / 100; $takt = ceil($takt); $weapon = $weapon +$takt;}






$weapon  = $weapon +$takt;

if($crit == 1){ $weapon = $weapon  * 1.5; $weapon = ceil($weapon); }









$plazma = $user['strength']+$user['dobav'];



$messi = ($crit==1) ? '<font color=red>(крит)</font>' : '';


$am1_time = $user['am1_time'] -time();
if($am1_time<=0){ $am1_time =''; }


$am2_time = $user['am2_time'] -time();
if($am2_time<=0){ $am2_time =''; }
$apteka_time = $user['apteka_t'] -time();
if($apteka_time<=0){ $apteka_time =''; }




$next = 0;
if($user['s_pet']==1){

$pet = $dbc->query("SELECT `name`,`str`,`spec` FROM `user_pets` WHERE `id_user` = '".$user['id']."' LIMIT 1")->fetch_assoc(); $next = $pet['str']; }



$rast = ($next>0 and $pet['spec']==2) ? $next : 0 ;













if($user['pers']==1){ $dob=2; } else { $dob=1; }











$aluko = $dbc->query("SELECT `max_health`,`health`,`id` ,`name`,`time`,`money`,`strength`,`def`,`spec`,`otrava`,`img` FROM `monster` WHERE `user`='".$user['id']."' LIMIT 1")->fetch_assoc();






$cc = $aluko['health']/$aluko['max_health']*100;
$cc = floor($cc);






if(!$aluko){ $_SESSION['message']=' Монстр убит или сбежал';


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



//if($user['pers']==1){ $dob=2; }esle{ $dob=1; }







function dead_bos(){
global $user;
global $dbc;
global $aluko;
global $dob;
global $shans;

$byl  = mt_rand(1,4);


$dbc->query("UPDATE `monster` SET `health`=0, `user` = 0, `time`=0 ,`otrava`='".$byl."' WHERE `id`='".$aluko['id']."'");


/*
$ff = mt_rand(1,100);

if($ff<=70){



$bc = "<img src=img/new/gift.png width='16' height='16'>+1";
$all = 1; }else { $all = 0;


$bc = ""; }

*/

$bc ="";

if($user['level']<15){ $limit = 10; $kr =1; $pm =1; }elseif($user['level']>=15){ $limit= 20; $kr =1;  $pm =1; }




if($user['level']>=25){  $limit = 30; $kr =1; $pm =1; }

if($user['level']>=45){  $limit = 40; $kr =2;  $pm =2; }




if($user['level']>=55){  $limit = 50; $kr =3;  $pm =3; }

if($user['level']>=65){  $limit = 60; $kr =4;   $pm =4;}

if($user['level']>=75){  $limit = 70; $kr =5;  $pm =5;  }

if($user['level']>=85){  $limit = 80; $kr =6;  $pm =6; }

if($user['level']>=95){  $limit = 100; $kr =7; $pm =7;  }

$limit   = $limit*1;


$bon = $dbc->query("SELECT * FROM `bonus` WHERE `user` = '".$user['id']."' LIMIT 1")->fetch_assoc(); 


if($bon['kris']==1){


$kr = $kr+2;


$limit = $limit+20;}

if($user['vip']==1){ $kr = $kr*2;}





if($user['lim']<$limit){


$sp = mt_rand(1,100);
 }else{ $sp = 101; }
if($sp<=20){ $vi ='Вы нашли <img src="img/money/money.png"> 1'; 





$dbc->query("UPDATE `users` SET `gold`=`gold`+1,`lim`=`lim`+1 WHERE `id`='".$user['id']."'"); }else { $vi = '';



}


$sion = 0;
$vis ='';
if($user['vip']==1){ $sion = $aluko['money']/2; $vis =' <span class=iLegendary>бонус vip: </span><img src=img/stat/sera.png>'.$sion.'';}



	

			
//if($user['clan']>0 and $user['level']>14){ $dbc->query("UPDATE `clan` SET `tour`=`tour`+'".$dob."' WHERE `id`='".$user['clan']."'"); }



$baba = $aluko['money']+$sion;



				
				// Начисляем рубины				
$dbc->query("UPDATE `users` SET 	`serebro`=`serebro`+'".$baba."' WHERE `id`='".$user['id']."'");



$dbc->query("UPDATE `clan` SET `sera`=`sera`+10  , `s_l`=`s_l`+10 WHERE `les`=1");


if($aluko['otrava']==3 and $user['level']>=40){

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





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



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


$item='';
				
$park = mt_rand(1,20);




if($user['lim']<$limit and $park==2 and $aluko['spec']>0){





$buy=$dbc->query("SELECT * FROM `it_pet` where `spec`='".$aluko['spec']."' order by rand() ")->fetch_assoc(); 





$dbc->query("INSERT INTO `art_pet` (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']."')"); 






$it = $dbc->insert_id; 




$item='Найдена Вещь <a href=info_it.php?ids='.$it.'><span class='.$buy['lite'].'>'.$buy['nik'].'</a>';










}






$bi = mt_rand(1,100);



if($bi<=$shans){ $viv ='Вы нашли <img src="img/new/kr.png">'.$kr.' </br> 
Найдены слезы влююбленных: <img src="/img/stat/hp.png">'.$pm.'  '; 
$dbc->query("UPDATE `users` SET `pump`=`pump`+'".$pm."' WHERE `id`='".$user['id']."'"); 

$dbc->query("UPDATE `users` SET `tour`=`tour`+'".$kr."' WHERE `id`='".$user['id']."'"); 




$dbc->query("UPDATE `clan` SET `tour`=`tour`+'".$kr."' WHERE `id`='".$user['clan']."'"); 


$_SESSION['snow']="$viv";}


		
		
		

$_SESSION['message']=' '.$aluko['name'].' убит.. <img src=img/stat/sera.png>'.$aluko['money'].' '.$vi.' '.$vis.' '.$item.' '.$bc.' ';











header ('location: fost.php');exit();

}




/////Элексир
	if(isset($_GET['el'])){
                if ($user['apteka_t'] > time()) {   
header('location:battle.php');exit;}



If($user['apteka']<=0){
$loki = '<font color=grey> У вас нет зелий</font>'; 

 $_SESSION['logi']="$loki";  header('location:battle.php');exit;}else{




$min = '<font color=green> Вы использовали зелье, здоровье восстановлено</font>'; 


$_SESSION['logi']="$min";


$dbc->query("UPDATE `users` SET `health`='".$user['max_health']."',`apteka_t` = '" .
(time() + 40) . "' ,`apteka`=`apteka`-1 WHERE `id`='".$user['id']."'");header('location:battle.php');exit;}}






/////////Простой Удар

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



If($user['udar']>time()){
$loki = '<font color=grey> Промах!</font>'; 

$_SESSION['logi']="$loki"; header('location:battle.php');exit;}











$lolvamp = mt_rand(1,100);
$lolpet = mt_rand(1,100);

$hill = $user['strength'] * $user['vampir'] / 100; $hill = ceil($hill);



$hill = ($lolvamp<=20) ? $hill : 0;








$last_pet = ($lolpet<=25) ? $pet['str'] : 0;




$conf=$hill+$last_pet;



$conf=$conf+$user['health']; 


$itog = ($conf>=$user['max_health']) ? $user['max_health'] : $conf; 





$ma = ($lolvamp<=20) ? ' ,похитив '.$hill.' здоровья' : '';



if($user['health']<$user['max_health'] and $lolpet<=25 || $lolvamp<=20){






$dbc->query('UPDATE `users` SET `health` = "' .$itog. '" WHERE `id` = "' . $user[id] . '"'); }

$bon = $dbc->query("SELECT * FROM `bonus` WHERE `user` = '".$user['id']."' LIMIT 1")->fetch_assoc(); 


if($bon['les']==1){





$den = $weapon * 30 / 100; 


$weapon = $weapon+$den;}


$vi ='';
$ket = $weapon*$aluko['def']/100;

$weapon  = $weapon - $ket;

$weapon = floor($weapon);
/*
$re = $weapon;
$re = $re - $aluko['def'];
$weapon = ($re>0) ? $re : 1;

*/
$wep = $weapon;

if($lolpet<=25 and $pet['spec']==1){

$vi = '</br><font color=green>Ваш питомец '.$pet[name].' зацепил  '.$aluko['name'].' на  '.$pet['str'].'</font>'; $weapon = $weapon+$pet['str']; }





if ($weapon >= $aluko['health']) {

Oput($weapon);
dead_bos(); }
else{
$dbc->query("UPDATE `monster` SET `health`=`health`-".$weapon." WHERE `id`='".$aluko['id']."'");

$dbc->query("UPDATE `users` SET `udar` = '" .(time() + 2) . " ' WHERE `id` = '" . $user['id'] . "'");




$maxty = ($sok==1) ? 'Сокрушил' : 'Ударил';




$suk = '<font color=green> Ты '.$maxty.' '.$aluko['name'].' на  '.$wep.' '.$messi.'</font>'.$ma.''; }


$_SESSION['kesy']="-$wep";






If($user['s_pet']==1 and $user['health']<$user['max_health'] and $lolpet<=25){



If($pet['spec']==2){ 



$vi = '</br><font color=lime> '.$pet['name'].' Исцелил тебя на  '.$last_pet.'</font>';















}}

Oput($weapon);


$mob_udar = mt_rand(1,2);


$tf = $aluko['strength']; 


$tf = $tf - $user['defense'];
$mob_uron = ($tf>0) ? $tf : mt_rand(1,30);





if($mob_udar == 2){
$wow = array('ударил','укусил','ранил');
shuffle($wow);
$tanki = '</br><font color=red> '.$aluko['name'].' '.$wow[0].' тебя на  '.$mob_uron.'</font>'; 



              
if($mob_uron>0){


  if ($mob_uron > $user['health']) {

$dbc->query("UPDATE `users` SET `health`='100' WHERE `id`='".$user['id']."'");

header ('location:death.php');exit();
}else{ $dbc->query("UPDATE `users` SET `health`=`health`-".$mob_uron." WHERE `id`='".$user['id']."'");}
}

}

$suk.=$tanki;
$suk.=$vi;
$_SESSION['logi']="$suk";





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



//////Душа Тени


	if(isset($_GET['dusha'])){
   if($user['dobav'] > 0) {  header('location:battle.php');exit;}            

 if($user['am1_time'] > time()) {  header('location:battle.php');exit;}else{


$basik = 0;
$ins ='';

if($user['pers']==1 and $user['amulet1']>4){ 



$basik = $user['defense'] * 30 / 100;
$basik = ceil($basik);

 $ins ='<span class=iLegendary>дополнительно + '.$basik.' силы , Эффект: Ярость Воина</span>'; }


$astor = $plazma * $user['ten'] / 100;


$astor = ceil($astor);
$astor = $astor+$basik;
$dbc->query('UPDATE `users` SET `am1_time` = "' .(time() + 60) . '",`dobav`=`dobav`+"'.$astor.'" WHERE `id` = ' . $user['id'] . '');


$maw = '<font color=green> Ты активировал Душа Теней (Сила +'.$astor.') '.$ins.'</font>'; 


$_SESSION['logi']="$maw"; header('location:battle.php');exit;}}











////// Плазма

	if(isset($_GET['plazm'])){
                if($user['am2_time'] > time()) { header('location:battle.php');exit;}else{


$dbc->query('UPDATE `users` SET `am2_time` = "' . (time() + 60) . '" WHERE `id` = "' . $user['id'] . '"');
$astor = $user['strength'] * $user['plazm'] / 100;

$astor = ceil($astor);
$astor = $astor+$plazma;
if($crit==1){$tali= $astor * 50 / 100; $tali = ceil($tali); $astor = $astor+$tali;$mess =' <font color=red>(крит)</font>';}
$in ='';
$sh = mt_rand(1,3);
if($user['pers']==2 and $user['amulet2']>4 and $sh==2){ 
$astor = $astor*2;
$in =' <span class=iLegendary>Сила удвоена, Эффект: Гнев Мага</span>';}


if ($astor >= $aluko['health']) {         dead_bos();
$sukm = '<font color=blueviovet> Лучи плазмы сожгли  '.$aluko[name].' '.$in.'</font>'; 



Oput($astor);
}else{


Oput($astor);
$dbc->query("UPDATE `monster` SET `health`=`health`-".$astor." WHERE `id`='".$aluko['id']."'");


$maw = '<font color=blueviolet> Лучи плазмы пронзили '.$aluko[name].'  раня на '.$astor.' '.$mess.' '.$in.'</font>';   $_SESSION['logi']="$maw";

$_SESSION['kesy']="-$astor";


?><span id="flashEnemyDamage"></span><?

 header('location:?');exit;}}}




include 'acss.php';


include 'css_bat.php';

$tes = $aluko['time']-time();
if(Sec2Time($tes)>0){ ?><center><span class="iLegendary">Монстр под защитой <?=Sec2Time($tes)?></span></center><? }



	


?><div class="combati">


<div class="combati-enemy">


<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td width="39" valign="top">
<div class="img-enemy">
<img src="/img/forest/<?=$aluko['img']?>.png" width="32" height="32" alt="."/></div>

</td>
<td valign="top">
<div class="name">
<b><?=$aluko['name']?>(<?=$cc?>%)</b> 

</div>
<div class="progress-hp _damaged">

<div class="hp-feel" style="width:<?=$cc?>%" id="hpFill"></div>

<div class="hp-health">
<span id="flashEnemyDamage" class="deltaEnemyDamage"><?=$aluko['health']?></span> <span class="va-m">/ <?=$aluko['max_health']?></span>


</div>
<div class="hp-damage flashEnemyDamage"><?=$_SESSION['kesy']?></div>



</div>
</td>
</tr>
</tbody>
</table>

</div><? 

/*


?><div class="combat-line"><a href="?jump" class="btn-aqua btn-potion"><img class="link-icon" src="/img/log/2.png" alt="" width="12" height="12"><span>Атаковать</span></a></div><?






If($am2_time <= 0){ ?><div class="combat-line"><a href="?plazm" class="btn-red"><img class="link-icon" src="/img/log/3.png" alt="" width="12" height="12"><span>Сияние Плазмы</span></a></div><?}else{?><div class="combat-line"><a href="/battle.php?plazm" class="btn-red inactive inactive25"><img class="link-icon"src="/img/log/3.png" alt="" width="12" height="12"><span>Сияние Плазмы</span>&nbsp;<span class="locked-time"><?=Sec2Time($am2_time)?></span></a></div><?}






If($am1_time <= 0){?><div class="combat-line"><a href="/battle.php?dusha" class="btn-red"><img class="link-icon" src="/img/log/4.png" alt="" width="12" height="12"><span>Душа Тени </span></a></div><?}else{?><div class="combat-line"><a href="/battle.php?dusha" class="btn-red inactive inactive25"><img class="link-icon" src="/img/log/4.png" alt="" width="12" height="12"><span>Душа Тени</ span>&nbsp;<span class="locked-time"><?=Sec2Time($am1_time)?></span></a></div><?}  If($apteka_time <= 0){?><div class="combat-line"><a href="/battle.php?el" class="btn-aqua btn-potion"><img class="link-icon" src="/img/log/5.png" alt="" width="12" height="12"><span>Зелье Здоровья(<?=$user['apteka']?>)</span></a></div><? }Else{ ?></div><div class="combat-line"><a href="/battle.php?el" class="btn-aqua inactive-skill inactive50"><img class="link-icon" src="/img/log/5.png" alt="" width="12" height="12"><span>Зелье Здоровья(<?=$user['apteka']?>)</span>&nbsp;<span class="locked-time"><?=Sec2Time($apteka_time)?></span></a></div><?}

*/




/*


?><div class="block item_center">

<a href="?jump">
<div id="weap_4" class="weap_container weap_4">
</span>
</div>
</a>
<?
?>
<a href="?dusha">
<div id="weap_1" class="weap_container weap_1">
<div class="weap_text">
<span name="weap" weapId="1" time="<?=$am1_time?>"><?=$am1_time?></span>
</div>
</div>
</a>
<?


?>

<a href="?plazm">
<div id="weap_2" class="weap_container weap_2">
<div class="weap_text">
<span name="weap" weapId="2" time="<?=$am2_time?>"><?=$am2_time?></span>
</div>
</div>
</a>
<? 


?>

<a href="?el">
<div id="weap_3" class="weap_container weap_3">
<div class="weap_text">
<span name="weap" weapId="3" time="<?=$apteka_time?>"><?=$apteka_time?></span>
</div>
</div>
</a>
<? 

?></div><? 
*/


?></div><?

?><div class="combat-line"><a href="?jump" class="btn-aqua btn-potion"><img class="link-icon" src="/img/log/2.png" alt="" width="12" height="12"><span>Атаковать</span></a></div><?

?></div><div class="l_belt">

<?

?><a class="belt_item" href="?dusha" title="Душа Тени">

<div class="belt_item_icn">






<div id="weap_1" class="weap_container weap_1"> 
<div class="weap_text">
<span name="weap" weapId="1" time="<?=$am1_time?>"><?=$am1_time?></span>
</div>
</div> 
</div>
</a>
<?

?><a class="belt_item" href="?plazm" title="Сияние Плазмы">



<div class="belt_item_icn">






<div id="weap_2" class="weap_container weap_2"> 
<div class="weap_text">
<span name="weap" weapId="2" time="<?=$am2_time?>"><?=$am2_time?></span>
</div>
</div> 
</div>
</a>




<a class="belt_item" href="?el" title=""Зелье Здоровья">


<div class="belt_item_icn">






<div id="weap_3" class="weap_container weap_3"> 
<div class="weap_text">
<span name="weap" weapId="3" time="<?=$apteka_time?>"><?=$apteka_time?></span>
</div>
</div> 
</div>
</a>







</div>

<?






if($user['s_pet']==1){?><div class="info-box"><font color=orange>Помощник</font>: <font color=grey><?=$pet['name']?></br></div><?}

if (isset($_SESSION['logi'])){?>

<div class="b-panel-new dblue-panel bordered mt2">
<div class="panel-inner-2"><?=$_SESSION['logi']?></div></div><?   $_SESSION['logi']=NULL; }



$_SESSION['kesy']=NULL;







if ($user['level'] <30) {  ?><span class="info">Усиление новичка : Сила в в лесу тьмы +200</span><? } 



	

































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

foot();

?><script src="styles/jss/weap.js"></script><? 

?><script src="/styles/jss/gg.js?v=1544436385300" type="text/javascript"></script><script type="text/javascript">

        $(document).ready(function() {
            damageMaxFlash("wqUHDEBlxTsRXFEW", 4000, "_flash-animation");
        });
    </script><?


?>
