battles/akadem.php

162 lines
6.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
require_once 'functions.php';
$user = $user ?? null;
if ($user->room != 61) {
header("Location: main.php");
exit;
}
if ($user->battle) {
header('location: fight.php');
exit;
}
const SMITH = 'оружейник';
const MERCENARY = 'наёмник';
const MEDIC = 'лекарь';
$status = 'Внимание! Моментальная оплата без подтверждения!';
$get = urldecode(filter_input(INPUT_SERVER, 'QUERY_STRING'));
function setProfession($name, $type, $needMoney, $needLevel)
{
global $user;
$profId = 0;
$status = null;
if (!in_array($name, [SMITH, MERCENARY, MEDIC])) {
$status = 'Такой профессии не существует!';
}
if ($user['money'] < $needMoney) {
$status = 'Недостаточно денег!';
}
if ($user['level'] < $needLevel) {
$status = 'Ваш уровень ещё мал для этой профессии!';
}
if (!empty($user['prof1']) && $type == 1) {
$status = 'Ошибка! У вас уже есть другая мирная профессия!';
}
if (!empty($user['prof2']) && $type == 2) {
$status = 'Ошибка! У вас уже есть другая боевая профессия!';
}
if ($name == SMITH && !$status) {
$profId = 1;
}
if ($name == MERCENARY && !$status) {
$profId = 21;
}
if ($name == MEDIC && !$status) {
$profId = 22;
}
if (!empty($profId)) {
$user->money -= $needMoney;
Bank::setWalletMoney($user->money, $user->id);
db::c()->query('UPDATE `users` SET ?f = ?i WHERE `id` = ?i', 'prof' . $type, $profId, $user->id);
$deloText = "{$user['login']} купил профессию «{$name}» в академии за {$needMoney} кр.";
addToDelo($deloText);
$user['prof' . $type] = true;
$status = 'Вы получили профессию!';
} else {
$status = 'Что-то пошло не так...';
}
return $status;
}
if ($get == 'smith') {
$status = setProfession(SMITH, 1, 300, 3);
}
if ($get == 'mercenary') {
$status = setProfession(MERCENARY, 2, 700, 5);
}
if ($get == 'medic') {
$status = setProfession(MEDIC, 2, 700, 5);
}
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);
header('Location: city.php');
}
\Battles\Template::header('Академия');
?>
<link href="css/secondary.css" rel="stylesheet"/>
<div style="float: right;">
<button onclick="location.href='?exit'">Вернуться</button>
</div>
<h1>Академия</h1>
<div><?= $status ?></div>
<div class="appblock appblock-main">
<span class="legend">Информация</span>
<span class="wrap">Кредиты<span class="num"><?= $user->money ?></span></span>
<span class="wrap">Уровень персонажа<span class="num"><?= $user->level ?></span></span>
</div>
<div class="appblock">
<span class="legend">Наёмник</span>
<?php if (empty($user['prof2'])): ?>
<button onclick="location.href='?mercenary'">Изучить профессию</button>
<?php else: ?>
<button style="color: darkred" disabled>У вас уже есть боевая профессия</button>
<?php endif; ?>
<span class="wrap">Цена<span class="num">700</span></span>
<span class="wrap">Уровень персонажа<span class="num">5</span></span>
<span class="wrap">
Палач, это наёмник, который за деньги вмешивается в поединки других игроков не получая за это боевого опыта.
Боевая профессия.
</span>
</div>
<div class="appblock">
<span class="legend">Лекарь</span>
<?php if (empty($user['prof2'])): ?>
<button onclick="location.href='?medic'">Изучить профессию</button>
<?php else: ?>
<button style="color: darkred" disabled>У вас уже есть боевая профессия</button>
<?php endif; ?>
<span class="wrap">Цена<span class="num">700</span></span>
<span class="wrap">Уровень персонажа<span class="num">5</span></span>
<span class="wrap">
Лекарь лечит травмы, приобретённые игроками в боях и восстанавливает здоровье даже в поединке.
Боевая профессия.
</span>
</div>
<div class="appblock">
<span class="legend">Колдун</span>
<button disabled>Недоступно</button>
<span class="wrap">Цена<span class="num">300</span></span>
<span class="wrap">Уровень персонажа<span class="num">5</span></span>
<span class="wrap">
Колдун может встраивать руны в предметы, тем самым изменяя характеристики предмета. Мирная профессия.
</span>
</div>
<div class="appblock">
<span class="legend">Кузнец</span>
<button disabled>Недоступно</button>
<span class="wrap">Цена<span class="num">5000</span></span>
<span class="wrap">Уровень персонажа<span class="num">10</span></span>
<span class="wrap">
Кузнец может создавать новые предметы используя расходные материалы. Мирная профессия.
</span>
</div>
<div class="appblock">
<span class="legend">Оружейник</span>
<?php if (empty($user['prof1'])): ?>
<button onclick="location.href='?smith'">Изучить профессию</button>
<?php else: ?>
<button style="color: darkred" disabled>У вас уже есть мирная профессия</button>
<?php endif; ?>
<span class="wrap">Цена<span class="num">300</span></span>
<span class="wrap">Уровень персонажа<span class="num">5</span></span>
<span class="wrap">
Оружейник может точить оружие и подгонять броню, тем самым изменяя характеристики предмета. Мирная профессия.
</span>
</div>
<div class="appblock">
<span class="legend">Алхимик</span>
<button disabled>Недоступно</button>
<span class="wrap">Цена<span class="num">5000</span></span>
<span class="wrap">Уровень персонажа<span class="num">10</span></span>
<span class="wrap">
Алхимик может создавать новые зелья используя расходные материалы. Мирная профессия.
</span>
</div>