<?php
$t = 'Тренировка';
require_once 'wcore/core.php';
require_once 'wcore/head.php';
iank();

$cost_1 = ($ank['train_1'] == 0) ? 5000 : ($ank['train_1']*5000);
$cost_2 = ($ank['train_2'] == 0) ? 5000 : ($ank['train_2']*5000);
$cost_3 = ($ank['train_3'] == 0) ? 5000 : ($ank['train_3']*5000);
$cost_4 = ($ank['train_4'] == 0) ? 5000 : ($ank['train_4']*5000);

if(isset($_GET['train_1'])){
	if($ank['train_1'] < 500){
		if($ank['gold'] >= $cost_1){
			mysqli_query($mysqli,"UPDATE `users` SET `param_1` = '". ( 1000 + $ank['param_1'] ) ."',
													 `train_1` = '". ( 1 + $ank['train_1'] ) ."',
													 `train_p1` = '". ( 1000 + $ank['train_p1'] ) ."',
													 `gold` = '". ( $ank['gold'] - $cost_1 ) ."' WHERE `id` = '". $ank['id'] ."'");
			$_SESSION['msg'] = $sd . 'Вы успешно тренировали здоровье на 1000 единиц!' . $_sd;
			go('/train.php');
			exit;
		}else{
			$_SESSION['msg'] = $ed . 'Не достаточно золота!' . $_ed;
			go('/train.php');
			exit;
		}
	}else{
		$_SESSION['msg'] = $wd . 'Максимальный уровень!' . $_wd;
		go('/train.php');
		exit;
	}
}

if(isset($_GET['train_2'])){
	if($ank['train_2'] < 500){
		if($ank['gold'] >= $cost_2){
			mysqli_query($mysqli,"UPDATE `users` SET `param_2` = '". ( 300 + $ank['param_2'] ) ."',
													 `train_2` = '". ( 1 + $ank['train_2'] ) ."',
													 `train_p2` = '". ( 300 + $ank['train_p2'] ) ."',
													 `gold` = '". ( $ank['gold'] - $cost_2 ) ."' WHERE `id` = '". $ank['id'] ."'");
			$_SESSION['msg'] = $sd . 'Вы успешно тренировали силу на 300 единиц!' . $_sd;
			go('/train.php');
			exit;
		}else{
			$_SESSION['msg'] = $ed . 'Не достаточно золота!' . $_ed;
			go('/train.php');
			exit;
		}
	}else{
		$_SESSION['msg'] = $wd . 'Максимальный уровень!' . $_wd;
		go('/train.php');
		exit;
	}
}

if(isset($_GET['train_3'])){
	if($ank['train_3'] < 500){
		if($ank['gold'] >= $cost_3){
			mysqli_query($mysqli,"UPDATE `users` SET `param_3` = '". ( 800 + $ank['param_3'] ) ."',
													 `train_3` = '". ( 1 + $ank['train_3'] ) ."',
													 `train_p3` = '". ( 800 + $ank['train_p3'] ) ."',
													 `gold` = '". ( $ank['gold'] - $cost_3 ) ."' WHERE `id` = '". $ank['id'] ."'");
			$_SESSION['msg'] = $sd . 'Вы успешно тренировали защиту на 800 единиц!' . $_sd;
			go('/train.php');
			exit;
		}else{
			$_SESSION['msg'] = $ed . 'Не достаточно золота!' . $_ed;
			go('/train.php');
			exit;
		}
	}else{
		$_SESSION['msg'] = $wd . 'Максимальный уровень!' . $_wd;
		go('/train.php');
		exit;
	}
}

if(isset($_GET['train_4'])){
	if($ank['train_4'] < 500){
		if($ank['gold'] >= $cost_4){
			mysqli_query($mysqli,"UPDATE `users` SET `param_4` = '". ( 150 + $ank['param_4'] ) ."',
													 `train_4` = '". ( 1 + $ank['train_4'] ) ."',
													 `train_p4` = '". ( 150 + $ank['train_p4'] ) ."',
													 `gold` = '". ( $ank['gold'] - $cost_4 ) ."' WHERE `id` = '". $ank['id'] ."'");
			$_SESSION['msg'] = $sd . 'Вы успешно тренировали скорость на 150 единиц!' . $_sd;
			go('/train.php');
			exit;
		}else{
			$_SESSION['msg'] = $ed . 'Не достаточно золота!' . $_ed;
			go('/train.php');
			exit;
		}
	}else{
		$_SESSION['msg'] = $wd . 'Максимальный уровень!' . $_wd;
		go('/train.php');
		exit;
	}
}

echo '<center><div class="titles">Тренировка</div></center>';

	echo $_SESSION['msg'];
	$_SESSION['msg'] = NULL;

echo '<div class="blocks"><table style="margin: -3px"><tbody><tr>
<td valign="middle" style="background: black;border-radius: 5px;"><img src="img/icons/train_p1.png" width="80px" height="80px"></td>
<td valign="middle" width="100%" style="font-size: 14px;">
<span style="font-size: 16px;border-bottom: 1px solid darkgray;">Здоровье: '. $ank['param_1'] .'</span><br>
Бонус к здоровью: <font color="green">+'. $ank['train_p1'] .'</font><br>
Уровень тренировки: '. $ank['train_1'] .' / 500<br>
'. ($ank['train_1'] == 500 ? '' : '<font size="3px">Цена: '.$cost_1.'<img src="/img/icons/200164.png" width="16px"></font>') .' '. ($ank['train_1'] == 500 ? '<span style="display: inline-block; float: right; border: 3px solid black; padding: 3px;margin: 0 -3px;border-radius: 5px;">MAX Уровень</span>' : '<a href="?train_1" style="display: inline-block; float: right; border: 3px solid black; padding: 3px;margin: 0 -3px;border-radius: 5px;">Тренироваться</a>') .'
</td>
</tr></tbody></table>
</div>';

echo '<div class="blocks"><table style="margin: -3px"><tbody><tr>
<td valign="middle" style="background: black;border-radius: 5px;"><img src="img/icons/train_p2.png" width="80px" height="80px"></td>
<td valign="middle" width="100%" style="font-size: 14px;">
<span style="font-size: 16px;border-bottom: 1px solid darkgray;">Сила: '. $ank['param_2'] .'</span><br>
Бонус к силе: <font color="green">+'. $ank['train_p2'] .'</font><br>
Уровень тренировки: '. $ank['train_2'] .' / 500<br>
'. ($ank['train_2'] == 500 ? '' : '<font size="3px">Цена: '.$cost_2.'<img src="/img/icons/200164.png" width="16px"></font>') .' '. ($ank['train_2'] == 500 ? '<span style="display: inline-block; float: right; border: 3px solid black; padding: 3px;margin: 0 -3px;border-radius: 5px;">MAX Уровень</span>' : '<a href="?train_2" style="display: inline-block; float: right; border: 3px solid black; padding: 3px;margin: 0 -3px;border-radius: 5px;">Тренироваться</a>') .'
</td>
</tr></tbody></table>
</div>';

echo '<div class="blocks"><table style="margin: -3px"><tbody><tr>
<td valign="middle" style="background: black;border-radius: 5px;"><img src="img/icons/train_p3.png" width="80px" height="80px"></td>
<td valign="middle" width="100%" style="font-size: 14px;">
<span style="font-size: 16px;border-bottom: 1px solid darkgray;">Защита: '. $ank['param_3'] .'</span><br>
Бонус к защите: <font color="green">+'. $ank['train_p3'] .'</font><br>
Уровень тренировки: '. $ank['train_3'] .' / 500<br>
'. ($ank['train_3'] == 500 ? '' : '<font size="3px">Цена: '.$cost_3.'<img src="/img/icons/200164.png" width="16px"></font>') .' '. ($ank['train_3'] == 500 ? '<span style="display: inline-block; float: right; border: 3px solid black; padding: 3px;margin: 0 -3px;border-radius: 5px;">MAX Уровень</span>' : '<a href="?train_3" style="display: inline-block; float: right; border: 3px solid black; padding: 3px;margin: 0 -3px;border-radius: 5px;">Тренироваться</a>') .'
</td>
</tr></tbody></table>
</div>';

echo '<div class="blocks"><table style="margin: -3px"><tbody><tr>
<td valign="middle" style="background: black;border-radius: 5px;"><img src="img/icons/train_p4.png" width="80px" height="80px"></td>
<td valign="middle" width="100%" style="font-size: 14px;">
<span style="font-size: 16px;border-bottom: 1px solid darkgray;">Скорость: '. $ank['param_4'] .'</span><br>
Бонус к скорости: <font color="green">+'. $ank['train_p4'] .'</font><br>
Уровень тренировки: '. $ank['train_4'] .' / 500<br>
'. ($ank['train_4'] == 500 ? '' : '<font size="3px">Цена: '.$cost_4.'<img src="/img/icons/200164.png" width="16px"></font>') .' '. ($ank['train_4'] == 500 ? '<span style="display: inline-block; float: right; border: 3px solid black; padding: 3px;margin: 0 -3px;border-radius: 5px;">MAX Уровень</span>' : '<a href="?train_4" style="display: inline-block; float: right; border: 3px solid black; padding: 3px;margin: 0 -3px;border-radius: 5px;">Тренироваться</a>') .'
</td>
</tr></tbody></table>
</div>';

require_once 'wcore/foot.php';
?>