<?php
include_once ('./core/base.php');
falseauth();
include_once ('./core/head.php');
//echo 'Обучение';

//Если обучние пройдено
if($u['training_step'] == 0){
	$_SESSION['message'] = 'Обучение уже пройдено.';
	header('Location: /');
	exit;
}

$next = fl($_GET['next']);
$move = fl($_GET['move']);
$step = fl($_GET['step']);

if($next == 'ok'){
	$base -> query('UPDATE `users` SET `training_step` = `training_step`+"1" WHERE `id` = "'.$u['id'].'"');
	header('Location: /training/'.($u['training_step']+1).'/');
	exit;
}
if($move == 'ok' AND $u['training_location'] < 20 AND $u['training_location'] != 14){
	$base -> query('UPDATE `users` SET `training_location` = `training_location`+"1" WHERE `id` = "'.$u['id'].'"');
	header('Location: /training/'.$u['training_step'].'/');
	exit;
}
if($step != $u['training_step'] AND $u['training_step'] != 0){
	header('Location: /training/'.$u['training_step'].'/');
	exit;
}

if($u['sex'] == 1) $sex = 27;
else $sex = 28;

switch ($step) {

default:

break;

case '1':

//Хэдер
echo '<body><div class="page"><div class="sticky_header"><table width="100%" class="a_table a_table-common" style="border-collapse: collapse;"><tr><td width="45%">';
echo '<div class="exp" style="background-size: 99% 12px; text-shadow: black 0 1px 0;"><font size="1">EXP: 99% <div style="float: right;">LV:99</div></font></div>';
echo '<div class="hp" style="background-size: 100% 12px; text-shadow: black 0 1px 0;"><font size="1">HP: 10K/10K</font></div>';
echo '<div class="mp" style="background-size: 100% 12px; text-shadow: black 0 1px 0;"><font size="1">MP: 10К/10К</font></div>';
echo '</td><td width="19%" valign="top"><div style="text-shadow: black 0 1px 0;"><a href="/gold/"><img src="/images/icons/silver.png"  width="16px"><font size="2">10M</font></a><br/>';
echo '<a href="/gold/"><img src="/images/icons/gold.png" width="16px"><font color="gold" size="2">10M</font></a>';
echo '</div></td><td width="36%" align="right" valign="top"><a class="btn_smallest" href="https://vk.com/avalormobi"><img src="/images/vk.png" width="20px"></a><a class="btn_smallest" href="https://t.me/joinchat/AAAAAFXi5EIjuCJfSiMxsg"><img src="/images/telegram.png" width="20px"></a><a class="btn_smallest" href="/fresh_news/"><img src="/images/icons/bell.png" width="20px"></a><a class="btn_smallest" href="/mail/"><img src="/images/icons/mail.png" width="20px"></a><br/><font style="float: right; font-size: 11px; color: #9090A1; text-shadow: black 0 1px 0;">BETA</font></td></tr></table></div>';
//Битва
echo '<div class="body"><div class="border" style="position: relative; margin-top: 5px; box-sizing: border-box;"><div style="width: 100%; max-width: 336px; height: 248px; background: url(/images/locations/backgrounds/lava_cave.png) no-repeat center;">';
//Указатель
echo '<div style="position: absolute; bottom: -5%; right: -3%; z-index: 9999;"><a href="/training/next/"><img src="/images/cursor.gif"></a></div>';
echo '<table width="100%" height="22%" style="font-size: 11px; text-shadow: black 1px 1px 1px; color: white;"><tr>';
//echo '<td width="50%" valign="top"></td>';
//Речь наставника
echo '<td width="100%" valign="top"><div class="fast_log"><table><tr><td><img src="/images/npcs/haming.png" width="36px"></td><td valign="top"><small><font color="#E0E0E0">Нажми на иконку меча или на монстра!</small></font></td></tr></table></div>';
//Поле боя
echo '</td></tr></table>';
echo '<table width="100%" height="78%" style="position: relative;"><tr><td width="50%"><center><div style="position: absolute; bottom: 35%; left: 10%; width: 35%;">';
echo '<font style="text-shadow: black 1px 1px 1px; color: #FFFFFF; font-size: 12px;">'.$u['login'].'</font><br/>
<div class="hp_small" style="background-size: 100% 2px;"></div><br/>
<div class="mp_small" style="background-size: 100% 2px;"></div><br/><img src="/images/skins/'.$sex.'_right.gif"></div><center></td>';
echo '<td width="50%" style="position: relative;"><center><small><font style="text-shadow: black 1px 1px 1px; color: #FFFFFF;">Фобос</font></small><br/><a href="/training/next/"><img style="max-height: 120px;" src="/images/mobs/bosses/fobos.gif"></a></center>
<center><div class="hp" style="width: 75%; background-size: 100% 12px; text-shadow: black 0 1px 0; text-align: left;"><font color="#E0E0E0" size="1">HP: 10К/10К</font></div></center><br/><br/>';
echo '<div style="position: absolute; bottom: 0.5%; right: 0.5%;"><a href="/training/next/"><img  src="/images/items/training_sword.png" style="border: 1px solid #DD4FFF;" width="42px"></a></div></td></tr></table></div></div>';
//Пояс и умения
echo '<center><table style="width: 100%; max-width: 303px;" cellspacing="3px"><tr><td class="event" width="50%"><div class="potion" style="width: 42px; height: 42px; border: 1px solid #B1B1B1;"><div style="background: url(/images/items/resource/hp_500.png) no-repeat center; background-size: 100%; display: inline-block; width: 42; height: 42px;">
	<div style="padding-top: 70%; padding-right: 3px;"><font style="text-shadow: black 1px 1px 1px; color: #e0e0e0; font-size: 10px; float: right;">99</font></div></div></div>';
echo '<div class="potion" style="width: 42px; height: 42px; border: 1px solid #B1B1B1;"><div style="background: url(/images/items/resource/mp_500.png) no-repeat center; background-size: 100%; display: inline-block; width: 42; height: 42px;"><div style="padding-top: 70%; padding-right: 3px;"><font style="text-shadow: black 1px 1px 1px; color: #e0e0e0; font-size: 10px; float: right;">99</font></div></div></div>';
echo '<div class="potion" style="border: 1px solid gray; height: 31px; width: 42px;font-size: 13px; padding-top: 11px; display: inline-block; color: gray;">пусто</div></td>';
echo '<td class="event" width="50%"><div class="potion" style="width: 42px; height: 42px; border: 1px solid orangered;"><div style="background: url(/images/skills/meteor_rain.png) no-repeat center; background-size: 100%; display: inline-block; width: 42px; height: 42px;"></div></div>';
echo '<div class="skill" style="width: 42px; height: 42px; border: 1px solid orangered;"><div style="background: url(/images/skills/fireball.png) no-repeat center; background-size: 100%; display: inline-block; width: 42px; height: 42px;"></div></div>';
echo '<div class="skill" style="width: 42px; height: 42px; border: 1px solid limegreen;"><div style="background: url(/images/skills/healing_wave.png) no-repeat center; background-size: 100%; display: inline-block; width: 42px; height: 42px;"></div></div></td></tr></table></center>';

//Футер
echo '</div></div></div><div class="b_foot"><table width="100%"><tr><td valign="top" width="20%"><center>';
echo '<div class="foot_btn_off"><img src="/images/icons/menu.png"><br/>Меню</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/icons/location.png"><br/>Локация</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/skins/'.$sex.'_big.png" width="32px"><br/>Персонаж</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/icons/bag.png"><br/>Инвентарь</div></center></td><td valign="top" width="20%"><center><a href="?"><div class="foot_btn"><img src="/images/icons/refresh.png"><br/>Обновить';
echo '</center></td></tr></table></div></div>';

break;

case '2':

//Хэдер
echo '<body><div class="page"><div class="sticky_header"><table width="100%" class="a_table a_table-common" style="border-collapse: collapse;"><tr><td width="45%">';
echo '<div class="exp" style="background-size: 99% 12px; text-shadow: black 0 1px 0;"><font size="1">EXP: 99% <div style="float: right;">LV:99</div></font></div>';
echo '<div class="hp" style="background-size: 100% 12px; text-shadow: black 0 1px 0;"><font size="1">HP: 10K/10K</font></div>';
echo '<div class="mp" style="background-size: 100% 12px; text-shadow: black 0 1px 0;"><font size="1">MP: 10К/10К</font></div>';
echo '</td><td width="19%" valign="top"><div style="text-shadow: black 0 1px 0;"><a href="/gold/"><img src="/images/icons/silver.png"  width="16px"><font size="2">10M</font></a><br/>';
echo '<a href="/gold/"><img src="/images/icons/gold.png" width="16px"><font color="gold" size="2">10M</font></a>';
echo '</div></td><td width="36%" align="right" valign="top"><a class="btn_smallest" href="https://vk.com/avalormobi"><img src="/images/vk.png" width="20px"></a><a class="btn_smallest" href="https://t.me/joinchat/AAAAAFXi5EIjuCJfSiMxsg"><img src="/images/telegram.png" width="20px"></a><a class="btn_smallest" href="/fresh_news/"><img src="/images/icons/bell.png" width="20px"></a><a class="btn_smallest" href="/mail/"><img src="/images/icons/mail.png" width="20px"></a><br/><font style="float: right; font-size: 11px; color: #9090A1; text-shadow: black 0 1px 0;">BETA</font></td></tr></table></div>';
//Битва
echo '<div class="body"><div class="border" style="position: relative; margin-top: 5px; box-sizing: border-box;"><div style="width: 100%; max-width: 336px; height: 248px; background: url(/images/locations/backgrounds/lava_cave.png) no-repeat center;">';
//Указатель
echo '<div style="position: absolute; bottom: -5%; right: -3%; z-index: 9999;"><a href="/training/next/"><img src="/images/cursor.gif"></a></div>';
echo '<table width="100%" height="22%" style="font-size: 11px; text-shadow: black 1px 1px 1px; color: white;"><tr>';
//echo '<td width="50%" valign="top"></td>';
//Речь наставника
echo '<td width="100%" valign="top"><div class="fast_log"><table><tr><td><img src="/images/npcs/haming.png" width="36px"></td><td valign="top"><small><font color="#E0E0E0">Отлично! Продолжай в том же духе!</small></font></td></tr></table></div>';
//Поле боя
echo '</td></tr></table>';
echo '<table width="100%" height="78%" style="position: relative;"><tr><td width="50%"><center><div style="position: absolute; bottom: 35%; left: 10%; width: 35%;">';
echo '<font style="text-shadow: black 1px 1px 1px; color: #FFFFFF; font-size: 12px;">'.$u['login'].'</font><br/>
<div class="hp_small" style="background-size: 100% 2px;"></div><br/>
<div class="mp_small" style="background-size: 100% 2px;"></div><br/><img src="/images/skins/'.$sex.'_right.gif"></div><center></td>';
echo '<td width="50%" style="position: relative;"><center><small><font style="text-shadow: black 1px 1px 1px; color: #FFFFFF;">Фобос</font></small><br/><a href="/training/next/"><img style="max-height: 120px;" src="/images/mobs/bosses/fobos.gif"></a></center>
<center><div class="hp" style="width: 75%; background-size: 80% 12px; text-shadow: black 0 1px 0; text-align: left;"><font color="#E0E0E0" size="1">HP: 8К/10К</font></div></center><br/><br/>';
echo '<div style="position: absolute; bottom: 0.5%; right: 0.5%;"><a href="/training/next/"><img  src="/images/items/training_sword.png" style="border: 1px solid #DD4FFF;" width="42px"></a></div></td></tr></table></div></div>';
//Пояс и умения
echo '<center><table style="width: 100%; max-width: 303px;" cellspacing="3px"><tr><td class="event" width="50%"><div class="potion" style="width: 42px; height: 42px; border: 1px solid #B1B1B1;"><div style="background: url(/images/items/resource/hp_500.png) no-repeat center; background-size: 100%; display: inline-block; width: 42; height: 42px;">
	<div style="padding-top: 70%; padding-right: 3px;"><font style="text-shadow: black 1px 1px 1px; color: #e0e0e0; font-size: 10px; float: right;">99</font></div></div></div>';
echo '<div class="potion" style="width: 42px; height: 42px; border: 1px solid #B1B1B1;"><div style="background: url(/images/items/resource/mp_500.png) no-repeat center; background-size: 100%; display: inline-block; width: 42; height: 42px;"><div style="padding-top: 70%; padding-right: 3px;"><font style="text-shadow: black 1px 1px 1px; color: #e0e0e0; font-size: 10px; float: right;">99</font></div></div></div>';
echo '<div class="potion" style="border: 1px solid gray; height: 31px; width: 42px;font-size: 13px; padding-top: 11px; display: inline-block; color: gray;">пусто</div></td>';
echo '<td class="event" width="50%"><div class="skill" style="width: 42px; height: 42px; border: 1px solid orangered;"><div style="background: url(/images/skills/meteor_rain.png) no-repeat center; background-size: 100%; display: inline-block; width: 42px; height: 42px;"></div></div>';
echo '<div class="skill" style="width: 42px; height: 42px; border: 1px solid orangered;"><div style="background: url(/images/skills/fireball.png) no-repeat center; background-size: 100%; display: inline-block; width: 42px; height: 42px;"></div></div>';
echo '<div class="skill" style="width: 42px; height: 42px; border: 1px solid limegreen;"><div style="background: url(/images/skills/healing_wave.png) no-repeat center; background-size: 100%; display: inline-block; width: 42px; height: 42px;"></div></div></td></tr></table></center>';

//Футер
echo '</div></div></div><div class="b_foot"><table width="100%"><tr><td valign="top" width="20%"><center>';
echo '<div class="foot_btn_off"><img src="/images/icons/menu.png"><br/>Меню</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/icons/location.png"><br/>Локация</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/skins/'.$sex.'_big.png" width="32px"><br/>Персонаж</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/icons/bag.png"><br/>Инвентарь</div></center></td><td valign="top" width="20%"><center><a href="?"><div class="foot_btn"><img src="/images/icons/refresh.png"><br/>Обновить';
echo '</center></td></tr></table></div></div>';

break;

case '3':

//Хэдер
echo '<body><div class="page"><div class="sticky_header"><table width="100%" class="a_table a_table-common" style="border-collapse: collapse;"><tr><td width="45%">';
echo '<div class="exp" style="background-size: 99% 12px; text-shadow: black 0 1px 0;"><font size="1">EXP: 99% <div style="float: right;">LV:99</div></font></div>';
echo '<div class="hp" style="background-size: 50% 12px; text-shadow: black 0 1px 0;"><font size="1">HP: 5K/10K</font></div>';
echo '<div class="mp" style="background-size: 100% 12px; text-shadow: black 0 1px 0;"><font size="1">MP: 10К/10К</font></div>';
echo '</td><td width="19%" valign="top"><div style="text-shadow: black 0 1px 0;"><a href="/gold/"><img src="/images/icons/silver.png"  width="16px"><font size="2">10M</font></a><br/>';
echo '<a href="/gold/"><img src="/images/icons/gold.png" width="16px"><font color="gold" size="2">10M</font></a>';
echo '</div></td><td width="36%" align="right" valign="top"><a class="btn_smallest" href="https://vk.com/avalormobi"><img src="/images/vk.png" width="20px"></a><a class="btn_smallest" href="https://t.me/joinchat/AAAAAFXi5EIjuCJfSiMxsg"><img src="/images/telegram.png" width="20px"></a><a class="btn_smallest" href="/fresh_news/"><img src="/images/icons/bell.png" width="20px"></a><a class="btn_smallest" href="/mail/"><img src="/images/icons/mail.png" width="20px"></a><br/><font style="float: right; font-size: 11px; color: #9090A1; text-shadow: black 0 1px 0;">BETA</font></td></tr></table></div>';
//Битва
echo '<div class="body"><div class="border" style="margin-top: 5px; box-sizing: border-box;"><div style="width: 100%; max-width: 336px; height: 248px; background: url(/images/locations/backgrounds/lava_cave.png) no-repeat center;">';
echo '<table width="100%" height="22%" style="font-size: 11px; text-shadow: black 1px 1px 1px; color: white;"><tr>';
//echo '<td width="50%" valign="top"></td>';
//Речь наставника
echo '<td width="100%" valign="top"><div class="fast_log"><table><tr><td><img src="/images/npcs/haming.png" width="36px"></td><td valign="top"><small><font color="#E0E0E0">Черт, он зацепил тебя! Выпей целебное зелье!</small></font></td></tr></table></div>';
//Поле боя
echo '</td></tr></table>';
echo '<table width="100%" height="78%" style="position: relative;"><tr><td width="50%"><center><div style="position: absolute; bottom: 35%; left: 10%; width: 35%;">';
echo '<font style="text-shadow: black 1px 1px 1px; color: #FFFFFF; font-size: 12px;">'.$u['login'].'</font><br/>
<div class="hp_small" style="background-size: 50% 2px;"></div><br/>
<div class="mp_small" style="background-size: 100% 2px;"></div><br/><img src="/images/skins/'.$sex.'_right.gif"></div><center></td>';
echo '<td width="50%" style="position: relative;"><center><small><font style="text-shadow: black 1px 1px 1px; color: #FFFFFF;">Фобос</font></small><br/><img style="max-height: 120px;" src="/images/mobs/bosses/fobos.gif"></center>
<center><div class="hp" style="width: 75%; background-size: 60% 12px; text-shadow: black 0 1px 0; text-align: left;"><font color="#E0E0E0" size="1">HP: 6К/10К</font></div></center><br/><br/>';
echo '<div style="position: absolute; bottom: 0.5%; right: 0.5%;"><img  src="/images/items/training_sword.png" style="border: 1px solid #DD4FFF;" width="42px"></div></td></tr></table></div></div>';
//Пояс и умения
echo '<center><div style="width: 303px; position: relative;">';
//Указатель
echo '<div style="position: absolute; bottom: -9%; left: 13%; z-index: 9999;"><a href="/training/next/"><img src="/images/cursor.gif"></a></div>';
echo '<table style="width: 100%; max-width: 303px; position: relative;" cellspacing="3px"><tr>';
echo '<td class="event" width="50%"><a href="/training/next/" class="potion" style="width: 42px; height: 42px; border: 1px solid #B1B1B1;"><div style="background: url(/images/items/resource/hp_500.png) no-repeat center; background-size: 100%; display: inline-block; width: 42; height: 42px;">
	<div style="padding-top: 70%; padding-right: 3px;"><font style="text-shadow: black 1px 1px 1px; color: #e0e0e0; font-size: 10px; float: right;">99</font></div></div></a>';
echo '<div class="potion" style="width: 42px; height: 42px; border: 1px solid #B1B1B1;"><div style="background: url(/images/items/resource/mp_500.png) no-repeat center; background-size: 100%; display: inline-block; width: 42; height: 42px;"><div style="padding-top: 70%; padding-right: 3px;"><font style="text-shadow: black 1px 1px 1px; color: #e0e0e0; font-size: 10px; float: right;">99</font></div></div></div>';
echo '<div class="potion" style="border: 1px solid gray; height: 31px; width: 42px;font-size: 13px; padding-top: 11px; display: inline-block; color: gray;">пусто</div></td>';
echo '<td class="event" width="50%"><div class="skill" style="width: 42px; height: 42px; border: 1px solid orangered;"><div style="background: url(/images/skills/meteor_rain.png) no-repeat center; background-size: 100%; display: inline-block; width: 42px; height: 42px;"></div></div>';
echo '<div class="skill" style="width: 42px; height: 42px; border: 1px solid orangered;"><div style="background: url(/images/skills/fireball.png) no-repeat center; background-size: 100%; display: inline-block; width: 42px; height: 42px;"></div></div>';
echo '<div class="skill" style="width: 42px; height: 42px; border: 1px solid limegreen;"><div style="background: url(/images/skills/healing_wave.png) no-repeat center; background-size: 100%; display: inline-block; width: 42px; height: 42px;"></div></div></td></tr></table>';
echo '</div></center>';

//Футер
echo '</div></div></div><div class="b_foot"><table width="100%"><tr><td valign="top" width="20%"><center>';
echo '<div class="foot_btn_off"><img src="/images/icons/menu.png"><br/>Меню</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/icons/location.png"><br/>Локация</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/skins/'.$sex.'_big.png" width="32px"><br/>Персонаж</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/icons/bag.png"><br/>Инвентарь</div></center></td><td valign="top" width="20%"><center><a href="?"><div class="foot_btn"><img src="/images/icons/refresh.png"><br/>Обновить';
echo '</center></td></tr></table></div></div>';

break;

case '4':

//Хэдер
echo '<body><div class="page"><div class="sticky_header"><table width="100%" class="a_table a_table-common" style="border-collapse: collapse;"><tr><td width="45%">';
echo '<div class="exp" style="background-size: 99% 12px; text-shadow: black 0 1px 0;"><font size="1">EXP: 99% <div style="float: right;">LV:99</div></font></div>';
echo '<div class="hp" style="background-size: 100% 12px; text-shadow: black 0 1px 0;"><font size="1">HP: 10K/10K</font></div>';
echo '<div class="mp" style="background-size: 100% 12px; text-shadow: black 0 1px 0;"><font size="1">MP: 10К/10К</font></div>';
echo '</td><td width="19%" valign="top"><div style="text-shadow: black 0 1px 0;"><a href="/gold/"><img src="/images/icons/silver.png"  width="16px"><font size="2">10M</font></a><br/>';
echo '<a href="/gold/"><img src="/images/icons/gold.png" width="16px"><font color="gold" size="2">10M</font></a>';
echo '</div></td><td width="36%" align="right" valign="top"><a class="btn_smallest" href="https://vk.com/avalormobi"><img src="/images/vk.png" width="20px"></a><a class="btn_smallest" href="https://t.me/joinchat/AAAAAFXi5EIjuCJfSiMxsg"><img src="/images/telegram.png" width="20px"></a><a class="btn_smallest" href="/fresh_news/"><img src="/images/icons/bell.png" width="20px"></a><a class="btn_smallest" href="/mail/"><img src="/images/icons/mail.png" width="20px"></a><br/><font style="float: right; font-size: 11px; color: #9090A1; text-shadow: black 0 1px 0;">BETA</font></td></tr></table></div>';
//Битва
echo '<div class="body"><div class="border" style="margin-top: 5px; box-sizing: border-box;"><div style="width: 100%; max-width: 336px; height: 248px; background: url(/images/locations/backgrounds/lava_cave.png) no-repeat center;">';
echo '<table width="100%" height="22%" style="font-size: 11px; text-shadow: black 1px 1px 1px; color: white;"><tr>';
//echo '<td width="50%" valign="top"></td>';
//Речь наставника
echo '<td width="100%" valign="top"><div class="fast_log"><table><tr><td><img src="/images/npcs/haming.png" width="36px"></td><td valign="top"><small><font color="#E0E0E0">Молодец! А теперь добей монстра с помощью огненного умения!</small></font></td></tr></table></div>';
//Поле боя
echo '</td></tr></table>';
echo '<table width="100%" height="78%" style="position: relative;"><tr><td width="50%"><center><div style="position: absolute; bottom: 35%; left: 10%; width: 35%;">';
echo '<font style="text-shadow: black 1px 1px 1px; color: #FFFFFF; font-size: 12px;">'.$u['login'].'</font><br/>
<div class="hp_small" style="background-size: 100% 2px;"></div><br/>
<div class="mp_small" style="background-size: 100% 2px;"></div><br/><img src="/images/skins/'.$sex.'_right.gif"></div><center></td>';
echo '<td width="50%" style="position: relative;"><center><small><font style="text-shadow: black 1px 1px 1px; color: #FFFFFF;">Фобос</font></small><br/><img style="max-height: 120px;" src="/images/mobs/bosses/fobos.gif"></center>
<center><div class="hp" style="width: 75%; background-size: 60% 12px; text-shadow: black 0 1px 0; text-align: left;"><font color="#E0E0E0" size="1">HP: 30К/50К</font></div></center><br/><br/>';
echo '<div style="position: absolute; bottom: 0.5%; right: 0.5%;"><img  src="/images/items/training_sword.png" style="border: 1px solid #DD4FFF;" width="42px"></div></td></tr></table></div></div>';
//Пояс и умения
echo '<center><div style="width: 303px; position: relative;">';
//Указатель
echo '<div style="position: absolute; bottom: -9%; right: 28%; z-index: 9999;"><a href="/training/next/"><img src="/images/cursor.gif"></a></div>';
echo '<center><table style="width: 100%; max-width: 303px;" cellspacing="3px"><tr><td class="event" width="50%"><div class="potion" style="width: 41px; height: 41px; border: 1px solid #B1B1B1;"><div style="background: url(/images/items/resource/hp_500.png) no-repeat center; background-size: 100%; display: inline-block; width: 41; height: 41px;">
	<div style="padding-top: 70%; padding-right: 3px;"><font style="text-shadow: black 1px 1px 1px; color: #e0e0e0; font-size: 10px; float: right;">98</font></div></div></div>';
echo '<div class="potion" style="width: 42px; height: 42px; border: 1px solid #B1B1B1;"><div style="background: url(/images/items/resource/mp_500.png) no-repeat center; background-size: 100%; display: inline-block; width: 42; height: 42px;"><div style="padding-top: 70%; padding-right: 3px;"><font style="text-shadow: black 1px 1px 1px; color: #e0e0e0; font-size: 10px; float: right;">99</font></div></div></div>';
echo '<div class="potion" style="border: 1px solid gray; height: 31px; width: 42px;font-size: 13px; padding-top: 11px; display: inline-block; color: gray;">пусто</div></td>';
echo '<td class="event" width="50%"><a href="/training/next/" class="skill" style="width: 42px; height: 42px; border: 1px solid orangered;"><div style="background: url(/images/skills/meteor_rain.png) no-repeat center; background-size: 100%; display: inline-block; width: 42px; height: 42px;"></div></a>';
echo '<div class="skill" style="width: 42px; height: 42px; border: 1px solid orangered;"><div style="background: url(/images/skills/fireball.png) no-repeat center; background-size: 100%; display: inline-block; width: 42px; height: 42px;"></div></div>';
echo '<div class="skill" style="width: 42px; height: 42px; border: 1px solid limegreen;"><div style="background: url(/images/skills/healing_wave.png) no-repeat center; background-size: 100%; display: inline-block; width: 42px; height: 42px;"></div></div></td></tr></table>';
echo '</div></center>';
//echo '<center><table style="width: 100%; max-width: 335px;"><tr><td class="event"><div style="margin-top: 2px; color: #B1B1B1; font-size: 12px;"><img src="/images/icons/topic.png" width="16px"> Волк нанёс вам 89 урона.</div><div style="margin-top: 2px; color: #B1B1B1; font-size: 12px;"><img src="/images/icons/topic.png" width="16px"> Волк напал на AlexHated, битва началась!</div></td></tr></table></center></div>';
//echo '<a class="skill" style="width: 42px; height: 42px; border: 1px solid orangered;" href="/pve/skill/2/"><div style="background: url(/images/skills/fireball.png) no-repeat center; background-size: 100%; display: inline-block; width: 42px; height: 42px;"></div></a>';

//Футер
echo '</div></div></div><div class="b_foot"><table width="100%"><tr><td valign="top" width="20%"><center>';
echo '<div class="foot_btn_off"><img src="/images/icons/menu.png"><br/>Меню</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/icons/location.png"><br/>Локация</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/skins/'.$sex.'_big.png" width="32px"><br/>Персонаж</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/icons/bag.png"><br/>Инвентарь</div></center></td><td valign="top" width="20%"><center><a href="?"><div class="foot_btn"><img src="/images/icons/refresh.png"><br/>Обновить';
echo '</center></td></tr></table></div></div>';

break;

case '5':

if($u['training_location'] == 14) $url = '/training/next/';
else $url = '/training/move/';

//Направление
if($u['training_location'] > 1 AND $u['training_location'] < 5) $dir = '_right';
if($u['training_location'] > 4 AND $u['training_location'] < 14) $dir = '_up';

//Хэдер
echo '<body><div class="page"><div class="sticky_header"><table width="100%" class="a_table a_table-common" style="border-collapse: collapse;"><tr><td width="45%">';
echo '<div class="exp" style="background-size: 100% 12px; text-shadow: black 0 1px 0;"><font size="1">EXP: 100% <div style="float: right;">LV:100</div></font></div>';
echo '<div class="hp" style="background-size: 100% 12px; text-shadow: black 0 1px 0;"><font size="1">HP: 10K/10K</font></div>';
echo '<div class="mp" style="background-size: 100% 12px; text-shadow: black 0 1px 0;"><font size="1">MP: 10К/10К</font></div>';
echo '</td><td width="19%" valign="top"><div style="text-shadow: black 0 1px 0;"><a href="/gold/"><img src="/images/icons/silver.png"  width="16px"><font size="2">10M</font></a><br/>';
echo '<a href="/gold/"><img src="/images/icons/gold.png" width="16px"><font color="gold" size="2">10M</font></a>';
echo '</div></td><td width="36%" align="right" valign="top"><a class="btn_smallest" href="https://vk.com/avalormobi"><img src="/images/vk.png" width="20px"></a><a class="btn_smallest" href="https://t.me/joinchat/AAAAAFXi5EIjuCJfSiMxsg"><img src="/images/telegram.png" width="20px"></a><a class="btn_smallest" href="/fresh_news/"><img src="/images/icons/bell.png" width="20px"></a><a class="btn_smallest" href="/mail/"><img src="/images/icons/mail.png" width="20px"></a><br/><font style="float: right; font-size: 11px; color: #9090A1; text-shadow: black 0 1px 0;">BETA</font></td></tr></table></div>';

//Локация
echo '<div class="border" style="margin-top: 5px; width: 100%; max-width: 343px; height: 344px; box-sizing: border-box;"><div style="background: url(/images/locations/training/tl'.$u['training_location'].'.gif); background-size: cover; width: 100%; max-width: 336px; height: 336px; background-color: #101010; position: relative; word-wrap: break-word;"><table cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse;" width="100%" height="336px"><tbody>';
//Указатель
if($u['training_location'] > 0 AND $u['training_location'] < 4){
	$bottom = 40;
	$left = 65;
}elseif($u['training_location'] > 3 AND $u['training_location'] < 14){
	$bottom = 54;
	$left = 51;
}elseif($u['training_location'] == 14){
	$bottom = -1;
	$left = 93;
}
echo '<div style="position: absolute; bottom: '.$bottom.'%; left: '.$left.'%; z-index: 9999;"><a href="'.$url.'"><img src="/images/cursor.gif"></a></div>';
//Речь наставника
if($u['training_location'] == 1) $say = 'Монстр сражён! Нажми на квадрат возле тебя чтобы перейти туда.';
if($u['training_location'] == 2) $say = 'Отлично! Продолжай в том же духе!';
if($u['training_location'] == 14) $say = 'Здесь Азазель держит пленников... Нужно их освободить!';
if($u['training_location'] == 1 OR $u['training_location'] == 2 OR $u['training_location'] == 14){
	echo '<div style="position: absolute; top: 1%; left: 1%; width: 98%; font-size: 12px; text-shadow: black 1px 1px 1px; color: white;">';
	echo '<div class="fast_log">';
	echo '<div style="text-align: left; padding: 4px; min-height: 36px;"><img style="float: left; margin-right: 3px;" src="/images/npcs/haming.png" width="36px"><div style=""><font color="#E0E0E0">'.$say.'</font></div></div>';
	echo '</div></div>';
}
//Башня мучеников
if($u['training_location'] == 14) echo '<div style="position: absolute; bottom: 1%; right: 1%; width: 40%;" align="right"><a href="/training/next/"><div class="btn_mini"><center><img src="/images/icons/location.png" width="24px"><br/><font size="1">Перейти</font></a></div>';
//Локация
echo '<tr height="14.3%">';
echo '<td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td>';
echo '</tr>';
echo '<tr height="14.3%">';
echo '<td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td>';
echo '</tr>';
echo '<tr height="14.3%">';
echo '<td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td>';
if($u['training_location'] > 3 AND $u['training_location'] < 14) echo '</td><td width="14.285%"><a href="'.$url.'"><img src="/images/move.png"></a></td><td width="14.285%"></td><td width="14.285%"></td>';
else echo '</td><td width="14.285%"></td>';
echo '<td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td>';
echo '</tr>';
echo '<tr height="14.3%">';
echo '<td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td>';
echo '<td width="14.285%">';
//Персонаж и передвижение
echo '<div style="width: 100%; height: 100%; background: url(/images/skins/'.$sex.''.$dir.'.gif) no-repeat center;"><div style="position: absolute; bottom: 57%; right: 35.7%; font-size: 10px; text-shadow: black 1px 1px 1px; color: white; width: 28.5%; height: 11px;text-align: center;">'.$u['login'].'</div></div></td>';
//Локация
if($u['training_location'] > 0 AND $u['training_location'] < 4) echo '</td><td width="14.285%"><a href="'.$url.'"><img src="/images/move.png"></a></td><td width="14.285%"></td><td width="14.285%"></td>';
else echo '</td><td width="14.285%"></td>';
echo '</tr>';
echo '<tr height="14.3%">';
echo '<td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td>';
echo '</tr>';
echo '<tr height="14.3%">';
echo '<td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td>';
echo '</tr>';
echo '<tr height="14.3%">';
echo '<td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td>';
echo '</tr>';
echo '</tbody></table></div></div></center></div>';

//Футер
echo '</div></div></div><div class="b_foot"><table width="100%"><tr><td valign="top" width="20%"><center>';
echo '<div class="foot_btn_off"><img src="/images/icons/menu.png"><br/>Меню</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/icons/location.png"><br/>Локация</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/skins/'.$sex.'_big.png" width="32px"><br/>Персонаж</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/icons/bag.png"><br/>Инвентарь</div></center></td><td valign="top" width="20%"><center><a href="?"><div class="foot_btn"><img src="/images/icons/refresh.png"><br/>Обновить';
echo '</center></td></tr></table></div></div>';

break;

case '6':

//Хэдер
echo '<body><div class="page"><div class="sticky_header"><table width="100%" class="a_table a_table-common" style="border-collapse: collapse;"><tr><td width="45%">';
echo '<div class="exp" style="background-size: 100% 12px; text-shadow: black 0 1px 0;"><font size="1">EXP: 100% <div style="float: right;">LV:100</div></font></div>';
echo '<div class="hp" style="background-size: 100% 12px; text-shadow: black 0 1px 0;"><font size="1">HP: 10K/10K</font></div>';
echo '<div class="mp" style="background-size: 100% 12px; text-shadow: black 0 1px 0;"><font size="1">MP: 10К/10К</font></div>';
echo '</td><td width="19%" valign="top"><div style="text-shadow: black 0 1px 0;"><a href="/gold/"><img src="/images/icons/silver.png"  width="16px"><font size="2">10M</font></a><br/>';
echo '<a href="/gold/"><img src="/images/icons/gold.png" width="16px"><font color="gold" size="2">10M</font></a>';
echo '</div></td><td width="36%" align="right" valign="top"><a class="btn_smallest" href="https://vk.com/avalormobi"><img src="/images/vk.png" width="20px"></a><a class="btn_smallest" href="https://t.me/joinchat/AAAAAFXi5EIjuCJfSiMxsg"><img src="/images/telegram.png" width="20px"></a><a class="btn_smallest" href="/fresh_news/"><img src="/images/icons/bell.png" width="20px"></a><a class="btn_smallest" href="/mail/"><img src="/images/icons/mail.png" width="20px"></a><br/><font style="float: right; font-size: 11px; color: #9090A1; text-shadow: black 0 1px 0;">BETA</font></td></tr></table></div>';

//Квест
echo '<div class="body" style="position: relative;"><div class="b"><div class="title">Башня Мучеников</div>';
//Указатель
echo '<div style="position: absolute; bottom: 1%; left: 58%; z-index: 9999;"><a href="/training/next/"><img src="/images/cursor.gif"></a></div>';
echo '<center><div class="border"><img style="width: 100%; max-width: 336px;" src="/images/places/hell_tower.png"></div></center><div class="title">Старец</div><div class="event"><table><tbody><tr><td><img src="/images/npcs/ernest.png" width="48px"></td><td><small><font color="#B1B1B1"> Умоляю, пощадите хотя бы моих внуков! Стой... Это не прислужник демонов... Ты наш спаситель? Пожалуйста скажи что это так! Азазель держит в страхе весь Авалор, а теперь и вовсе ни перед чем не остановится!</font></small></td></tr></tbody></table></div><center><a class="btn_small" href="/training/next/">Я освобожу вас!</a></center><br/></div></div>';

//Футер
echo '</div></div></div><div class="b_foot"><table width="100%"><tr><td valign="top" width="20%"><center>';
echo '<div class="foot_btn_off"><img src="/images/icons/menu.png"><br/>Меню</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/icons/location.png"><br/>Локация</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/skins/'.$sex.'_big.png" width="32px"><br/>Персонаж</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/icons/bag.png"><br/>Инвентарь</div></center></td><td valign="top" width="20%"><center><a href="?"><div class="foot_btn"><img src="/images/icons/refresh.png"><br/>Обновить';
echo '</center></td></tr></table></div></div>';

break;

case '7':

if($u['training_location'] < 20) $url = '/training/move/';
else $url = '/training/next/';

//Направление
if($u['training_location'] > 15 AND $u['training_location'] < 18) $dir = '_left';
elseif($u['training_location'] > 17) $dir = '_up';

if($u['training_location'] == 14){
	$base -> query('UPDATE `users` SET `training_location` = "15" WHERE `id` = "'.$u['id'].'"');
	header('Location: /training/'.$u['training_step'].'/');
	exit;
}

//Хэдер
echo '<body><div class="page"><div class="sticky_header"><table width="100%" class="a_table a_table-common" style="border-collapse: collapse;"><tr><td width="45%">';
echo '<div class="exp" style="background-size: 100% 12px; text-shadow: black 0 1px 0;"><font size="1">EXP: 100% <div style="float: right;">LV:100</div></font></div>';
echo '<div class="hp" style="background-size: 100% 12px; text-shadow: black 0 1px 0;"><font size="1">HP: 10K/10K</font></div>';
echo '<div class="mp" style="background-size: 100% 12px; text-shadow: black 0 1px 0;"><font size="1">MP: 10К/10К</font></div>';
echo '</td><td width="19%" valign="top"><div style="text-shadow: black 0 1px 0;"><a href="/gold/"><img src="/images/icons/silver.png"  width="16px"><font size="2">10M</font></a><br/>';
echo '<a href="/gold/"><img src="/images/icons/gold.png" width="16px"><font color="gold" size="2">10M</font></a>';
echo '</div></td><td width="36%" align="right" valign="top"><a class="btn_smallest" href="https://vk.com/avalormobi"><img src="/images/vk.png" width="20px"></a><a class="btn_smallest" href="https://t.me/joinchat/AAAAAFXi5EIjuCJfSiMxsg"><img src="/images/telegram.png" width="20px"></a><a class="btn_smallest" href="/fresh_news/"><img src="/images/icons/bell.png" width="20px"></a><a class="btn_smallest" href="/mail/"><img src="/images/icons/mail.png" width="20px"></a><br/><font style="float: right; font-size: 11px; color: #9090A1; text-shadow: black 0 1px 0;">BETA</font></td></tr></table></div>';

//Локация
echo '<div class="border" style="margin-top: 5px; width: 100%; max-width: 343px; height: 344px; box-sizing: border-box;"><div style="background-image: url(/images/locations/training/tl'.$u['training_location'].'.gif); background-size: cover; width: 100%; max-width: 336px; height: 336px; background-color: #101010; position: relative; word-wrap: break-word;"><table cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse;" width="100%" height="336px"><tbody>';
//Указатель
if($u['training_location'] > 0 AND $u['training_location'] < 4){
	$bottom = 40;
	$left = 65;
}elseif($u['training_location'] > 3 AND $u['training_location'] < 14){
	$bottom = 54;
	$left = 51;
}elseif($u['training_location'] == 14){
	$bottom = -1;
	$left = 93;
}elseif($u['training_location'] > 14 AND $u['training_location'] < 17){
	$bottom = 40;
	$left = 36;
}elseif($u['training_location'] > 16 AND $u['training_location'] < 20){
	$bottom = 54;
	$left = 51;
}
elseif($u['training_location'] == 20){
	$bottom = -1;
	$left = 93;
}
echo '<div style="position: absolute; bottom: '.$bottom.'%; left: '.$left.'%; z-index: 9999;"><a href="'.$url.'"><img src="/images/cursor.gif"></a></div>';
//Речь наставника
if($u['training_location'] == 1) $say = 'Монстр сражён! Нажми на квадрат возле тебя чтобы перейти туда.';
if($u['training_location'] == 2) $say = 'Отлично! Продолжай в том же духе!';
if($u['training_location'] == 14) $say = 'Здесь Азазель держит пленников... Нужно их освободить!';
if($u['training_location'] == 20) $say = 'Это Азазель, владыка демонов! Надеюсь ты не забыл как сражаться?';
if($u['training_location'] == 1 OR $u['training_location'] == 2 OR $u['training_location'] == 14 OR $u['training_location'] == 20){
	echo '<div style="position: absolute; top: 1%; left: 1%; width: 98%; font-size: 12px; text-shadow: black 1px 1px 1px; color: white;">';
	echo '<div class="fast_log">';
	echo '<div style="text-align: left; padding: 4px; min-height: 36px;"><img style="float: left; margin-right: 3px;" src="/images/npcs/haming.png" width="36px"><div style=""><font color="#E0E0E0">'.$say.'</font></div></div>';
	echo '</div></div>';
}
//Башня мучеников
if($u['training_location'] == 14) echo '<div style="position: absolute; bottom: 1%; right: 1%; width: 40%;" align="right"><a href="/training/next/"><div class="btn_mini"><center><img src="/images/icons/location.png" width="24px"><br/><font size="1">Перейти</font></a></div>';
//Азазель
if($u['training_location'] == 20) echo '<div style="position: absolute; bottom: 1%; right: 1%; width: 40%;" align="right"><a href="/training/next/"><div class="btn_mini"><center><img src="/images/icons/boss.png" width="24px"><br/><font size="1">Азазель</font></a></div>';
//Локация
echo '<tr height="14.3%">';
echo '<td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td>';
echo '</tr>';
echo '<tr height="14.3%">';
echo '<td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td>';
echo '</tr>';
echo '<tr height="14.3%">';
echo '<td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td>';
if($u['training_location'] > 16 AND $u['training_location'] < 20) echo '</td><td width="14.285%"><a href="'.$url.'"><img src="/images/move.png"></a></td><td width="14.285%"></td><td width="14.285%"></td>';
else echo '</td><td width="14.285%"></td>';
echo '<td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td>';
echo '</tr>';
echo '<tr height="14.3%">';
echo '<td width="14.285%"></td><td width="14.285%"></td>';
if($u['training_location'] > 14 AND $u['training_location'] < 17) echo '</td><td width="14.285%"><a href="'.$url.'"><img src="/images/move.png"></a></td>';
else echo '</td><td width="14.285%"></td>';
echo '<td width="14.285%">';
//Персонаж и передвижение
echo '<div style="width: 100%; height: 100%; background: url(/images/skins/'.$sex.''.$dir.'.gif) no-repeat center;"><div style="position: absolute; bottom: 57%; right: 35.7%; font-size: 10px; text-shadow: black 1px 1px 1px; color: white; width: 28.5%; height: 11px;text-align: center;">'.$u['login'].'</div></div></td>';
//Локация
if($u['training_location'] > 0 AND $u['training_location'] < 4) echo '</td><td width="14.285%"><a href="'.$url.'"><img src="/images/move.png"></a></td><td width="14.285%"></td><td width="14.285%"></td>';
else echo '</td><td width="14.285%"></td>';
echo '</tr>';
echo '<tr height="14.3%">';
echo '<td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td>';
echo '</tr>';
echo '<tr height="14.3%">';
echo '<td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td>';
echo '</tr>';
echo '<tr height="14.3%">';
echo '<td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td><td width="14.285%"></td>';
echo '</tr>';
echo '</tbody></table></div></div></center></div>';

//Футер
echo '</div></div></div><div class="b_foot"><table width="100%"><tr><td valign="top" width="20%"><center>';
echo '<div class="foot_btn_off"><img src="/images/icons/menu.png"><br/>Меню</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/icons/location.png"><br/>Локация</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/skins/'.$sex.'_big.png" width="32px"><br/>Персонаж</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/icons/bag.png"><br/>Инвентарь</div></center></td><td valign="top" width="20%"><center><a href="?"><div class="foot_btn"><img src="/images/icons/refresh.png"><br/>Обновить';
echo '</center></td></tr></table></div></div>';


break;

case '8':

$tb = $base -> query('SELECT * FROM `training_battle` WHERE `user` = "'.$u['id'].'" LIMIT 1') -> fetch_assoc();

if(!$tb){
	$base -> query('INSERT INTO `training_battle` SET
	`user` = "'.$u['id'].'",
	`hp_bottles` = "98",
	`mp_bottles` = "99",
	`hp` = "10000",
	`max_hp` = "10000",
	`mp` = "10000",
	`max_mp` = "10000",
	`boss_hp` = "500000",
	`boss_max_hp` = "500000"');
	$_SESSION['enemy_fast_log'] = 'Бой с Азазель начался!';
	header('Location: /');
	exit;
}else{

if($tb['hp'] <= 0 OR $tb['boss_hp'] <= 10000){
	$end = 1;
	$tb['hp'] = 0;
	if($tb['boss_hp'] < 10000) $tb['boss_hp'] = 10000;
	$skin = ''.$sex.'_dead';

}else{
	$skin = ''.$sex.'_right';
}

$attack = fl($_GET['attack']);
$hp = fl($_GET['hp']);
$mp = fl($_GET['mp']);
$skill = fl($_GET['skill']);

if($end != 1){//Если ещё не сражён
if($attack == 'ok'){
	$dmg = mt_rand(500,1000);
	$enemy_dmg = mt_rand(2500,5000);
	$base -> query('UPDATE `training_battle` SET `hp` = `hp`-"'.$enemy_dmg.'", `boss_hp` = `boss_hp`-"'.$dmg.'" WHERE `user` = "'.$u['id'].'" LIMIT 1');
	$_SESSION['user_fast_log'] = 'Вы нанесли <font color="yellow">'.n_f($dmg).'</font> урона!';
	$_SESSION['enemy_fast_log'] = 'Азазель нанёс <font color="red">'.n_f($enemy_dmg).'</font> урона!';
	header('Location: /');
	exit;
}
if($hp == 'ok'){
	if($tb['hp_bottles'] > 0){
		$new_hp = $tb['hp'] + 500;
		if($new_hp > $tb['max_hp']) $new_hp = $tb['max_hp'];
		$base -> query('UPDATE `training_battle` SET `hp` = "'.$new_hp.'", `hp_bottles` = `hp_bottles`-"1" WHERE `user` = "'.$u['id'].'" LIMIT 1');
		$_SESSION['user_fast_log'] = 'Восстановлено <font color="lime">500</font> здоровья.';
	}else{
		$_SESSION['user_fast_log'] = 'Зелья закончились.';
	}
	header('Location: /');
	exit;
}
if($mp == 'ok'){
	if($tb['mp_bottles'] > 0){
		$new_mp = $tb['mp'] + 500;
		if($new_mp > $tb['max_mp']) $new_mp = $tb['max_mp'];
		$base -> query('UPDATE `training_battle` SET `mp` = "'.$new_mp.'", `mp_bottles` = `mp_bottles`-"1" WHERE `user` = "'.$u['id'].'" LIMIT 1');
		$_SESSION['user_fast_log'] = 'Восстановлено <font color="dodgerblue">500</font> маны.';
	}else{
		$_SESSION['user_fast_log'] = 'Зелья закончились.';
	}
	header('Location: /');
	exit;
}
if($skill){
	if($tb['mp'] > 499){
		if($skill == 1 OR $skill == 2){
			if($skill == 1) $dmg = mt_rand(2500,5000);
			elseif($skill == 2) $dmg = mt_rand(1000,1500);
			$enemy_dmg = mt_rand(2500,5000);
			$base -> query('UPDATE `training_battle` SET `hp` = `hp`-"'.$enemy_dmg.'", `boss_hp` = `boss_hp`-"'.$dmg.'", `mp` = `mp`-"500" WHERE `user` = "'.$u['id'].'" LIMIT 1');
			$_SESSION['user_fast_log'] = 'Вы нанесли <font color="yellow">'.n_f($dmg).'</font> урона!';
			$_SESSION['enemy_fast_log'] = 'Азазель нанёс <font color="red">'.n_f($enemy_dmg).'</font> урона!';
		}elseif($skill == 3){
			$new_hp = $tb['hp'] + 1000;
			if($new_hp > $tb['max_hp']) $new_hp = $tb['max_hp'];
			$base -> query('UPDATE `training_battle` SET `hp` = "'.$new_hp.'", `hp_bottles` = `hp_bottles`-"1", `mp` = `mp`-"500" WHERE `user` = "'.$u['id'].'" LIMIT 1');
			$_SESSION['user_fast_log'] = 'Восстановлено <font color="lime">1000</font> здоровья.';
		}
	}else{
		$_SESSION['user_fast_log'] = 'Не хватает маны.';
	}
	header('Location: /');
	exit;
}
}


$now_hp = round($tb['hp']/$tb['max_hp']*100,1);
if($now_hp > 100)$now_hp = 100;
$now_mp = round($tb['mp']/$tb['max_mp']*100,1);
if($now_mp > 100)$now_mp = 100;
$now_boss_hp = round($tb['boss_hp']/$tb['boss_max_hp']*100,1);
if($now_boss_hp > 100)$now_boss_hp = 100;

//Хэдер
echo '<body><div class="page"><div class="sticky_header"><table width="100%" class="a_table a_table-common" style="border-collapse: collapse;"><tr><td width="45%">';
echo '<div class="exp" style="background-size: 100% 12px; text-shadow: black 0 1px 0;"><font size="1">EXP: 100% <div style="float: right;">LV:100</div></font></div>';
echo '<div class="hp" style="background-size: '.$now_hp.'% 12px; text-shadow: black 0 1px 0;"><font size="1">HP: '.n_f($tb['hp']).'/'.n_f($tb['max_hp']).'</font></div>';
echo '<div class="mp" style="background-size: '.$now_mp.'% 12px; text-shadow: black 0 1px 0;"><font size="1">MP: '.n_f($tb['mp']).'/'.n_f($tb['max_mp']).'</font></div>';
echo '</td><td width="19%" valign="top"><div style="text-shadow: black 0 1px 0;"><a href="/gold/"><img src="/images/icons/silver.png"  width="16px"><font size="2">10M</font></a><br/>';
echo '<a href="/gold/"><img src="/images/icons/gold.png" width="16px"><font color="gold" size="2">10M</font></a>';
echo '</div></td><td width="36%" align="right" valign="top"><a class="btn_smallest" href="https://vk.com/avalormobi"><img src="/images/vk.png" width="20px"></a><a class="btn_smallest" href="https://t.me/joinchat/AAAAAFXi5EIjuCJfSiMxsg"><img src="/images/telegram.png" width="20px"></a><a class="btn_smallest" href="/fresh_news/"><img src="/images/icons/bell.png" width="20px"></a><a class="btn_smallest" href="/mail/"><img src="/images/icons/mail.png" width="20px"></a><br/><font style="float: right; font-size: 11px; color: #9090A1; text-shadow: black 0 1px 0;">BETA</font></td></tr></table></div>';
//Битва
echo '<div class="body"><div class="border" style="position: relative; margin-top: 5px; box-sizing: border-box;"><div style="width: 100%; max-width: 336px; height: 248px; background: url(/images/locations/backgrounds/lava_cave.png) no-repeat center;">';
//Указатель
if($end ==1) echo '<div style="position: absolute; bottom: -25%; right: 36%; z-index: 9999;"><a href="/training/next/"><img src="/images/cursor.gif"></a></div>';
echo '<table width="100%" height="22%" style="font-size: 11px; text-shadow: black 1px 1px 1px; color: white;"><tr>';
if($end == 1){
//Речь наставника
echo '<td width="100%" valign="top"><div class="fast_log"><table><tr><td><img src="/images/npcs/training_boss.png" width="36px"></td><td valign="top"><small><font color="#E0E0E0">Тебе не по силам одолеть меня! И уж тем более в одиночку! Жалкое создание...</small></font></td></table></div>';
}
//Поле боя
//Быстрые логи
if($end != 1){
echo '<td width="50%" valign="top">';
if(isset($_SESSION['user_fast_log'])){
	echo '<div class="fast_log">';
	echo '<center>'.$_SESSION['user_fast_log'].'</center>';
	echo '</div>';
	unset($_SESSION['user_fast_log']);
}
echo '</td>';
echo '<td width="50%" valign="top">';
if(isset($_SESSION['enemy_fast_log'])){
	echo '<div class="fast_log">';
	echo '<center>'.$_SESSION['enemy_fast_log'].'</center>';
	echo '</div>';
	unset($_SESSION['enemy_fast_log']);
}
echo '</td>';
}
echo '</td></tr></table>';

echo '<table width="100%" height="78%" style="position: relative;"><tr><td width="50%"><center><div style="position: absolute; bottom: 35%; left: 10%; width: 35%;">';
echo '<font style="text-shadow: black 1px 1px 1px; color: #FFFFFF; font-size: 12px;">'.$u['login'].'</font><br/>
<div class="hp_small" style="background-size: '.$now_hp.'% 2px;"></div><br/>
<div class="mp_small" style="background-size: '.$now_mp.'% 2px;"></div><br/><img src="/images/skins/'.$skin.'.gif"></div><center></td>';
if($end != 1){
	echo '<td width="50%" style="position: relative;"><center><small><font style="text-shadow: black 1px 1px 1px; color: #FFFFFF;">Азазель</font></small><br/><a href="/training/'.$u['training_step'].'/attack/"><img style="max-height: 120px;" src="/images/mobs/bosses/training_boss.gif" width="100px"></a></center><center><div class="hp" style="width: 75%; background-size: '.$now_boss_hp.'% 12px; text-shadow: black 0 1px 0; text-align: left;"><font color="#E0E0E0" size="1">HP: '.n_f($tb['boss_hp']).'/'.n_f($tb['boss_max_hp']).'</font></div></center><br/><br/>';
}else{
	echo '<td width="50%" style="position: relative;"><center><small><font style="text-shadow: black 1px 1px 1px; color: #FFFFFF;">Азазель</font></small><br/><a href="/training/next/"><img style="max-height: 120px;" src="/images/mobs/bosses/training_boss.gif" width="100px"></a></center><center><div class="hp" style="width: 75%; background-size: '.$now_boss_hp.'% 12px; text-shadow: black 0 1px 0; text-align: left;"><font color="#E0E0E0" size="1">HP: '.n_f($tb['boss_hp']).'/'.n_f($tb['boss_max_hp']).'</font></div></center><br/><br/>';
}
if($end != 1){
	echo '<div style="position: absolute; bottom: 0.5%; right: 0.5%;"><a href="/training/'.$u['training_step'].'/attack/"><img  src="/images/items/training_sword.png" style="border: 1px solid #DD4FFF;" width="42px"></a></div>';
}
echo '</td></tr></table></div></div>';
if($end != 1){
//Пояс и умения
echo '<center><table style="width: 100%; max-width: 303px;" cellspacing="3px"><tr><td class="event" width="50%"><a href="/training/'.$u['training_step'].'/hp/" class="potion" style="width: 42px; height: 42px; border: 1px solid #B1B1B1;"><div style="background: url(/images/items/resource/hp_500.png) no-repeat center; background-size: 100%; display: inline-block; width: 42; height: 42px;">
	<div style="padding-top: 70%; padding-right: 3px;"><font style="text-shadow: black 1px 1px 1px; color: #e0e0e0; font-size: 10px; float: right;">'.$tb['hp_bottles'].'</font></div></div></a>';
echo '<a href="/training/'.$u['training_step'].'/mp/" class="potion" style="width: 42px; height: 42px; border: 1px solid #B1B1B1;"><div style="background: url(/images/items/resource/mp_500.png) no-repeat center; background-size: 100%; display: inline-block; width: 42; height: 42px;"><div style="padding-top: 70%; padding-right: 3px;"><font style="text-shadow: black 1px 1px 1px; color: #e0e0e0; font-size: 10px; float: right;">'.$tb['mp_bottles'].'</font></div></div></a>';
echo '<div class="potion" style="border: 1px solid gray; height: 31px; width: 42px;font-size: 13px; padding-top: 11px; display: inline-block; color: gray;">пусто</div></td>';
echo '<td class="event" width="50%"><a href="/training/'.$u['training_step'].'/skill/1/" class="skill" style="width: 42px; height: 42px; border: 1px solid orangered;"><div style="background: url(/images/skills/meteor_rain.png) no-repeat center; background-size: 100%; display: inline-block; width: 42px; height: 42px;"></div></a>';
echo '<a href="/training/'.$u['training_step'].'/skill/2/" class="skill" style="width: 42px; height: 42px; border: 1px solid orangered;"><div style="background: url(/images/skills/fireball.png) no-repeat center; background-size: 100%; display: inline-block; width: 42px; height: 42px;"></div></a>';
echo '<a href="/training/'.$u['training_step'].'/skill/3/" class="skill" style="width: 42px; height: 42px; border: 1px solid limegreen;"><div style="background: url(/images/skills/healing_wave.png) no-repeat center; background-size: 100%; display: inline-block; width: 42px; height: 42px;"></div></a></td></tr></table></center>';
}

//Сражён
if($end == 1) echo '<center><a class="btn_small" href="/training/next/">Продолжить</a></center>';

//Футер
echo '</div></div></div><div class="b_foot"><table width="100%"><tr><td valign="top" width="20%"><center>';
echo '<div class="foot_btn_off"><img src="/images/icons/menu.png"><br/>Меню</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/icons/location.png"><br/>Локация</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/skins/'.$sex.'_big.png" width="32px"><br/>Персонаж</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/icons/bag.png"><br/>Инвентарь</div></center></td><td valign="top" width="20%"><center><a href="?"><div class="foot_btn"><img src="/images/icons/refresh.png"><br/>Обновить';
echo '</center></td></tr></table></div></div>';
}

break;

case '9':

if($u['sex'] == 1) $sex = 1;
else $sex = 14;

//Хэдер
echo '<body><div class="page"><div class="sticky_header"><table width="100%" class="a_table a_table-common" style="border-collapse: collapse;"><tr><td width="45%">';
echo '<div class="exp" style="background-size: 100% 12px; text-shadow: black 0 1px 0;"><font size="1">EXP: 100% <div style="float: right;">LV:100</div></font></div>';
echo '<div class="hp" style="background-size: 100% 12px; text-shadow: black 0 1px 0;"><font size="1">HP: 10K/10K</font></div>';
echo '<div class="mp" style="background-size: 100% 12px; text-shadow: black 0 1px 0;"><font size="1">MP: 10К/10К</font></div>';
echo '</td><td width="19%" valign="top"><div style="text-shadow: black 0 1px 0;"><a href="/gold/"><img src="/images/icons/silver.png"  width="16px"><font size="2">10M</font></a><br/>';
echo '<a href="/gold/"><img src="/images/icons/gold.png" width="16px"><font color="gold" size="2">10M</font></a>';
echo '</div></td><td width="36%" align="right" valign="top"><a class="btn_smallest" href="https://vk.com/avalormobi"><img src="/images/vk.png" width="20px"></a><a class="btn_smallest" href="https://t.me/joinchat/AAAAAFXi5EIjuCJfSiMxsg"><img src="/images/telegram.png" width="20px"></a><a class="btn_smallest" href="/fresh_news/"><img src="/images/icons/bell.png" width="20px"></a><a class="btn_smallest" href="/mail/"><img src="/images/icons/mail.png" width="20px"></a><br/><font style="float: right; font-size: 11px; color: #9090A1; text-shadow: black 0 1px 0;">BETA</font></td></tr></table></div>';

//Фон
echo '<div class="body"><div class="border" style="position: relative; margin-top: 5px; box-sizing: border-box;"><div style="width: 100%; max-width: 336px; height: 248px; background: url(/images/locations/backgrounds/training_ocean.png) no-repeat center;">';
//Указатель
echo '<div style="position: absolute; bottom: -25%; right: 36%; z-index: 9999;"><a href="/training/next/"><img src="/images/cursor.gif"></a></div>';

echo '<table width="100%" height="65%" style="font-size: 11px; text-shadow: black 1px 1px 1px; color: white;"><tr>';
//Речь наставника
if($u['sex'] == 1){
	$a = '';
	$b = 'ся';
}else{
	$a = 'a';
	$b = 'ась';
}
echo '<td width="100%" valign="top"><div class="fast_log"><table><tr><td><img src="/images/npcs/ernest.png" width="36px"></td><td valign="top"><small><font color="#E0E0E0"><b>Эрнест:</b> Я нашёл тебя без сознания неподалёку от небольшого городка, Эллертон. Ты не помнил'.$a.' как тебя зовут, и как здесь очутил'.$b.', и лишь бормотал'.$a.' Азазель... Азазель... Нужно его остановить...<br/>О ком ты говорил'.$a.', я понятия не имею, но тем не менее, понимал, что нужно помочь.</small></font></td></table></div>';
echo '</td></tr></table>';
//Игрок
echo '<center><img src="/images/skins/'.$sex.'_dead.gif"></center>';

echo '</div></div>';

echo '<center><a class="btn_small" href="/training/next/">Продолжить</a></center>';

//Футер
echo '</div></div></div><div class="b_foot"><table width="100%"><tr><td valign="top" width="20%"><center>';
echo '<div class="foot_btn_off"><img src="/images/icons/menu.png"><br/>Меню</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/icons/location.png"><br/>Локация</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/skins/'.$sex.'_big.png" width="32px"><br/>Персонаж</div></center></td><td valign="top" width="20%"><center><div class="foot_btn_off"><img src="/images/icons/bag.png"><br/>Инвентарь</div></center></td><td valign="top" width="20%"><center><a href="?"><div class="foot_btn"><img src="/images/icons/refresh.png"><br/>Обновить';
echo '</center></td></tr></table></div></div>';


break;

case '10':

$base -> query('DELETE FROM `training_battle` WHERE `user` = "'.$u['id'].'"');
unset($_SESSION['user_fast_log']);
unset($_SESSION['enemy_fast_log']);
header('Location: /location/');
exit;

break;

case '11':

header('Location: /location/');
exit;

break;

case '12':

header('Location: /location/');
exit;

break;

case '13':

header('Location: /location/');
exit;

break;

case '14':

$base -> query('UPDATE `users` SET `x` = "6", `y` = "-1" WHERE `id` = "'.$u['id'].'" LIMIT 1');

header('Location: /location/');
exit;

break;

case '15':

header('Location: /location/');
exit;

break;

case '16':

header('Location: /location/');
exit;

break;

case '17':

$base -> query('UPDATE `users` SET `training_step` = "0", `training_location` = "0" WHERE `id` = "'.$u['id'].'" LIMIT 1');
$_SESSION['message'] = 'Обучение пройдено!';
header('Location: /location/');
exit;

break;

}


include_once ('./core/foot.php');
?>