<?php
require_once ('system/func.php');
if ($user['id_pet'] > 0) {
$title = 'Ваш Спутник';
}
else{
$title = 'Спутник';
}
require_once ('system/header.php');
auth(); // Закроем от не авторизованных
$pets = mysql_query("SELECT * FROM `pets`");
if ($user['id_pet'] <= 0) {
while ($pet = mysql_fetch_assoc($pets)) {
$shans = rand(1,2);
if (isset($_GET['yes'.$pet['id'].'']) and $shans == 1) {
if($user['gold'] < 500){
$_SESSION['msg'] = 'Не хватает золота';
header('location: ?');
exit();
}else{
mysql_query("UPDATE `users` SET `id_pet` = ".$pet['id'].", `str` = `str` + ".$pet['str'].", `max_health` = `max_health` + ".$pet['health'].", `def` = `def` + ".$pet['def'].", `p_str` = `p_str` + ".$pet['str'].", `p_health` = `p_health` + ".$pet['health'].", `p_def` = `p_def` + ".$pet['def'].", `pet_lvl` = ".$pet['lvl'].", `gold` = `gold` - 500 WHERE (`id` = '".$user['id']."')");
$_SESSION['msg'] = '<font color="green">Удача</font><br />Поздравляем ты смог приручить Спутник. Воистину ты великий человек! Твои Силы возрасли, +'.$pet['str'].' Атака '.ico('icons', 'str.png').' +'.$pet['health'].' Жизни '.ico('icons', 'health.png').' +'.$pet['def'].' Защита '.ico('icons', 'def.png').'';
header('location: ?');
exit();
}
}
elseif(isset($_GET['yes'.$pet['id'].'']) and $shans == 2){
if($user['gold'] < 500){
$_SESSION['msg'] = 'Не хватает золота';
header('location: ?');
exit();
}else{
mysql_query("UPDATE `users` SET `gold` = `gold` - 500 WHERE (`id` = '".$user['id']."')");
$_SESSION['msg'] = '<font color="red">Неудача</font><br />Ты не смог приручить Спутника. Ты пока не достоин. Попробуй с другим, может получиться. Затраты - 500 золота '.ico('icons', 'gold.png').'';
header('location: ?');
exit();
}
}
echo '<div class = "block center"><img src="'.$pet['img'].'"/><br /><hr>
<strong>Имя: </strong> ' .$pet['name']. '<br /><hr>
<strong>Информация: </strong> ' .$pet['text']. '<br /><hr>
+'.$pet['str'].' Атака '.ico('icons', 'str.png').' +'.$pet['health'].' Жизни '.ico('icons', 'health.png').' +'.$pet['def'].' Защита '.ico('icons', 'def.png').'<br /></div>
<a href="?yes'.$pet['id'].'" class="link center">Приручить за <font color="gold">500 золота</font> '.ico('icons', 'gold.png').'</a>';
}
echo '<font color="orange">- Шанс приручить спутника 50/50. При неудачи ты лишь потеряешь Золото<br />
- В дальнейшем твой спутник будет увеличивать свои силы благодаря тебе</font>';
}
$mypet = mysql_fetch_assoc(mysql_query("SELECT * FROM `pets` WHERE (`id` = '".$user['id_pet']."')"));
if ($user['id_pet'] > 0) {
function cost($e) {
switch($e) {
case 0:
$cost = 200;
break;
case 1:
$cost = 4000;
break;
case 2:
$cost = 6000;
break;
case 3:
$cost = 8000;
break;
case 4:
$cost = 10000;
break;
case 5:
$cost = 100;
break;
case 6:
$cost = 16000;
break;
case 7:
$cost = 32000;
break;
case 8:
$cost = 48000;
break;
case 9:
$cost = 64000;
break;
case 10:
$cost = 80000;
break;
case 11:
$cost = 200;
break;
case 12:
$cost = 24000;
break;
case 13:
$cost = 48000;
break;
case 14:
$cost = 72000;
break;
case 15:
$cost = 96000;
break;
case 16:
$cost = 120000;
break;
case 17:
$cost = 500;
break;
case 18:
$cost = 32000;
break;
case 19:
$cost = 72000;
break;
case 20:
$cost = 108000;
break;
case 21:
$cost = 144000;
break;
case 22:
$cost = 180000;
break;
case 23:
$cost = 800;
break;
case 24:
$cost = 360000;
break;
case 25:
$cost = 720000;
break;
case 26:
$cost = 1080000;
break;
case 27:
$cost = 1440000;
break;
case 28:
$cost = 1800000;
break;
case 29:
$cost = 1000;
break;
case 30:
$cost = 480000;
break;
case 31:
$cost = 960000;
break;
case 32:
$cost = 1440000;
break;
case 33:
$cost = 1920000;
break;
case 34:
$cost = 2400000;
break;
case 35:
$cost = 1600;
break;
case 36:
$cost = 560000;
break;
case 37:
$cost = 1120000;
break;
case 38:
$cost = 1680000;
break;
case 39:
$cost = 2240000;
break;
case 40:
$cost = 2500;
break;
}
global $user;
global $auction;
return $cost;
}
function value($e) {
switch($e) {
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 = 'gold';
break;
}
return $value;
}
if(isset($_GET['kach'])) {
if($user['pet_lvl'] != 40) {
if(value($user['pet_lvl']) == 'crystals') {
if($user['crystals'] < cost($user['pet_lvl'])) {
$_SESSION['msg'] = "Не хватает ".ico('icons','crystal.png')." ".(cost($user['pet_lvl'])-$user['crystals'])." кристаллов";
header('Location: /pets.php?');
exit();
}else{
mysql_query('UPDATE `users` SET `str` = `str` + '.$mypet['str'].',`max_health` = `max_health` + '.$mypet['health'].',`def` = `def` + '.$mypet['def'].', `p_str` = `p_str` + '.$mypet['str'].',`p_health` = `p_health` + '.$mypet['health'].',`p_def` = `p_def` + '.$mypet['def'].', `pet_lvl` = `pet_lvl` + 1 WHERE `id` = "'.$user['id'].'"');
mysql_query('UPDATE `users` SET `crystals` = `crystals` - '.cost($user['pet_lvl']).' WHERE `id` = "'.$user['id'].'"');
$_SESSION['msg'] = '<strong>Увеличились Характеристики на:</strong> <br /> Атака +'.$mypet['str'].' '.ico('icons', 'str.png').' Жизни +'.$mypet['health'].' '.ico('icons', 'health.png').' Защита +'.$mypet['def'].' '.ico('icons', 'def.png').'<br />';
header('Location: /pets.php?');
exit();
}
}
elseif(value($user['pet_lvl'] == 'gold')) {
if($user['gold'] < cost($user['pet_lvl'])) {
$_SESSION['msg'] = "Не хватает ".ico('icons','gold.png')." ".(cost($user['pet_lvl'])-$user['gold'])." золота";
header('Location: /pets.php?');
exit();
}else{
mysql_query('UPDATE `users` SET `str` = `str` + '.$mypet['str'].',`max_health` = `max_health` + '.$mypet['health'].',`def` = `def` + '.$mypet['def'].', `p_str` = `p_str` + '.$mypet['str'].',`p_health` = `p_health` + '.$mypet['health'].',`p_def` = `p_def` + '.$mypet['def'].', `pet_lvl` = `pet_lvl` + 1 WHERE `id` = "'.$user['id'].'"');
mysql_query('UPDATE `users` SET `gold` = `gold` - '.cost($user['pet_lvl']).' WHERE `id` = "'.$user['id'].'"');
$_SESSION['msg'] = '<strong>Увеличились Характеристики на:</strong> <br /> Атака +'.$mypet['str'].' '.ico('icons', 'str.png').' Жизни +'.$mypet['health'].' '.ico('icons', 'health.png').' Защита +'.$mypet['def'].' '.ico('icons', 'def.png').'<br />';
header('Location: /pets.php?');
exit();
}
}
}
}
echo '<div class="block center"><img src="'.$mypet['img'].'"/><br /><hr>
<strong>Имя: </strong> ' .$mypet['name']. ' '. $user['pet_lvl'] . ' ' .ico('icons', 'level.png').'<br /><hr>
<strong>Информация: </strong> ' .$mypet['text']. '<br /><hr>
<font color="white"><p style="margin-bottom:1px;">Жизни: + '.$user['p_health'].' '.ico('icons', 'health.png').'</p><br/><p style="margin-bottom:1px;">Атака: + '.$user['p_str'].' '.ico('icons', 'str.png').'</p><br/><p >Защита: + '.$user['p_def'].' '.ico('icons', 'def.png').'</p><br/></font>
'.($user['pet_lvl'] != 40 ? '<strong>С каждым новым уровенем вы получаете: </strong><br /> +'.$mypet['str'].' Атака '.ico('icons', 'str.png').' +'.$mypet['health'].' Жизни '.ico('icons', 'health.png').' +'.$mypet['def'].' Защита '.ico('icons', 'def.png').'<br />' : '').'</div>';
if ($user['pet_lvl'] != 40) {
echo '<a href="?kach" class="link center">Улучшить за '.(value($user['pet_lvl']) == 'gold' ? ico('icons','gold.png') : ico('icons','crystal.png')).' '.cost($user['pet_lvl']).'</a>';
}
else {
echo '<center style="padding-bottom:10px;"><font color="orange">Спутник полностью прокачен до 40 '.ico('icons','level.png').'</font></center>';
}
}
require_once ('system/footer.php');
?>