<?
require_once '../core/system.php';
$header = 'Обменник камней';
require_once '../core/head.php';




if($user[level] < 7){
echo "<div class='player center'>";
echo "<img src='/images/town/gold.png'>";
echo "<li><b>Для обмена требуется <img src='/images/icon/level.png'> 7 уровень.</b></li>";
echo "<li><b>Ваш уровень: <img src='/images/icon/level.png'> $user[level]</b></li>";
echo "</div>";
}


if($user[level] >= 7){
switch($act) {
case '1':
if($user[kamni] > 99){
mysql_query("UPDATE `user` SET `kamni` = '".($user['kamni']-100)."', `gold` = '".($user['gold']+30)."' WHERE `id` = '$user[id]' LIMIT 1");
header('Location: ?');
$_SESSION['message'] = 'Обмен выполнен!';
exit();
}else{
header('Location: ?');
$_SESSION['err'] = 'Не достаточно камней!';
exit();
}
break;
case '2':
if($user[kamni] > 49){
mysql_query("UPDATE `user` SET `kamni` = '".($user['kamni']-50)."', `gold` = '".($user['gold']+15)."' WHERE `id` = '$user[id]' LIMIT 1");
header('Location: ?');
$_SESSION['message'] = 'Обмен выполнен!';
exit();
}else{
header('Location: ?');
$_SESSION['err'] = 'Не достаточно камней!';
exit();
}
break;
case '3':
if($user[kamni] > 24){
mysql_query("UPDATE `user` SET `kamni` = '".($user['kamni']-24)."', `gold` = '".($user['gold']+10)."' WHERE `id` = '$user[id]' LIMIT 1");
header('Location: ?');
$_SESSION['message'] = 'Обмен выполнен!';
exit();
}else{
header('Location: ?');
$_SESSION['err'] = 'Не достаточно камней!';
exit();
}
break;
case '4':
if($user[kamni] > 9){
mysql_query("UPDATE `user` SET `kamni` = '".($user['kamni']-10)."', `gold` = '".($user['gold']+3)."' WHERE `id` = '$user[id]' LIMIT 1");
header('Location: ?');
$_SESSION['message'] = 'Обмен выполнен!';
exit();
}else{
header('Location: ?');
$_SESSION['err'] = 'Не достаточно камней!';
exit();
}
break;
default;
echo "<div class='player center'>";
echo "<img src='/images/town/gold.png'>";
echo "</div>";
echo "<div class='dot-line'></div>";
echo "<div class='player center blue'>";
echo "Обмен: <img src='/images/icon/kamni.png'> Камней на <img src='/images/icon/gold.png'> Золото";
echo "</div>";
echo "<div class='mini-line'></div>";
if($user[kamni] > 9){
echo "<div class='player menuList'>";
if($user[kamni] > 99)echo "<li><a href='?act=1'><img src='/images/icon/arrow.png'>Обменять <img src='/images/icon/kamni.png'><span class='white'>100</span> <span class='blue'>→ </span><img src='/images/icon/gold.png'><span class='white'>30</span></a></li>";
if($user[kamni] > 49)echo "<li><a href='?act=2'><img src='/images/icon/arrow.png'>Обменять <img src='/images/icon/kamni.png'><span class='white'>50</span> <span class='blue'>→ </span><img src='/images/icon/gold.png'><span class='white'>15</span></a></li>";
if($user[kamni] > 24)echo "<li><a href='?act=3'><img src='/images/icon/arrow.png'>Обменять <img src='/images/icon/kamni.png'><span class='white'>25</span> <span class='blue'>→ </span><img src='/images/icon/gold.png'><span class='white'>10</span></a></li>";
if($user[kamni] > 9)echo "<li><a href='?act=4'><img src='/images/icon/arrow.png'>Обменять <img src='/images/icon/kamni.png'><span class='white'>10</span> <span class='blue'>→ </span><img src='/images/icon/gold.png'><span class='white'>3</span></a></li>";
echo "</div>";
}else{
echo "<div class='player'>У вас не достаточно камней!</div>";
}
echo "<div class='mini-line'></div>";

}
}

require_once '../core/foot.php';
?>