Файл: weatut.ru/pit.php
Строк: 47
<?php
require_once ('system/func.php');
auth(); // Закроем от не авторизованных
$pit = mysql_query("SELECT * FROM `pit_users` WHERE `id_user` = '".$myID."' ORDER BY `id` LIMIT 1");
$pit = mysql_fetch_array($pit);
function cost($i) {
switch($i) {
case 0:
$cost = 200;
break;
case 1:
$cost = 400;
break;
case 2:
$cost = 600;
break;
case 3:
$cost = 800;
break;
case 4:
$cost = 1000;
break;
case 5:
$cost = 1;
break;
case 6:
$cost = 1600;
break;
case 7:
$cost = 3200;
break;
case 8:
$cost = 4800;
break;
case 9:
$cost = 6400;
break;
case 10:
$cost = 8000;
break;
case 11:
$cost = 10;
break;
case 12:
$cost = 2400;
break;
case 13:
$cost = 4800;
break;
case 14:
$cost = 7200;
break;
case 15:
$cost = 9600;
break;
case 16:
$cost = 12000;
break;
case 17:
$cost = 20;
break;
case 18:
$cost = 3200;
break;
case 19:
$cost = 7200;
break;
case 20:
$cost = 10800;
break;
case 21:
$cost = 14400;
break;
case 22:
$cost = 18000;
break;
case 23:
$cost = 40;
break;
case 24:
$cost = 3600;
break;
case 25:
$cost = 7200;
break;
case 26:
$cost = 10800;
break;
case 27:
$cost = 14400;
break;
case 28:
$cost = 18000;
break;
case 29:
$cost = 80;
break;
case 30:
$cost = 4800;
break;
case 31:
$cost = 9600;
break;
case 32:
$cost = 14400;
break;
case 33:
$cost = 19200;
break;
case 34:
$cost = 24000;
break;
case 35:
$cost = 160;
break;
case 36:
$cost = 5600;
break;
case 37:
$cost = 11200;
break;
case 38:
$cost = 16800;
break;
case 39:
$cost = 22400;
break;
case 40:
$cost = 28000;
break;
case 41:
$cost = 320;
break;
case 42:
$cost = 6400;
break;
case 43:
$cost = 12800;
break;
case 44:
$cost = 19200;
break;
case 45:
$cost = 25600;
break;
case 46:
$cost = 32000;
break;
case 47:
$cost = 640;
break;
case 48:
$cost = 7200;
break;
case 49:
$cost = 14400;
break;
case 50:
$cost = 21600;
break;
case 51:
$cost = 28800;
break;
case 52:
$cost = 36000;
break;
case 53:
$cost = 1280;
break;
case 54:
$cost = 5000;
break;
case 55:
$cost = 16000;
break;
case 56:
$cost = 24000;
break;
case 57:
$cost = 32000;
break;
case 58:
$cost = 40000;
break;
case 59:
$cost = 2560;
break;
}
global $user;
global $auction;
## Акция ##
//if($auction == 1 and $user[auction] >= 500)$cost -= ceil($cost*25/100);
###########
return $cost;
}
function value($i) {
switch($i) {
case 0:
$value = 'crystals';
break;
case 1:
$value = 'crystals';
break;
case 2:
$value = 'crystals';
break;
case 3:
$value = 'crystals';
break;
case 4:
$value = 'crystals';
break;
case 5:
$value = 'gold';
break;
case 6:
$value = 'crystals';
break;
case 7:
$value = 'crystals';
break;
case 8:
$value = 'crystals';
break;
case 9:
$value = 'crystals';
break;
case 10:
$value = 'crystals';
break;
case 11:
$value = 'gold';
break;
case 12:
$value = 'crystals';
break;
case 13:
$value = 'crystals';
break;
case 14:
$value = 'crystals';
break;
case 15:
$value = 'crystals';
break;
case 16:
$value = 'crystals';
break;
case 17:
$value = 'gold';
break;
case 18:
$value = 'crystals';
break;
case 19:
$value = 'crystals';
break;
case 20:
$value = 'crystals';
break;
case 21:
$value = 'crystals';
break;
case 22:
$value = 'crystals';
break;
case 23:
$value = 'gold';
break;
case 24:
$value = 'crystals';
break;
case 25:
$value = 'crystals';
break;
case 26:
$value = 'crystals';
break;
case 27:
$value = 'crystals';
break;
case 28:
$value = 'crystals';
break;
case 29:
$value = 'gold';
break;
case 30:
$value = 'crystals';
break;
case 31:
$value = 'crystals';
break;
case 32:
$value = 'crystals';
break;
case 33:
$value = 'crystals';
break;
case 34:
$value = 'crystals';
break;
case 35:
$value = 'gold';
break;
case 36:
$value = 'crystals';
break;
case 37:
$value = 'crystals';
break;
case 38:
$value = 'crystals';
break;
case 39:
$value = 'crystals';
break;
case 40:
$value = 'crystals';
break;
case 41:
$value = 'gold';
break;
case 42:
$value = 'crystals';
break;
case 43:
$value = 'crystals';
break;
case 44:
$value = 'crystals';
break;
case 45:
$value = 'crystals';
break;
case 46:
$value = 'crystals';
break;
case 47:
$value = 'gold';
break;
case 48:
$value = 'crystals';
break;
case 49:
$value = 'crystals';
break;
case 50:
$value = 'crystals';
break;
case 51:
$value = 'crystals';
break;
case 52:
$value = 'crystals';
break;
case 53:
$value = 'gold';
break;
case 54:
$value = 'crystals';
break;
case 55:
$value = 'crystals';
break;
case 56:
$value = 'crystals';
break;
case 57:
$value = 'crystals';
break;
case 58:
$value = 'crystals';
break;
case 59:
$value = 'gold';
break;
}
return $value;
}
if(isset($_GET['train'])) {
if(!$pit) {
$_SESSION['msg'] = "У вас не куплен Питомец...";
exit(header('Location: /pitomnik'));
}
if($pit['level'] != 60) {
if(value($pit['level']) == 'crystals') {
if($user['crystals'] < cost($pit['level'])) {
$_SESSION['msg'] = "Не хватает ".ico('icons','crystal.png')." ".(cost($pit['level'])-$user['crystals'])." кристалов";
header("Location: ?$random");
exit();
}else{
mysql_query('UPDATE `pit_users` SET
`str` = `str` + 1,
`def` = `def` + 1,
`health` = `health` + 1,
`level` = `level` + 1
WHERE `id` = "'.$pit['id'].'"');
mysql_query('UPDATE `users` SET
`str` = `str` + 1,
`def` = `def` + 1,
`max_health` = `max_health` + 1,
`crystals` = `crystals` - '.cost($pit['level']).'
WHERE `id` = "'.$myID.'"');
$_SESSION['msg'] = "Уровень питомца повышен";
header("Location: ?$random");
exit();
}
}elseif(value($pit['level'] == 'gold')) {
if($user['gold'] < cost($pit['level'])) {
$_SESSION['msg'] = "Не хватает ".ico('icons','gold.png')." ".(cost($pit['level'])-$user['gold'])." золота";
header("Location: ?$random");
exit();
}else{
mysql_query('UPDATE `pit_users` SET
`str` = `str` + 3,
`def` = `def` + 3,
`health` = `health` + 3,
`level` = `level` + 1
WHERE `id` = "'.$pit['id'].'"');
mysql_query('UPDATE `users` SET
`str` = `str` + 3,
`def` = `def` + 3,
`max_health` = `max_health` + 3,
`gold` = `gold` - '.cost($pit['level']).'
WHERE `id` = "'.$myID.'"');
$_SESSION['msg'] = "Уровень питомца повышен";
header("Location: ?$random");
exit();
}
}
}
}
$title = 'Питомник';
require_once ('system/header.php');
if($pit){
echo "<div class='block'>";
echo "<h1>".$pit['name'].", $pit[level]ур.</h1>";
echo "<div class='oh'><img src='/images/pits/$pit[item].png' style='margin-right:3px;margin-top:-2px;'></div>";
echo ico('icons','str.png')." Атака: $pit[str]<br>";
echo ico('icons','def.png')." Защита: $pit[def]<br>";
echo ico('icons','health.png')." Жизнь: $pit[health]<div style='clear:both;'></div>";
if($pit[level] != 60)echo "<hr><a href='?train' class='link center'>Тренировать за ".(value($pit['level']) == 'gold' ? ico('icons','gold.png') : ico('icons','crystal.png'))." ".cost($pit['level'])."</a>";
echo "</div>";
}else{
echo "<div class='block'>У вас нет питомца...</div>";
}
require_once ('system/footer.php');
?>