Прикручиваем шаблон. Хороним идиотские ошибки.

This commit is contained in:
Igor Barkov (iwork) 2020-09-30 15:26:27 +03:00
parent dc47050b54
commit 2e167b79dd
1 changed files with 24 additions and 28 deletions

View File

@ -14,6 +14,9 @@ if ($user->battle) {
header('location: fight.php'); header('location: fight.php');
exit; exit;
} }
const SMITH = 'оружейник';
const MERCENARY = 'наёмник';
const MEDIC = 'лекарь';
$status = 'Внимание! Моментальная оплата без подтверждения!'; $status = 'Внимание! Моментальная оплата без подтверждения!';
$get = urldecode(filter_input(INPUT_SERVER, 'QUERY_STRING')); $get = urldecode(filter_input(INPUT_SERVER, 'QUERY_STRING'));
@ -22,28 +25,29 @@ function setProfession($name, $type, $needMoney, $needLevel)
{ {
global $user; global $user;
$profId = 0; $profId = 0;
if (!in_array($name, ['оружейник', 'наёмник', 'лекарь'])) { $status = null;
return 'Такой профессии не существует!'; if (!in_array($name, [SMITH, MERCENARY, MEDIC])) {
$status = 'Такой профессии не существует!';
} }
if ($user['money'] < $needMoney) { if ($user['money'] < $needMoney) {
return 'Недостаточно денег!'; $status = 'Недостаточно денег!';
} }
if ($user['level'] < $needLevel) { if ($user['level'] < $needLevel) {
return 'Ваш уровень ещё мал для этой профессии!'; $status = 'Ваш уровень ещё мал для этой профессии!';
} }
if (!empty($user['prof1']) && $type == 1) { if (!empty($user['prof1']) && $type == 1) {
return 'Ошибка! У вас уже есть другая мирная профессия!'; $status = 'Ошибка! У вас уже есть другая мирная профессия!';
} }
if (!empty($user['prof2']) && $type == 2) { if (!empty($user['prof2']) && $type == 2) {
return 'Ошибка! У вас уже есть другая боевая профессия!'; $status = 'Ошибка! У вас уже есть другая боевая профессия!';
} }
if ($name == 'оружейник') { if ($name == SMITH && !$status) {
$profId = 1; $profId = 1;
} }
if ($name == 'наёмник') { if ($name == MERCENARY && !$status) {
$profId = 21; $profId = 21;
} }
if ($name == 'лекарь') { if ($name == MEDIC && !$status) {
$profId = 22; $profId = 22;
} }
if (!empty($profId)) { if (!empty($profId)) {
@ -52,42 +56,36 @@ function setProfession($name, $type, $needMoney, $needLevel)
db::c()->query('UPDATE `users` SET ?f = ?i WHERE `id` = ?i', 'prof' . $type, $profId, $user->id); db::c()->query('UPDATE `users` SET ?f = ?i WHERE `id` = ?i', 'prof' . $type, $profId, $user->id);
$deloText = "{$user['login']} купил профессию «{$name}» в академии за {$needMoney} кр."; $deloText = "{$user['login']} купил профессию «{$name}» в академии за {$needMoney} кр.";
addToDelo($deloText); addToDelo($deloText);
$user['prof'.$type] = true; $user['prof' . $type] = true;
return 'Вы получили профессию!'; $status = 'Вы получили профессию!';
} else { } else {
return 'Что-то пошло не так...'; $status = 'Что-то пошло не так...';
} }
return $status;
} }
if ($get == 'smith') { if ($get == 'smith') {
$status = setProfession('оружейник', 1, 300, 3); $status = setProfession(SMITH, 1, 300, 3);
} }
if ($get == 'mercenary') { if ($get == 'mercenary') {
$status = setProfession('наёмник', 2, 700, 5); $status = setProfession(MERCENARY, 2, 700, 5);
} }
if ($get == 'medic') { if ($get == 'medic') {
$status = setProfession('лекарь', 2, 700, 5); $status = setProfession(MEDIC, 2, 700, 5);
} }
if ($get == 'exit') { if ($get == 'exit') {
db::c()->query('UPDATE `users`,`online` SET `users`.`room` = 2702, `online`.`room` = 2702 WHERE `users`.`id` = ?i AND `online`.`id` = ?i', $user->id, $user->id); db::c()->query('UPDATE `users`,`online` SET `users`.`room` = 2702, `online`.`room` = 2702 WHERE `users`.`id` = ?i AND `online`.`id` = ?i', $user->id, $user->id);
header('Location: city.php'); header('Location: city.php');
} }
Template::header('Академия');
?> ?>
<!DOCTYPE html> <link href="css/secondary.css" rel="stylesheet"/>
<html lang="ru">
<head>
<meta charset="utf-8">
<link href="css/main.css" rel="stylesheet">
<link href="css/secondary.css" rel="stylesheet"/>
<title></title>
</head>
<body>
<div style="float: right;"> <div style="float: right;">
<button onclick="location.href='?exit'">Вернуться</button> <button onclick="location.href='?exit'">Вернуться</button>
</div> </div>
<h1>Академия</h1> <h1>Академия</h1>
<div><?php if (!empty($status)) err($status); ?></div> <div><?= $status ?></div>
<div class="appblock appblock-main"> <div class="appblock appblock-main">
<span class="legend">Информация</span> <span class="legend">Информация</span>
<span class="wrap">Кредиты<span class="num"><?= $user->money ?></span></span> <span class="wrap">Кредиты<span class="num"><?= $user->money ?></span></span>
@ -160,6 +158,4 @@ if ($get == 'exit') {
<span class="wrap"> <span class="wrap">
Алхимик может создавать новые зелья используя расходные материалы. Мирная профессия. Алхимик может создавать новые зелья используя расходные материалы. Мирная профессия.
</span> </span>
</div> </div>
</body>
</html>