<?php

//include_once 'core/class.php';

require_once 'core/system.php';








head('Лабиринт');




reg();

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









$tanki='';
















$weapon = $weapo;
if($user['id']==400){ $weapon = $weapon+5000;}




$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;}






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();
$am2_time = $user['am2_time'] -time();
$apteka_time = $user['apteka_t'] -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 * FROM `lab` WHERE `user`='".$user['id']."' LIMIT 1")->fetch_assoc();


$sila = 200*$aluko['etap'];
$def = 100*$aluko['etap'];

$yra = $aluko['yra'] -time();
$exp = $aluko['exp'] -time();

$sinb = $aluko['time'] -time();



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



if ($aluko['yra'] > time()) { 

$goo = 2;}else{ $goo= 1;}


if ($aluko['exp'] > time()) { 

$gos = 2;}else{ $gos= 1;}



if(!$aluko){



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


if(Sec2Time($sinb)<=0){ header('location:lab.php?ex');}




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


$beb = 300*$aluko['etap'];

$u2 = $aluko['etap'];

$dbc->query("UPDATE `users` SET `serebro` = `serebro`+'".$beb."',`rub`=`rub`+'".$u2."' WHERE `id` = '" . $user['id'] . "'");


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

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


$_SESSION['message']=' Сражение в Лабиринте Окончено. Ваша награда<img src=img/stat/sera.png>'.$beb.' ';


if($aluko['etap']>3){



























$osada=$dbc->query("SELECT * FROM `osada` where `id`= 1 ")->fetch_assoc();   
$guli=$dbc->query("SELECT * FROM `clan` where `id`= '".$osada['clan_lord']."' ")->fetch_assoc(); 

if($guli){   
$dbc->query("UPDATE `clan` SET `kazna`=`kazna`+1 , `sobr`=`sobr`+1 WHERE `id`='".$guli['id']."'"); 







$_SESSION['fos']='Клан  '.$guli['name'].' получает <img src=img/money/money.png>1 '; 





}}  





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


}





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


$wowi = array('Заблудший Стражник','Ключник',' Призрак Стражника','Лорд Алтаир');
shuffle($wowi);
$ben = 5000*$aluko['etap'];



$dbc->query("UPDATE `lab` SET `health`='".$ben."',`max_health`='".$ben."',`etap`=`etap`+1, `name`='".$wowi[0]."' WHERE `user`='".$user['id']."'");


$tr  = mt_rand(1,5);


if($tr==1){


$dbc->query("UPDATE `lab` SET `yra` = '" .(time() + 60) . " ' WHERE `user` = '" . $user['id'] . "'");


$mini = '<span class=info> Вы Нашли Свиток Ярости</span>'; 
$_SESSION['logi']="$mini";

}

if($tr==2){


$dbc->query("UPDATE `lab` SET `exp` = '" .(time() + 60) . " ' WHERE `user` = '" . $user['id'] . "'");


$mini = '<span class=info> Вы Нашли Свиток Мудрости Предков</span>'; 
$_SESSION['logi']="$mini";
}

if($tr==3){


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



$mini = '<span class=info> Вы нашли <img src="img/stat/sera.png">500</span>'; 

$_SESSION['logi']="$mini";
}


if($tr==4){


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



$mini = '<span class=info> Вы нашли <img src="img/stat/sera.png">1000</span>'; 

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

}

if($tr==5){


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



$mini = '<span class=info> Вы нашли <img src="img/stat/sera.png">1500</span>'; 

$_SESSION['logi']="$mini";
} 



























    

            






                













                








































                
                











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


}




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



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

 $_SESSION['logi']="$loki";  header('location:lab.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:lab.php');exit;}}






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

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



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

$_SESSION['logi']="$loki"; header('location:lab.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] . '"'); }


$vi ='';
$re = $weapon;
$re = $re - $def;

$weapon = ($re>0) ? $re : 1;

$wep = $weapon*$goo;



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

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


$weapon = $weapon*$goo;



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

Oput($weapon*$gos);

dead_bos(); }
else{
$dbc->query("UPDATE `lab` 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.''; }







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*$gos);



$mob_udar = mt_rand(1,2);


$tf = $sila; 



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





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:lab.php?ex');exit();

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

}

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





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



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


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

 if($user['am1_time'] > time()) {  header('location:lab.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);
$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:lab.php');exit;}}











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

    if(isset($_GET['plazm'])){
                if($user['am2_time'] > time()) { header('location:lab.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>';}

$astor = $astor*$goo;

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



Oput($astor*$gos);

}else{


Oput($astor*$gos);

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


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






$tes = $aluko['time']-time();
if(Sec2Time($tes)>0){ ?><center><span class="iLegendary">Сражение Закончится через <?=Sec2Time($tes)?></span></center><? }




?><center><span class="info">Этап <?=$aluko['etap']?></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/at/pac.png" width="32" height="32" alt="."/></div>

</td>
<td valign="top">
<div class="name">
<b><?=$aluko['name']?></b> 
</div>
<div class="progress-hp">
<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"></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="/lab.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="/lab.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="/lab.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="/lab.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="/lab.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><?}



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; }









    












                if ($aluko['yra'] > time()) {  ?><span class="info">Свиток Ярости : Атака в лабиринте +100%</span>(<?=Sec2Time($yra)?>)<? } 




                if ($aluko['exp'] > time()) {  ?><span class="info">Свиток Мудрости Предков : Опыт в лабиринте +100%</span>(<?=Sec2Time($exp)?>)<? } 

















?></div></div><?
foot();
?>

