<?
require_once ('system/func.php');
auth(); // Закроем от гостей
$title = ' Приключение';


$boss_user = mysql_query("SELECT * FROM `boss_user` WHERE `id_user` = '".$myID."' ORDER BY `id` LIMIT 1");
$boss_user = mysql_fetch_array($boss_user);

$ability = mysql_query("SELECT * FROM `ability` WHERE `id_user` = '".$myID."' ORDER BY `id` LIMIT 1");
$ability = mysql_fetch_array($ability);



//Если нету игрока в приключениях
if(!$boss_user){
mysql_query("INSERT INTO `boss_user` SET `id_user` = '$myID', `id_boss` = '1'");
header('Location: ?');
exit();
}
switch($_GET['act']){
case 'batlle':
$batlle = mysql_query("SELECT * FROM `boss_batlle` WHERE `id_user` = '".$myID."' ORDER BY `id` DESC LIMIT 1");
$batlle = mysql_fetch_array($batlle);
if($batlle['user_health'] > $user['max_health'] + $ClassHp) $batlle['user_health'] = $user['max_health'] + $ClassHp;


if($boss_user['last'] > time()){
header('Location: /adventure/');
exit();
}
if(!$batlle){
header('Location: /adventure/');
exit();
}
$boss = mysql_query("SELECT * FROM `boss` WHERE `id` = '".$user['adventure_id']."' ORDER BY `id` LIMIT 1");
$boss = mysql_fetch_array($boss);
$title = 'Бой с '.$boss['name'];
require_once ('system/head.php');
//Выход с боя
if(isset($_GET['exit'])){
mysql_query("DELETE FORM `boss_batlle` WHERE `id` = '".$batlle['id']."' LIMIT 1");
mysql_query("update `boss_user` set `last` = '".(time()+60*10* $user[adventure_id])."' where (`id_user` = '".$myID."')");
header('Location: /adventure/');
exit();
}

if($boss_user['kol'] <= 0 ){
mysql_query("UPDATE `boss_user` SET  `kol`='3' WHERE `id_user`='".$myID."' LIMIT 1");
mysql_query("update `boss_user` set `last` = '".(time()+60*10* $user[adventure_id])."' where (`id_user` = '".$myID."')");
}
if($boss_user['win_kol'] >= 5 ){
mysql_query("update `users` set    `adventure_id` = '".($user['adventure_id']+ 1 )."'  where (`id` = '".$myID."')");
mysql_query("UPDATE `boss_user` SET  `win_kol`='0' WHERE `id_user`='".$myID."' LIMIT 1");
}
$_str_opp =ceil(($boss['str']/3 + ($boss_user['win_kol'] +1 ) / 10000000000) - ($user['def'] /4)) ;
$_str = ceil(($user['str']/3) - (($boss['def'] /4 + ($boss_user['win_kol'] +1 ) / 10000000000))) ;


if($_str_opp < 0)$_str_opp = 1;
if($boss_user['win_kol'] >= 1  ){
$_str_opp = ceil($_str_opp + ($boss_user['win_kol'] +1  / 10000000000));



}
$c = 15;
$r = rand(1,100);
if($r <= $c){
    $crit =true;
    $_str *=2;
    
}
if($ability['statusDef']== 1 )
$_str_opp  = ceil($_str_opp - ($ability[spellDefAbsorb] + ($user['def'] /20)));
if($ability['statusStr']== 1 )
$SpellStr = ceil($_str + ($ability[spellStrDmg] + ($user['str'] /15)) );

$_str +=$SpellStr;


//Умения  Сила жизни
if(isset($_GET['UseSpellHp']) and $ability['statusHp'] == 0  and  $ability['energy'] >= 1) {
    //Если юзали и меньше энергии
   if($ability['statusHp'] == 1 and  $ability['energy'] <= 1){
   header('Location: /adventure/batlle/?attack');
    exit();

    }
$SpellRespHp =  ceil($ability[spellHpResp] + ($user['max_health'] /100 * 10));

$logSpellHp = color('lime').' Вы полечились  на  '.ico('ability','spell_health.png').' '.$SpellRespHp.' здоровья </font>';
mysql_query("update `boss_batlle` set    `user_health` = '".($batlle['user_health']+ $SpellRespHp )."' where (`id_user` = '".$myID."')");
mysql_query("update `ability` set    `energy` = '".($ability['energy'] - 1 )."'  ,  `statusHp` = '1'   where (`id_user` = '".$myID."')");


mysql_query ("INSERT INTO `boss_batlle_log` SET  `tip` = 'user', `id_batlle` = '$batlle[id]' , `text` = '$logSpellHp'");


header('Location: /adventure/batlle/');
exit();


}
//Умения  Крепкая броня
if(isset($_GET['UseSpellDef']) and $ability['statusDef'] == 0  and  $ability['energy'] >= 1) {
    //Если юзали и меньше энергии
   if($ability['statusDef'] == 1 and  $ability['energy'] <= 1){
   header('Location: /adventure/batlle/?attack');
    exit();

    }
$spellDef = ceil($ability[spellDefAbsorb] + ($user['def'] /20));

$logSpellDef = color('lime').' Вы уменьшили урон   на  '.ico('ability','spell_defence.png').' '.$spellDef.' урона </font>';
mysql_query("update `ability` set    `energy` = '".($ability['energy'] - 1 )."'  ,  `statusDef` = '1'   where (`id_user` = '".$myID."')");
mysql_query ("INSERT INTO `boss_batlle_log` SET  `tip` = 'user', `id_batlle` = '$batlle[id]' , `text` = '$logSpellDef'");


header('Location: /adventure/batlle/');
exit();


}

//Умения  Крепкая броня
if(isset($_GET['UseSpellStr']) and $ability['statusStr'] == 0  and  $ability['energy'] >= 1) {
    //Если юзали и меньше энергии
   if($ability['statusStr'] == 1 and  $ability['energy'] <= 1){
   header('Location: /adventure/batlle/?attack');
    exit();

    }
$spellStr = ceil($ability[spellStrDmg] + ($user['str'] /15));

$logSpellStr= color('orange').' Вы увеличили урон   на  '.ico('ability','double_attack.jpg').' '.$spellStr.'  </font>';
mysql_query("update `ability` set    `energy` = '".($ability['energy'] - 1 )."'  ,  `statusStr` = '1'   where (`id_user` = '".$myID."')");
mysql_query ("INSERT INTO `boss_batlle_log` SET  `tip` = 'user', `id_batlle` = '$batlle[id]' , `text` = '$logSpellStr'");


header('Location: /adventure/batlle/');
exit();


}

if($_str < 0)$_str = 1;
if($_str_opp < 0)$_str_opp = 1;

if(isset($_GET['attack']) and $batlle['udar_last'] < time()) {

if( $_str > $batlle['boss_health'] ){
$gold = 100;
$exp = ceil(rand ($boss['min_exp'],$boss['max_exp']) /2);
//Еффект
if($effect_2['on'] == 1)$exp = $exp+ceil($exp*25/100);
if($auction['name'] == 2)$exp = ceil($exp*2);
if($auction['name'] == 2)$gold =ceil($gold*2);
mysql_query("update `users` set `exp` = '".($user['exp']+$exp)."',   `gold` = '".($user['gold']+ 100)."'  where (`id` = '".$myID."')");
$quest = mysql_fetch_assoc(mysql_query("SELECT * FROM `quest` WHERE `id` = '3'"));
$q = mysql_fetch_assoc(mysql_query("SELECT * FROM `quest_user` WHERE `id_quest` = '$quest[id]' AND `id_user` = '$myID'"));
if($q['last'] < time())mysql_query("update `quest_user` set `koll` = `koll`+'0' where (`id` = '".$q['id']."')");

if($user['clan_rang'] > 0){
mysql_query("UPDATE `users` SET `clan_exp` = '".($user['clan_exp']+ceil($exp* $user[trust]/100))."' WHERE `id` = '".$myID."' LIMIT 1");
mysql_query("UPDATE `clans` SET `exp` = `exp` + '".ceil($exp* $user[trust] /100)."' WHERE `id` = '".$user['id_clan']."' LIMIT 1");
mysql_query("UPDATE `users` SET `ResetClanExp` = `ResetClanExp` + '".ceil($exp* $user[trust] /100)."' WHERE `id` = '".$myID."' LIMIT 1");

}
//Задание
mysql_query("UPDATE `boss_user` SET  `win_kol` =  `win_kol`  + '1' WHERE `id_user`='".$myID."' LIMIT 1");
$quest = mysql_fetch_assoc(mysql_query("SELECT * FROM `quest` WHERE `id` = '3'"));
$q = mysql_fetch_assoc(mysql_query("SELECT * FROM `quest_user` WHERE `id_quest` = '$quest[id]' AND `id_user` = '$myID'"));
if($q['last'] < time())mysql_query("update `quest_user` set `koll` = `koll`+'1' where (`id` = '".$q['id']."')");

mysql_query("DELETE FORM `boss_batlle` WHERE `id` = '".$batlle['id']."' LIMIT 1");
if($boss_user['win_kol'] == 5 ){
mysql_query("update `users` set    `adventure_id` = '".($user['adventure_id']+ 1 )."'  where (`id` = '".$myID."')");
mysql_query("UPDATE `boss_user` SET  `win_kol`='0' WHERE `id_user`='".$myID."' LIMIT 1");
}
mysql_query("DELETE FROM `boss_batlle_log` WHERE `id` = '".$batlle['id']."' ");

mysql_query("update `ability` set    `energy` = '0'  ,  `statusHp` = '0'  ,  `statusDef` = '0' ,  `statusStr` = '0'  where (`id_user` = '".$myID."')");



  $_SESSION['msg']= color('lime')."Вы победили!</font><br> ".color('grey')."Награда:<br></font>".ico('icons','gold.png')."100 золота и  ".ico('icons','exp.png')." $exp опыта<br</div></font>";
   // Выпадение сундука   
                $ChanseSunduk = 20;    
                if(rand(1,100) <= $ChanseSunduk ){ 
                    $r= rand(1,100);     if($r > 0  and $r <= 5 ){ 
                        $SundukQuatility = 5;   
                        $SundukLvl =  20;   
                        }else if ($r >= 5  and $r <= 10 ){    
                            $SundukQuatility = 4;     
                            $SundukLvl =  15;     
                            }else if ($r >= 10  and $r <= 20 ){   
                                $SundukQuatility = 3;     
                                $SundukLvl =  10;   
                                }else if ($r >= 20  and $r <= 30 ){    
                                    
                                    $SundukQuatility = 3;   
                                $SundukLvl =  10;      }else if ($r >= 30  and $r <= 55 ){    
                                    $SundukQuatility = 2;     
                                    $SundukLvl =  5;    
                                    }else if ($r >= 55  and $r <= 100 ){     
                                        $SundukQuatility = 1; 
                                    $SundukLvl =  1;  
                                    }    
                                    
                                    
                                    switch( $SundukQuatility){ 
                                    case '1': $color = '<font color="green">Обычный';
                                    break;
                                    case '2': $color = '<font color="#1E90FF">Редкий';
                                    break;
                                    case '3': $color = '<font color="violet">Эпический';
                                    break; 
                                    case '4': $color = '<font color="gold"> Уникальный';
                                    break;
                                    case '5': $color = '<font color="Darkorange">Легендарный ';
                                    break;
                                    }     
                                    mysql_query("INSERT INTO `sunduk_user` SET `id_user` = '".($user['id'])."' , `lvl` = '$SundukLvl', `quatility` = '$SundukQuatility', `status` = 'close'") or die(mysql_error());   
                                    $_SESSION['sunduk']= div('header')." Вы получили сундук $color </font><br><img src=' /images/other/chest.png' width='100px'> </div> ";                   
            }
            
            
//if(rand(1,100) <= '50' ){
    
//$item = mysql_fetch_assoc(mysql_query("SELECT * FROM `item` WHERE `level` < 10 ORDER BY RAND() "));




//mysql_query("INSERT INTO `inv` SET `id_user` = '".($user['id'])."', `name` = '$item[name]', `str` = '$item[str]', `def` = '$item[def]', `health` = '$item[health]', `tip` = '$item[tip]', `skill` = '$item[skill]',  `level` = '$item[level]', `odeta` = 'net' , `item` = '$item[item]'")or die(mysql_error());
//$log = 'получил '.$item[name].'';
//$_SESSION['item']= "<div style = 'text-align:center;'><font color=#bce4f4>$item[name]</font> $status<br><img src='/images/items/$item[tip]/$item[item].png'>
//</div>";
//}
header('Location: /adventure/');
exit();


}elseif($_str_opp > $batlle['user_health'] ){
$exp = ceil(rand($boss['min_exp'],$boss['max_exp'])/3 );
//Эффект
if($effect_2['on'] == 1)$exp = $exp+ceil($exp*25/100);

$gold = ceil(rand($boss['min_gold'],$boss['max_gold'])/ 400);
if($auction['name'] == 2)$exp = ceil($exp*2);
if($auction['name'] == 2)$gold =ceil($gold*2);

mysql_query("update `users` set 
`exp` = '".($user['exp']+$exp)."', 
`gold` = '".($user['gold']+$gold)."'
where (`id` = '".$myID."')");
    //Задание 
$quest = mysql_fetch_assoc(mysql_query("SELECT * FROM `quest` WHERE `id` = '3'"));
$q = mysql_fetch_assoc(mysql_query("SELECT * FROM `quest_user` WHERE `id_quest` = '$quest[id]' AND `id_user` = '$myID'"));
if($q['last'] < time())mysql_query("update `quest_user` set `koll` = `koll`+'1' where (`id` = '".$q['id']."')");
//Опыт клану 
if($user['clan_rang'] > 0){

mysql_query("UPDATE `users` SET `clan_exp` = '".($user['clan_exp']+ceil($exp* $user[trust]/100))."' WHERE `id` = '".$myID."' LIMIT 1");
mysql_query("UPDATE `clans` SET `exp` = `exp` + '".ceil($exp* $user[trust] /100)."' WHERE `id` = '".$user['id_clan']."' LIMIT 1");
mysql_query("UPDATE `users` SET `ResetClanExp` = `ResetClanExp` + '".ceil($exp* $user[trust] /100)."' WHERE `id` = '".$myID."' LIMIT 1");

}


mysql_query("update `ability` set    `energy` = '0'  ,  `statusHp` = '0' ,  `statusDef` = '0' ,  `statusStr` = '0'   where (`id_user` = '".$myID."')");


mysql_query("UPDATE `boss_user` SET  `kol` =  `kol`  - '1' WHERE `id_user`='".$myID."' LIMIT 1");
mysql_query("DELETE FROM `boss_batlle_log` WHERE `id` = '".$batlle['id']."' ");
$_SESSION['msg']= color('tomato')."".div('block_c')."Вы отступили!<br>Возвращайтесь когда станете сильнее</font><br>".color('grey')."Награда:<br></font>".ico('icons','gold.png')." $gold золота и  ".ico('icons','exp.png')." $exp опыта<br></font>";
 // Выпадение сундука   
                $ChanseSunduk = 15;    
                if(rand(1,100) <= $ChanseSunduk ){ 
                    $r= rand(1,100);     if($r > 0  and $r <= 5 ){ 
                        $SundukQuatility = 5;   
                        $SundukLvl =  20;   
                        }else if ($r >= 5  and $r <= 10 ){    
                            $SundukQuatility = 4;     
                            $SundukLvl =  15;     
                            }else if ($r >= 10  and $r <= 20 ){   
                                $SundukQuatility = 3;     
                                $SundukLvl =  10;   
                                }else if ($r >= 20  and $r <= 30 ){    
                                    
                                    $SundukQuatility = 3;   
                                $SundukLvl =  5;      }else if ($r >= 30  and $r <= 55 ){    
                                    $SundukQuatility = 2;     
                                    $SundukLvl =  5;    
                                    }else if ($r >= 55  and $r <= 100 ){     
                                        $SundukQuatility = 1; 
                                    $SundukLvl =  1;  
                                    }    
                                    
                                    switch( $SundukQuatility){ 
                                    case '1': $color = '<font color="green">Обычный';
                                    break;
                                    case '2': $color = '<font color="#1E90FF">Редкий';
                                    break;
                                    case '3': $color = '<font color="violet">Эпический';
                                    break; 
                                    case '4': $color = '<font color="gold"> Уникальный';
                                    break;
                                    case '5': $color = '<font color="Darkorange">Легендарный ';
                                    break;
                                    }     
                                    mysql_query("INSERT INTO `sunduk_user` SET `id_user` = '".($user['id'])."' , `lvl` = '$SundukLvl', `quatility` = '$SundukQuatility', `status` = 'close'") or die(mysql_error());   
                                    $_SESSION['sunduk']= div('header')." Вы получили сундук $color </font><br><img src=' /images/other/chest.png' width='100px'> </div> ";                   
            }
        
//if(rand(1,100) <= '30' ){
    
//$item = mysql_fetch_assoc(mysql_query("SELECT * FROM `item` WHERE `level` < 10 ORDER BY RAND() "));


//mysql_query("INSERT INTO `inv` SET `id_user` = '".($user['id'])."', `name` = '$item[name]', `str` = '$item[str]', `def` = '$item[def]', `health` = '$item[health]', `tip` = '$item[tip]', `skill` = '$item[skill]',  `level` = '$item[level]', `odeta` = 'net' , `item` = '$item[item]'")or die(mysql_error());
//$log = 'получил '.$item[name].'';
        //mysql_query('INSERT INTO `duel_log` ( `user`, `text` , `login`) VALUES ("'.$user['id'].'", "'.$log.'" , "'.$user['login'].'")');
        
//$_SESSION['item']= "<div style = 'text-align:center;'><font color=#bce4f4>$item[name]</font>$status<br><img src='/images/items/$item[tip]/$item[item].png'><br></div>";
//}
header('Location: /adventure/');
exit;


}else{

$user_log = color('lime').'Вы </font> ударили '.color('tomato').''.$boss[name].'</font> под '.$_str.'  '.($crit == true ? '(крит)':'</font>');
$boss_log = color('tomato').' '.$boss[name].' </font> ударил '.color('lime').' Вас</font> под '.$_str_opp.'';
mysql_query("update `ability` set    `energy` = '".($ability['energy'] + 1 )."'     where (`id_user` = '".$myID."')");


mysql_query("INSERT INTO `boss_batlle_log` SET `uron_boss` = '$_str_opp',  `tip` = 'boss', `id_batlle` = '$batlle[id]' , `boss_text` = '$boss_log'");
mysql_query("INSERT INTO `boss_batlle_log` SET `uron_user` = '$_str',  `tip` = 'user', `id_batlle` = '$batlle[id]' , `text` = '$user_log'");
mysql_query("update `boss_batlle` set `boss_health` = '".($batlle['boss_health']-$_str)."', `user_health` = '".($batlle['user_health']-$_str_opp)."', `udar_last` = '".(time()+0)."' where (`id` = '".$batlle['id']."')");
header('Location: /adventure/batlle/?attack');
exit();

}
}


//$progress2 = round($batlle['boss_health']/$boss['max_health']*100,1);
//if($progress2 > 10000000000)$progress2= 10000000000;
//if($boss_user['win_kol'] >= 1  )
$percent_str = ceil($boss['str'] * ($boss_user['win_kol'] +1 ) / 10000000000);
$percent_def = ceil($boss['str'] * ($boss_user['win_kol'] +1 ) / 10000000000);
$boss_str = ($boss['str']) +$percent_str;
$boss_def =$boss['def'] + $percent_def;

$UserHp=round($batlle['user_health'] /($user['max_health']+ $ClassHp)*100,1);

echo "<div class='block_l'>";
echo ' <img style="background: radial-gradient(ellipse at left,#313131 0%,#000 100%);" width="70px" height="70px" class="round" src="/images/adventure/'.$user[adventure_id].'.jpg">  ';

echo "".ico('icons','str.png')."  $boss_str  ".ico('icons','def.png')." $boss_def  ".ico('icons','health.png')." $batlle[boss_health]</center>";

echo '<div class="life_bar"><div class="life_bar-red" style="width:'.$progress2.'% "></div></div>';
echo "</div>";
if($ability){

if($batlle['user_health'] > 0  and $batlle['boss_health'] >  0 ){
 echo div('foot');

echo "<table style='width:100%;'>";
echo "<td class='center'> <a href='?attack'>".img('ability','spell_attack.png')."</a></td>";
if($ability['statusHp'] == 1 or  $ability['energy'] <1 )
echo " <td class='center'><a href='?'>".spell('ability','spell_health.png ')."</a></td>";
else
echo " <td class='center'><a href='?UseSpellHp'>".img('ability','spell_health.png ')."</a></td>";


if($ability['statusDef'] == 1 or  $ability['energy'] <1 )
echo "<td class='center'> <a href='?'>".spell('ability','spell_defence.png ')."</a></td>";
else
echo " <td class='center'><a href='?UseSpellDef'>".img('ability','spell_defence.png ')."</a></td>";



if($ability['statusStr'] == 1 or  $ability['energy'] <1 )
echo " <td class='center'><a href='?'>".spell('ability','double_attack.jpg ')."</a></td>";
else
echo " <td class='center'><a href='?UseSpellStr'>".img('ability','double_attack.jpg ')."</a</td>";


echo "</div></div></table>";


}else
echo "<div class='header'><a class='seach' href='/adventure/'> Закончить бой</a></div>";


}else{
    

if($batlle['user_health'] > 0  and $batlle['boss_health'] >  0 )
echo "<div class='header'><a href='?attack'>".img('ability','spell_attack.png')."</a></div>";
else
echo "<div class='header'><a class='seach' href='/adventure/'> Закончить бой</a></div>";
echo "</div>";

}


$img_avatar  = "<img src='/images/avatar/$user[sex]/$user[avatar].jpg'>";
echo div('block_l')." ".div('oh')." ".ava($user)." </div>
".color('lime')."Вы</font><br>".ico('icons','str.png')." ".($user['str'] + $ClassStr)."".ico('icons','health.png')." 
 $batlle[user_health]  ".ico('icons','def.png')." ".($user['def'] + $ClassDef)."<br><br>";
 echo '<div class="life_bar"><div class="life_bar-green" style="width:'.$UserHp.'% "><br></div></div></div>';

        


$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `boss_batlle_log` WHERE `id_batlle` = '$batlle[id]'"),0);
$q = mysql_query("SELECT * FROM `boss_batlle_log` WHERE `id_batlle` = '$batlle[id]' ORDER BY `id` DESC LIMIT 15");
    echo div('wrapper');

while($post = mysql_fetch_assoc($q)){

if($post['tip'] == 'user'){
echo "".$post[text]." <br> ";

}else{
if($post['uron_boss'] >= 0)echo "".$post[boss_text]."<br>";
else echo "<font color='red'>$boss[name] промахнулся</font><br>";
}
}




break;

default:
require_once ('system/header.php');

$boss = mysql_query("SELECT * FROM `boss` WHERE `id` = '".$user['adventure_id']."' ORDER BY `id` LIMIT 1");
$boss = mysql_fetch_array($boss);
if(isset($_GET['go']) and $boss_user['last'] < time() and $user['level'] >= 1){
    $percent_hp = ceil($boss['max_health'] * ($boss_user['win_kol'] +1 ) / 10000000000);

$boss_health = $boss['max_health'] +$percent_hp;



         
//Кампания
if($campaign['id_camp'] == 2)
mysql_query("UPDATE `campaign`  SET  `adventure`='".($campaign['adventure'] + 1)."'  WHERE `id_user`='".$myID."'");



$hp = $user['max_health'] + $ClassHp;

mysql_query("INSERT INTO `boss_batlle` SET `id_user` = '$myID', `id_boss` = '$boss[id]', `boss_health` = '$boss_health', `user_health` = '$hp'");
mysql_query("update `boss_user` set `Time_end` = '".(time()+60)."' where (`id_user` = '".$myID."')");

header('Location: /adventure/batlle/');
exit();
}
if($user['level'] >= 1){
if($boss){

#### Приключение #####
$batlle = mysql_query("SELECT * FROM `boss_batlle` WHERE `id_user` = '".$myID."' ORDER BY `id` DESC LIMIT 1");
$batlle = mysql_fetch_array($batlle);
$boss = mysql_query("SELECT * FROM `boss` WHERE `id` = '".$user['adventure_id']."' ORDER BY `id` LIMIT 1");
$boss = mysql_fetch_array($boss);
$boss_user = mysql_query("SELECT * FROM `boss_user` WHERE `id_user` = '".$myID."' ORDER BY `id` LIMIT 1");
$boss_user = mysql_fetch_array($boss_user);
$boss_stat = $boss['str'] + $boss['def'] + $boss['max_health'];
$user_stat = $user['str'] + $user['def'] + $user['max_health'];
if($boss_stat > $user_stat )
$complexity= color('red')."тяжело";
else
$complexity= color('lime')."легко";
$round= round($boss_user['win_kol'] /  5 * 100,1);
if($round > 100)$round = 100;
echo div('header').' <span class="ribbon red  w75"><span class="r_end"><span class="r_cntr"> '.$boss[name].'</span></span></span>';

echo " <img $style src='/images/adventure/$user[adventure_id].jpg' ></div>";
echo  color('tomato')."  ".div('header')."<div class='reward_progress'><div class='yellow' style='width:".$round."%;'></div></div>
<span class='grey'><center>Сложность:</span>$complexity</font> <br>   ";


if($boss_user['last'] < time())
{
    echo "<div class='cbtn green mt2 w50'><span class='cb_end'><span class='cb_ttl'> <a href='/adventure/?go' > Сразиться<//div></span></span></a>";

}else{
    


$almaz = 15;

if(isset($_GET['resp']))
{
    
    if ($user['almaz'] < $almaz)
    {
        
    
    $_SESSION['msg'] = " Недостаточно алмазов ";
    
    }else{
        $_SESSION['msg'] = " Вы ускорили ожидание  и потратили  ".ico('icons', 'almaz.png')." $almaz";

mysql_query("UPDATE `boss_user` SET  `last`='0' , `kol`='3' WHERE `id_user`='".$myID."' LIMIT 1");
mysql_query("UPDATE `users` SET    `almaz` = '".($user['almaz']  - $almaz )."' WHERE `id` = '".$user['id']."'");
header('Location: /adventure/');
exit();


    }
    
}



echo " <span class='grey'>Следующий бой через:".ico('icons','time.png')."</span> ".tl($boss_user['last']-time())." <br>   <a href = '?resp'> <div class='cbtn blue mt2 w35'><span class='cb_end'><span class='cb_ttl'>  Ускорить  ".ico('icons', 'almaz.png')." $almaz</div></span></span> <a/></li>";
}
echo "</div>";
}else{
echo "<div class='block_c'>Все боссы повержены! Поздравляем, ты получил <b>Достижение</b>".ico('icons','dost.png')."</div>";
}
echo "</div>";
  }else{
echo "<div class='block center'>Тёмный лес доступен только с 10 уровня!</div>";
}
require_once ('system/footer.php');
break;
}
?>