battles/akadem.php

162 lines
6.9 KiB
PHP
Raw Normal View History

2018-01-28 16:40:49 +00:00
<?php
session_start();
if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
2019-01-15 21:44:55 +00:00
require_once 'functions.php';
$user = $user ?? null;
if ($user->room != 61) {
header("Location: main.php");
exit;
}
if ($user->battle) {
header('location: fight.php');
exit;
2018-01-28 16:40:49 +00:00
}
const SMITH = 'оружейник';
const MERCENARY = 'наёмник';
const MEDIC = 'лекарь';
2018-01-28 16:40:49 +00:00
2019-01-15 21:44:55 +00:00
$status = 'Внимание! Моментальная оплата без подтверждения!';
2019-01-15 22:03:58 +00:00
$get = urldecode(filter_input(INPUT_SERVER, 'QUERY_STRING'));
2019-01-15 21:44:55 +00:00
function setProfession($name, $type, $needMoney, $needLevel)
{
global $user;
2019-01-15 22:15:12 +00:00
$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;
}
2019-01-15 22:15:12 +00:00
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);
2019-01-15 22:31:53 +00:00
$deloText = "{$user['login']} купил профессию «{$name}» в академии за {$needMoney} кр.";
addToDelo($deloText);
$user['prof' . $type] = true;
$status = 'Вы получили профессию!';
} else {
$status = 'Что-то пошло не так...';
}
return $status;
}
2018-01-28 16:40:49 +00:00
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);
}
2019-01-15 22:03:58 +00:00
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');
2018-01-28 16:40:49 +00:00
}
\Battles\Template::header('Академия');
?>
<link href="css/secondary.css" rel="stylesheet"/>
2019-01-15 22:20:52 +00:00
<div style="float: right;">
2019-01-15 22:03:58 +00:00
<button onclick="location.href='?exit'">Вернуться</button>
2019-01-15 20:21:01 +00:00
</div>
<h1>Академия</h1>
<div><?= $status ?></div>
2019-01-15 22:24:09 +00:00
<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>
2019-01-15 22:24:09 +00:00
</div>
2019-01-15 21:44:55 +00:00
<div class="appblock">
<span class="legend">Наёмник</span>
<?php if (empty($user['prof2'])): ?>
2019-01-15 22:03:58 +00:00
<button onclick="location.href='?mercenary'">Изучить профессию</button>
2019-01-15 21:44:55 +00:00
<?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'])): ?>
2019-01-15 22:03:58 +00:00
<button onclick="location.href='?medic'">Изучить профессию</button>
2019-01-15 21:44:55 +00:00
<?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>
2019-01-15 20:21:01 +00:00
<div class="appblock">
<span class="legend">Колдун</span>
<button disabled>Недоступно</button>
<span class="wrap">Цена<span class="num">300</span></span>
2019-01-15 21:44:55 +00:00
<span class="wrap">Уровень персонажа<span class="num">5</span></span>
2019-01-15 20:21:01 +00:00
<span class="wrap">
2019-01-15 21:44:55 +00:00
Колдун может встраивать руны в предметы, тем самым изменяя характеристики предмета. Мирная профессия.
</span>
</div>
<div class="appblock">
<span class="legend">Кузнец</span>
<button disabled>Недоступно</button>
2019-01-15 22:03:58 +00:00
<span class="wrap">Цена<span class="num">5000</span></span>
<span class="wrap">Уровень персонажа<span class="num">10</span></span>
2019-01-15 21:44:55 +00:00
<span class="wrap">
Кузнец может создавать новые предметы используя расходные материалы. Мирная профессия.
</span>
</div>
<div class="appblock">
<span class="legend">Оружейник</span>
<?php if (empty($user['prof1'])): ?>
2019-01-15 22:03:58 +00:00
<button onclick="location.href='?smith'">Изучить профессию</button>
2019-01-15 21:44:55 +00:00
<?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>
2019-01-15 22:03:58 +00:00
<span class="wrap">Цена<span class="num">5000</span></span>
<span class="wrap">Уровень персонажа<span class="num">10</span></span>
2019-01-15 21:44:55 +00:00
<span class="wrap">
Алхимик может создавать новые зелья используя расходные материалы. Мирная профессия.
2019-01-15 20:21:01 +00:00
</span>
</div>