<?php
$t = 'Приросты мощи';
require_once 'wcore/core.php';
require_once 'wcore/head.php';
iank();

echo '<center><div class="titles">Могущество</div></center>';

echo '<style>.game { background: url("/img/game_bg/fuligonggao.png"); }</style>';

	echo $_SESSION['msg'];
	$_SESSION['msg'] = NULL;
	
	$p1 = ($ank['potence_level'] < 100) ? (1160*($ank['potence_level']+1)) : 'MAX';
	$p2 = ($ank['potence_level'] < 100) ? (360*($ank['potence_level']+1)) : 'MAX';
	$p3 = ($ank['potence_level'] < 100) ? (260*($ank['potence_level']+1)) : 'MAX';
	$p4 = ($ank['potence_level'] < 100) ? (360*($ank['potence_level']+1)) : 'MAX';
	$boop = (10*($ank['potence_level']+1));
	
	$rp1 = ($ank['reincarnation_level'] < 5) ? (100*($ank['reincarnation_level']+1)) : 'MAX';
	$rp2 = ($ank['reincarnation_level'] < 5) ? (100*($ank['reincarnation_level']+1)) : 'MAX';
	$rp3 = ($ank['reincarnation_level'] < 5) ? (100*($ank['reincarnation_level']+1)) : 'MAX';
	$rp4 = ($ank['reincarnation_level'] < 5) ? (100*($ank['reincarnation_level']+1)) : 'MAX';
	$rs = (50*($ank['reincarnation_level']+1));

