2018-01-28 16:40:49 +00:00
|
|
|
|
<?php
|
2021-08-25 01:44:36 +00:00
|
|
|
|
|
2022-08-09 19:57:43 +00:00
|
|
|
|
use Battles\{Database\Db, DressedItems, InventoryItem, Travel, User, UserInfo, UserEffect};
|
2021-08-26 16:15:47 +00:00
|
|
|
|
use Exceptions\GameException;
|
2021-01-27 15:19:05 +00:00
|
|
|
|
|
2022-08-09 19:57:43 +00:00
|
|
|
|
if (filter_input(INPUT_SERVER, 'QUERY_STRING') === 'exit') {
|
|
|
|
|
//session_destroy();
|
|
|
|
|
echo 'EXIT PRESSED';
|
2019-02-15 22:33:58 +00:00
|
|
|
|
header("Location: fight.php");
|
|
|
|
|
}
|
2020-06-23 18:19:52 +00:00
|
|
|
|
require_once 'functions.php';
|
2020-06-23 19:34:52 +00:00
|
|
|
|
|
2022-01-26 23:15:33 +00:00
|
|
|
|
User::getInstance()->setOnline();
|
2020-08-29 23:21:22 +00:00
|
|
|
|
|
2022-08-09 19:57:43 +00:00
|
|
|
|
if (!empty($_GET['edit'])) {
|
|
|
|
|
if (!empty($_GET['ups'])) {
|
2021-08-26 16:15:47 +00:00
|
|
|
|
try {
|
2022-01-26 23:15:33 +00:00
|
|
|
|
$up = new UserInfo(User::getInstance()->getId());
|
2022-08-09 19:57:43 +00:00
|
|
|
|
$up->addOnePointToStat($_GET['ups']);
|
2021-08-26 16:15:47 +00:00
|
|
|
|
unset($up);
|
|
|
|
|
} catch (GameException $e) {
|
|
|
|
|
echo $e;
|
|
|
|
|
}
|
2021-03-10 22:55:08 +00:00
|
|
|
|
}
|
2022-08-09 19:57:43 +00:00
|
|
|
|
if (!empty($_GET['drop'])) {
|
2022-01-26 23:15:33 +00:00
|
|
|
|
$items = new DressedItems(User::getInstance()->getId());
|
2022-08-09 19:57:43 +00:00
|
|
|
|
$items->undressItem($_GET['drop']);
|
2021-03-14 17:54:13 +00:00
|
|
|
|
unset($items);
|
2021-03-10 22:55:08 +00:00
|
|
|
|
}
|
|
|
|
|
//Пока что одеваем предмет отсюда.
|
2022-08-09 19:57:43 +00:00
|
|
|
|
if (!empty($_GET['dress'])) {
|
|
|
|
|
$dressing = new InventoryItem(Db::getInstance()->ofetch('select * from inventory where item_id = ? ', $_GET['dress']));
|
2021-03-14 17:54:13 +00:00
|
|
|
|
$dressing->dressItem();
|
|
|
|
|
unset($dressing);
|
2021-03-10 22:55:08 +00:00
|
|
|
|
}
|
2022-08-09 19:57:43 +00:00
|
|
|
|
//Выбросить предмет. Ниоткуда не вызывается. О_о
|
|
|
|
|
if (!empty($_GET['destruct'])) {
|
|
|
|
|
$item = new InventoryItem(Db::getInstance()->ofetch('select * from inventory where item_id = ? ', $_GET['destruct']));
|
|
|
|
|
echo $item->drop();
|
|
|
|
|
unset($item);
|
2021-03-10 22:55:08 +00:00
|
|
|
|
}
|
2022-08-09 19:57:43 +00:00
|
|
|
|
if (!empty($_GET['undress']) && $_GET['undress'] === 'all') {
|
2022-01-26 23:15:33 +00:00
|
|
|
|
DressedItems::undressAllItems(User::getInstance()->getId());
|
2021-03-10 22:55:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-29 23:21:22 +00:00
|
|
|
|
// Подготавливаем отображение инфы и предметов.
|
2022-01-26 23:15:33 +00:00
|
|
|
|
$data = Db::getInstance()->ofetchAll('SELECT * FROM inventory WHERE owner_id = ? AND dressed_slot = 0 AND on_sale = 0', User::getInstance()->getId());
|
2020-08-29 23:21:22 +00:00
|
|
|
|
$iteminfo = [];
|
2021-03-10 21:20:56 +00:00
|
|
|
|
foreach ($data as $row) {
|
2021-08-20 17:40:06 +00:00
|
|
|
|
$iteminfo = new InventoryItem($row);
|
2020-07-06 19:54:50 +00:00
|
|
|
|
}
|
2018-01-28 16:40:49 +00:00
|
|
|
|
|
2020-09-29 10:07:08 +00:00
|
|
|
|
//Обработчики нажатий на кнопки.
|
2022-08-09 19:57:43 +00:00
|
|
|
|
if (!empty($_POST['battlefield']) && User::getInstance()->getRoom() === 1) {
|
2020-09-28 14:44:33 +00:00
|
|
|
|
header('Location: zayavka.php');
|
|
|
|
|
exit();
|
|
|
|
|
}
|
2022-08-09 19:57:43 +00:00
|
|
|
|
if (!empty($_POST['module_quest'])) {
|
2020-10-26 23:07:27 +00:00
|
|
|
|
header('Location: module_quest.php');
|
|
|
|
|
exit();
|
|
|
|
|
}
|
2022-08-09 19:57:43 +00:00
|
|
|
|
if (!empty($_POST['move_inside']) && User::getInstance()->getRoom() === 20) {
|
2020-10-26 23:07:27 +00:00
|
|
|
|
header('Location: main.php?goto=arena');
|
|
|
|
|
exit();
|
|
|
|
|
}
|
2022-08-09 19:57:43 +00:00
|
|
|
|
if (!empty($_POST['move_outside']) && User::getInstance()->getRoom() === 1) {
|
2020-10-26 23:07:27 +00:00
|
|
|
|
header('Location: main.php?goto=plo');
|
|
|
|
|
exit();
|
|
|
|
|
}
|
2022-08-09 19:57:43 +00:00
|
|
|
|
if (!empty($_POST['main_page'])) {
|
2020-10-26 23:18:02 +00:00
|
|
|
|
header('Location: main.php');
|
|
|
|
|
exit();
|
|
|
|
|
}
|
2020-08-30 10:44:57 +00:00
|
|
|
|
|
2022-08-09 19:57:43 +00:00
|
|
|
|
if (empty($_GET['edit'])) {
|
2020-10-26 23:43:54 +00:00
|
|
|
|
/* === проверяем соответствие комнаты и скрипта === */
|
2022-01-26 23:15:33 +00:00
|
|
|
|
if (in_array(User::getInstance()->getRoom(), [20, 21, 26, 48, 51, 52, 651, 2655, 2601, 2701, 2702, 2111])) {
|
2020-10-26 23:43:54 +00:00
|
|
|
|
header('Location: city.php');
|
|
|
|
|
exit();
|
|
|
|
|
}
|
2022-01-26 23:15:33 +00:00
|
|
|
|
if (in_array(User::getInstance()->getRoom(), [22, 23, 25, 27, 29, 30, 31, 34, 45, 53, 61, 402, 403, 600, 601, 602, 603, 620, 621, 650, 660, 661, 662, 666, 760, 1051, 1052, 1055])) {
|
|
|
|
|
header('location: ' . Travel::$roomFileName[User::getInstance()->getRoom()]);
|
2020-10-26 23:43:54 +00:00
|
|
|
|
exit();
|
|
|
|
|
}
|
2018-07-02 15:35:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-09-17 14:37:44 +00:00
|
|
|
|
// Входим и выходим если можем.
|
2022-08-09 19:57:43 +00:00
|
|
|
|
if (!empty($_GET['goto'])) {
|
2019-09-17 14:37:44 +00:00
|
|
|
|
$imove = true;
|
2022-08-09 19:57:43 +00:00
|
|
|
|
$isInjured = Db::getInstance()->fetchColumn('select count(*) from users_effects where owner_id = ? and (type = 14 or type = 13)') > 0;
|
|
|
|
|
function gotoroom($room_id)
|
|
|
|
|
{
|
|
|
|
|
$query = 'update users, online set users.room = ' . '$room_id' . ', online.room = ' . '$room_id' . ' where user_id = id and user_id = ?';
|
|
|
|
|
Db::getInstance()->execute($query, User::getInstance()->getId());
|
|
|
|
|
}
|
2020-07-21 11:52:39 +00:00
|
|
|
|
|
2022-08-09 19:57:43 +00:00
|
|
|
|
if (UserEffect::isOverEncumbered(User::getInstance()->getId())) {
|
2019-09-17 14:37:44 +00:00
|
|
|
|
err('У вас переполнен рюкзак, вы не можете передвигаться...');
|
|
|
|
|
$imove = false;
|
|
|
|
|
}
|
2022-08-09 19:57:43 +00:00
|
|
|
|
if ($isInjured) {
|
2019-09-17 14:37:44 +00:00
|
|
|
|
err('У вас тяжелая травма, вы не можете передвигатся...');
|
|
|
|
|
$imove = false;
|
|
|
|
|
}
|
2022-08-09 19:57:43 +00:00
|
|
|
|
if ($_GET['goto'] === 'plo' && !User::getInstance()->getZayavka() && $imove && User::getInstance()->getRoom() != 20) {
|
|
|
|
|
Travel::toRoom(20, User::getInstance()->getRoom());
|
|
|
|
|
Travel::roomRedirects(User::getInstance()->getRoom(), User::getInstance()->getBattle());
|
2020-06-23 08:49:49 +00:00
|
|
|
|
} else {
|
|
|
|
|
err('Подали заявку на бой и убегаете из клуба? Нехорошо...');
|
|
|
|
|
}
|
2022-08-09 19:57:43 +00:00
|
|
|
|
if ($_GET['goto'] === 'arena' && User::getInstance()->getRoom() == 20 && $imove) {
|
|
|
|
|
Travel::toRoom(1, User::getInstance()->getRoom());
|
|
|
|
|
Travel::roomRedirects(User::getInstance()->getRoom(), User::getInstance()->getBattle());
|
2019-09-17 14:37:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-09 19:57:43 +00:00
|
|
|
|
if (!empty($_GET['obraz'])) {
|
|
|
|
|
User::getInstance()->setShadow($_GET['obraz']);
|
2022-01-26 23:15:33 +00:00
|
|
|
|
User::getInstance()->saveUser();
|
2018-01-28 16:40:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-09 19:57:43 +00:00
|
|
|
|
if (!empty($_POST['setshadow'])) {
|
|
|
|
|
include_once 'views/main-setshadow.php';
|
2020-08-29 23:21:22 +00:00
|
|
|
|
exit();
|
2018-03-02 14:33:58 +00:00
|
|
|
|
}
|
2020-07-06 19:54:50 +00:00
|
|
|
|
|
2022-08-09 19:57:43 +00:00
|
|
|
|
include_once 'views/main-game.php';
|