battles/hostel.php

61 lines
2.1 KiB
PHP
Raw Permalink Normal View History

<?php
use Battles\{Database\Db, Hostel, Travel, User, UserEffect};
require_once 'config.php';
2018-01-28 16:40:49 +00:00
$host = new Hostel();
if (!empty($_GET['exit'])) {
Travel::toRoom(26, 661);
}
if (!empty($_GET['to_room'])) {
if (empty($host->getHid())) {
$host->setError('У Вас, нету комнаты!');
}
if ($host->getTime() <= time()) {
$host->setError('У Вас просрочена аренда. Оплатите что-бы продолжить пользоваться нашими услугами!');
}
if ($host->getStatus()['type'] !== 'error') {
Travel::toRoom(661, 26);
}
2018-01-28 16:40:49 +00:00
}
if (!empty($_GET['pays'])) {
$host->changeTime($_GET['pays']);
2018-01-28 16:40:49 +00:00
}
if (!empty($_POST['select']) && !empty($_POST['tariff'])) {
$host->newRent((int)$_POST['tariff']);
2018-01-28 16:40:49 +00:00
}
if (!empty($_GET['del'])) {
$host->remove();
2018-01-28 16:40:49 +00:00
}
if (!empty($_POST['deselect']) && !empty($_POST['retariff'])) {
$host->changeType((int)$_POST['retariff']);
header('Location: main.php');
2018-01-28 16:40:49 +00:00
}
if (!empty($_GET['sleep'])) {
if (UserEffect::getRemainingEffectTime(User::getInstance()->getId(), 8) <= time()) {
//Разморозка таймеров эффектов??!
UserEffect::add(User::getInstance()->getId(), 8, UserEffect::$effectName[8], time() + 60 * 60 * 2);
Db::getInstance()->execute('update users_effects set remaining_time = remaining_time - ? where owner_id = ? and type not in (11,12,13,14,5,4,3,2,8)', [time(), User::getInstance()->getId()]);
header('Location: hostel.php');
} else {
$host->setError('Нельзя спать! Приходите через: ' . timeOut($user['sleep_time'] - time()));
2018-01-28 16:40:49 +00:00
}
}
if (!empty($_GET['unsleep'])) {
//Заморозка таймеров эффектов??!
UserEffect::remove(User::getInstance()->getId(), 8);
Db::getInstance()->execute('update users_effects set remaining_time = remaining_time + ? where owner_id = ? and type not in (11,12,13,14,5,4,3,2,8)', [time(), User::getInstance()->getId()]);
header('Location: hostel.php');
2018-01-28 16:40:49 +00:00
}
require_once 'views/hostel.php';