if(isset($_GET['reincarnation'])){
		
		if(isset($_GET['update']) && $ank['reincarnation_level'] < 5){
			if($ank['reincarnation_stones'] >= $rs){
				mysqli_query($mysqli,"UPDATE `users` SET `level` = '". ($ank['level']-10) ."', `reincarnation_stones` = '". ($ank['reincarnation_stones']-$rs) ."', `reincarnation_level` = `reincarnation_level` + 1, `reincarnation_bonus_p1` = `reincarnation_bonus_p1` + 1, `reincarnation_bonus_p2`= `reincarnation_bonus_p2` + 1, `reincarnation_bonus_p3` = `reincarnation_bonus_p3` + 1, `reincarnation_bonus_p4` = `reincarnation_bonus_p4` + 1 WHERE `id` = '". $ank['id'] ."'");
				$_SESSION['msg'] = $sd . 'Вы успешно реинкарнировались!' . $_sd;
				header('Location: /potence.php?reincarnation');
				exit;
			}else{
				$_SESSION['msg'] = $ed . 'Недостаточно камней реинкарнации!' . $_ed;
				header('Location: /potence.php?reincarnation');
				exit;
			}
		}
	
	echo '<center>Реинкарнация</center>';
	echo '<table width="100%"><tbody><tr>
	<td width="50%" style="background: #00000050; padding: 3px 7px; border: 1px solid #333333; border-top-left-radius: 6px; border-top-right-radius: 6px;">Сейчас</td>
	<td width="50%" style="background: #adebad50; padding: 3px 7px; border: 1px solid #adebad75; border-top-left-radius: 6px; border-top-right-radius: 6px; color: #7BF336;">Будет</td>
	</tr><tr>
	<td width="50%" style="background: #00000050; padding: 3px 7px; border: 1px solid #333333; border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; font-size: 13px;">
	<div style="margin: -1px;">Уровень <span class="params" style="float: right; display: block; width: 40%; text-align: right;">'. $reincarnation . $ank['level'] .'</span></div><br>
	<div style="margin: -1px;">Сила <span class="params" style="float: right; display: block; width: 40%; text-align: right;">'. ($ank['reincarnation_bonus_p1']*100) .'%</span></div><br>
	<div style="margin: -1px;">Сила <span class="params" style="float: right; display: block; width: 40%; text-align: right;">'. ($ank['reincarnation_bonus_p2']*100) .'%</span></div><br>
	<div style="margin: -1px;">Защита <span class="params" style="float: right; display: block; width: 40%; text-align: right;">'. ($ank['reincarnation_bonus_p3']*100) .'%</span></div><br>
	<div style="margin: -1px;">Скорость <span class="params" style="float: right; display: block; width: 40%; text-align: right;">'. ($ank['reincarnation_bonus_p4']*100) .'%</span></div>
	</td>
	<td width="50%" style="background: #adebad50; padding: 3px 7px; border: 1px solid #adebad75; border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; font-size: 13px; color: #7BF336;">
	<div style="margin: -1px;">Уровень <span class="params" style="float: right; display: block; width: 40%; text-align: right;">Р'. ($ank['reincarnation_level']+1) .'. '. ($ank['level']-10) .'</span></div><br>
	<div style="margin: -1px;">Здоровье <span class="params" style="float: right; display: block; width: 40%; text-align: right;">'. $rp1 .'%</span></div><br>
	<div style="margin: -1px;">Сила <span class="params" style="float: right; display: block; width: 40%; text-align: right;">'. $rp2 .'%</span></div><br>
	<div style="margin: -1px;">Защита <span class="params" style="float: right; display: block; width: 40%; text-align: right;">'. $rp3 .'%</span></div><br>
	<div style="margin: -1px;">Скорость <span class="params" style="float: right; display: block; width: 40%; text-align: right;">'. $rp4 .'%</span></div>
	</td>
	</tr></tbody></table>';
	
	if($ank['reincarnation_level'] < 5){
		echo '<center>Камней реинкарнации: '. $ank['reincarnation_stones'] .' / ' . $rs;
		echo '<br><a href="?reincarnation&update" class="button">Реинкарнация</a></center>';
	}
	
	echo '<center><a href="/potence.php" class="button">Назад</a></center>';
		
}else{
		
		if(isset($_GET['update']) && $ank['potence_level'] < 100){
			if($ank['boop'] >= $boop){
				mysqli_query($mysqli,"UPDATE `users` SET `boop` = '". ($ank['boop']-$boop) ."', `potence_level` = `potence_level` + 1, `potence_bonus_p1` = `potence_bonus_p1` + 1160, `potence_bonus_p2`= `potence_bonus_p2` + 360, `potence_bonus_p3` = `potence_bonus_p3` + 260, `potence_bonus_p4` = `potence_bonus_p4` + 360, `param_1` = `param_1` + 1160, `param_2` = `param_2` + 360, `param_3` = `param_3` + 260, `param_4` = `param_4` + 360 WHERE `id` = '". $ank['id'] ."'");
				$_SESSION['msg'] = $sd . 'Вы успешно улучшили могущество!' . $_sd;
				header('Location: /potence.php');
				exit;
			}else{
				$_SESSION['msg'] = $ed . 'Недостаточно книг могущества!' . $_ed;
				header('Location: /potence.php');
				exit;
			}
		}
		
	echo '<center>Уровень могущества: ' . $ank['potence_level'] . ' / 100';
	echo '<table width="100%"><tbody><tr>
	<td width="50%" style="background: #00000050; padding: 3px 7px; border: 1px solid #333333; border-top-left-radius: 6px; border-top-right-radius: 6px;">Сейчас</td>
	<td width="50%" style="background: #adebad50; padding: 3px 7px; border: 1px solid #adebad75; border-top-left-radius: 6px; border-top-right-radius: 6px; color: #7BF336;">Будет</td>
	</tr><tr>
	<td width="50%" style="background: #00000050; padding: 3px 7px; border: 1px solid #333333; border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; font-size: 13px;">
	<div style="margin: -1px;">Здоровье <span class="params" style="float: right; display: block; width: 40%; text-align: right;">'. $ank['potence_bonus_p1'] .'</span></div><br>
	<div style="margin: -1px;">Сила <span class="params" style="float: right; display: block; width: 40%; text-align: right;">'. $ank['potence_bonus_p2'] .'</span></div><br>
	<div style="margin: -1px;">Защита <span class="params" style="float: right; display: block; width: 40%; text-align: right;">'. $ank['potence_bonus_p3'] .'</span></div><br>
	<div style="margin: -1px;">Скорость <span class="params" style="float: right; display: block; width: 40%; text-align: right;">'. $ank['potence_bonus_p4'] .'</span></div>
	</td>
	<td width="50%" style="background: #adebad50; padding: 3px 7px; border: 1px solid #adebad75; border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; font-size: 13px; color: #7BF336;">
	<div style="margin: -1px;">Здоровье <span class="params" style="float: right; display: block; width: 40%; text-align: right;">'. $p1 .'</span></div><br>
	<div style="margin: -1px;">Сила <span class="params" style="float: right; display: block; width: 40%; text-align: right;">'. $p2 .'</span></div><br>
	<div style="margin: -1px;">Защита <span class="params" style="float: right; display: block; width: 40%; text-align: right;">'. $p3 .'</span></div><br>
	<div style="margin: -1px;">Скорость <span class="params" style="float: right; display: block; width: 40%; text-align: right;">'. $p4 .'</span></div>
	</td>
	</tr></tbody></table>';

	if($ank['potence_level'] < 100){
		echo '<center>Книг могущества: '. $ank['boop'] .' / ' . $boop;
		echo '<br><a href="?update" class="button">Улучшить</a></center>';
	}
	
	echo '<center><a href="?reincarnation" class="button">Реинкарнация</a>';
	
	echo '<a href="/potence.php" class="button">Назад</a></center>';
	
}

require_once 'wcore/foot.php';
?>