Файл: public_html/element_energy.php
Строк: 143
<?php
require_once './element_options/element_options.php';
if (!$user) { header('Location: /'); exit; }
//$user['lost_params_training'] = '0:0:0';
//writecache('element_users_id_'.$user['lost_id'],$user);
function cena_masters($count) {
$array = array( array(100), array(124), array(148), array(185), array(250), array(291), array(339), array(392),
array(500), array(573), array(661), array(742), array(800), array(891), array(994), array(1123),
array(1300), array(1452), array(1613), array(1794), array(2100), array(2324), array(2487), array(2750),
array(3000), array(3354), array(3719), array(4123), array(4500), array(4987), array(5523), array(6246),
array(6500), array(7345), array(8134), array(8934), array(10000), array(11032), array(12134), array(13345),
array(15000), array(16405), array(17943), array(19943));
$return = $array[$count];
if (is_array($return)) { $q = 'gold'; $return = $array[$count][0]; } else $q = 'cristall';
return array($q, $return, count($array));
}
$training = explode(':', $user['lost_params_training']);
$title = 'Энергетик';
require_once './element_include/element_head.php';
require_once './element_include/element_header_user_true.php';
if (empty($training[3]))
{
$training[3] = 0;
}
if (isset($_GET['up_en'])) {
$cena_str = cena_masters($training[3]);
if ($training[3] < $cena_str[2]) {
if ($cena_str[3] == 'cristall') {
if ($user['lost_resourse_cristalls'] < $cena_str[1])
$error = '<span class="red">Вам не хватает <img src="/images/icons/cristall.png"> '.($cena_str[1] - $user['lost_resourse_cristalls']).' кристаллов</span><br/><a class="button w40 mt5 mb5" href="/gold"><span class="ttl">Купить кристаллы</span></a>';
if (!isset($error)) {
$training[3] = $training[3] + 1;
$like_this = explode(':', $user['lost_params_energy']);
$like_this[1] += 1;
$user['lost_params_energy'] = implode(':', $like_this);
writecache('element_users_id_'.$user['lost_id'], $user);
user_list_update($user['lost_id']);
$user['lost_params_training'] = implode(':',$training);
update_money_exp($user, 0, -$cena_str[1], 0, 0);
header('Location: ?go=training');
exit;
} else echo '<div class="nfl p5 mb5 cntr small mlra">'.$error.'</div>';
} else if ($cena_str[0] == 'gold') {
if ($user['lost_money_gold'] < $cena_str[1])
$error = '<span class="red">Вам не хватает <img src="/images/icons/gold.png">'.($cena_str[1] - $user['lost_money_gold']).' золота</span><br/><a class="button w40 mt5 mb5" href="/payment"><span class="ttl">Купить золото</span></a>';
if (!isset($error)) {
$training[3] = $training[3] + 1;
$like_this = explode(':', $user['lost_params_energy']);
$like_this[1] += 1;
$user['lost_params_energy'] = implode(':', $like_this);
writecache('element_users_id_'.$user['lost_id'], $user);
user_list_update($user['lost_id']);
$user['lost_params_training'] = implode(':',$training);
update_money_exp($user, 0, 0, 0, -$cena_str[1]);
header('Location: ?go=training');
exit;
} else echo '<div class="nfl p5 mb5 cntr small mlra">'.$error.'</div>';
}
}
}
echo '<div class="nfl p5 mb5 mt5 mlra small cntr">';
echo '<div class="mt5 mb5 cntr small mlra">';
$cena_str = cena_masters($training[3]);
echo '<div class="mt5 mb5">';
echo '<div class="moderator mb5 bold"><img src="/images/icons/strlen.png"> Энергия: '.$user_energy[1].'</div>';
echo '<span class="bl mb5 prg-bar"><span class="bl fl prg-green" style="width:'.(int)(($training[3] / $cena_str[2]) * 100).'%"> </span></span>';
echo '<div class="white mt5">Чем больше энергии, тем больше энергии!</div>';
echo ($training[3] < $cena_str[2]) ? '<a class="button w70 mt5" href="?go=training&up_en"><span class="ttl">Улучшить за <img src="/images/icons/'.$cena_str[0].'.png">'.$cena_str[1].'</span></a>' : '';
echo '</div>';
echo '<div class="yellow1">Энергетик поможет Вам прокачать максимальный запас Вашей энергии.<br/> Одно улучшение: +1 к параметрам</div>';
echo '</div></div>';
require_once './element_include/element_foot_user_true.php';
?>