battles/main.php

368 lines
17 KiB
PHP
Raw Permalink Normal View History

2018-01-28 16:40:49 +00:00
<?php
use Battles\Database\Db;
use Battles\DressedItems;
use Battles\GameLogs;
use Battles\InventoryItem;
use Battles\Template;
use Battles\Travel;
use Battles\UserInfo;
use Battles\UserStats;
use Battles\User;
2021-08-26 16:15:47 +00:00
use Exceptions\GameException;
2019-02-15 22:31:18 +00:00
$get = filter_input(INPUT_SERVER, 'QUERY_STRING');
if ($get == 'exit') {
2019-02-15 22:33:58 +00:00
session_destroy();
header("Location: fight.php");
}
2020-06-23 18:19:52 +00:00
require_once 'functions.php';
2020-06-23 19:34:52 +00:00
User::getInstance()->setOnline();
2021-08-26 16:15:47 +00:00
$req = (object)[];
$keys = ['ups', 'drop', 'dress', 'destruct', 'use', 'undress', 'edit', 'goto', 'obraz', 'setshadow'];
foreach ($keys as $key) {
$req->$key = $_REQUEST[$key] ?? null;
}
2021-03-10 22:55:08 +00:00
2021-08-26 16:15:47 +00:00
if ($req->edit) {
if ($req->ups) {
try {
$up = new UserInfo(User::getInstance()->getId());
2021-08-26 16:15:47 +00:00
$up->addOnePointToStat($req->ups);
unset($up);
} catch (GameException $e) {
echo $e;
}
2021-03-10 22:55:08 +00:00
}
2021-08-26 16:15:47 +00:00
if ($req->drop) {
$items = new DressedItems(User::getInstance()->getId());
2021-08-26 16:15:47 +00:00
$items->undressItem($req->drop);
unset($items);
2021-03-10 22:55:08 +00:00
}
//Пока что одеваем предмет отсюда.
2021-08-26 16:15:47 +00:00
if ($req->dress) {
$dressing = new InventoryItem(Db::getInstance()->ofetch('select * from inventory where item_id = ? ', $req->dress));
$dressing->dressItem();
unset($dressing);
2021-03-10 22:55:08 +00:00
}
2021-08-26 16:15:47 +00:00
if ($req->destruct) {
$q = Db::getInstance()->ofetch('select name,dressed_slot from inventory where owner_id = ? and item_id = ?', [User::getInstance()->getId(), $req->destruct]);
if ($q) {
if (empty($q->dressed_slot)) {
2021-08-26 16:15:47 +00:00
InventoryItem::destroyItem($req->destruct);
GameLogs::addUserLog(User::getInstance()->getId(), User::getInstance()->getLogin() . ' выбросил предмет ' . $q->name . ' id:(cap' . $req->destruct . ')');
err('Предмет ' . $q->name . ' выброшен.');
2021-03-10 22:55:08 +00:00
} else {
err('Ошибка: нельзя выбросить одетый предмет!');
}
} else {
err('Ошибка: предмет не найден!');
}
}
2021-08-26 16:15:47 +00:00
if ($req->use) {
usemagic($req->use, $req->useTarget);
2021-03-10 22:55:08 +00:00
}
2021-08-26 16:15:47 +00:00
if ($req->undress) {
DressedItems::undressAllItems(User::getInstance()->getId());
2021-03-10 22:55:08 +00:00
}
}
// Подготавливаем отображение инфы и предметов.
$userInfo = new UserInfo(User::getInstance()->getId());
$userStats = new UserStats(User::getInstance()->getId());
$stat = $userStats->getFullStats();
$data = Db::getInstance()->ofetchAll('SELECT * FROM inventory WHERE owner_id = ? AND dressed_slot = 0 AND on_sale = 0', User::getInstance()->getId());
$iteminfo = [];
foreach ($data as $row) {
$iteminfo = new InventoryItem($row);
2020-07-06 19:54:50 +00:00
}
2018-01-28 16:40:49 +00:00
//Обработчики нажатий на кнопки.
if ($req->battlefield ?? 0 && User::getInstance()->getRoom() == 1) {
2020-09-28 14:44:33 +00:00
header('Location: zayavka.php');
exit();
}
2021-08-26 16:15:47 +00:00
if ($req->module_quest ?? 0) {
header('Location: module_quest.php');
exit();
}
if ($req->move_inside ?? 0 && User::getInstance()->getRoom() == 20) {
header('Location: main.php?goto=arena');
exit();
}
if ($req->move_outside ?? 0 && User::getInstance()->getRoom() == 1) {
header('Location: main.php?goto=plo');
exit();
}
2021-08-26 16:15:47 +00:00
if ($req->main_page ?? 0) {
header('Location: main.php');
exit();
}
2021-08-26 16:15:47 +00:00
if (!$req->edit) {
/* === проверяем соответствие комнаты и скрипта === */
if (in_array(User::getInstance()->getRoom(), [20, 21, 26, 48, 51, 52, 651, 2655, 2601, 2701, 2702, 2111])) {
header('Location: city.php');
exit();
}
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()]);
exit();
}
}
function del_efs($id, $type)
{
if ($id && !in_array($type, [2, 3, 4, 5, 8, 10, 11, 12, 13, 14, 20])) {
db::c()->query('DELETE FROM users_effects WHERE owner_id = ?i AND effect_id = ?i', $_SESSION['uid'], $id);
if ($type == 1022) {
db::c()->query('UPDATE `users` SET `invis` = 0 WHERE `id` = ?i', $_SESSION['uid']);
}
return 'Эффект удалён.';
} else {
return 'Эффект нельзя удалить.';
}
}
2019-09-17 14:37:44 +00:00
// Входим и выходим если можем.
2021-08-26 16:15:47 +00:00
if ($req->goto) {
2019-09-17 14:37:44 +00:00
$imove = true;
$d = db::c()->query('SELECT SUM(weight) AS sum_weight FROM inventory WHERE owner_id = ?i AND on_sale = 0', User::getInstance()->getId())->fetch_assoc();
$eff = db::c()->query('SELECT 1 FROM `users_effects` WHERE `owner_id` = ?i AND (`type` = 14 OR `type` = 13)', User::getInstance()->getId());
//(масса: <?= $getItemsBonuses->getItemsWeight() . '/' . User::getInstance()->strength * 4
if ($d['sum_weight'] > $userStats->getMaxWeight()) {
2019-09-17 14:37:44 +00:00
err('У вас переполнен рюкзак, вы не можете передвигаться...');
$imove = false;
}
2021-08-26 16:15:47 +00:00
if ($eff->getNumRows()) {
2019-09-17 14:37:44 +00:00
err('У вас тяжелая травма, вы не можете передвигатся...');
$imove = false;
}
if ($req->goto == 'plo' && !User::getInstance()->getZayavka() && $imove && User::getInstance()->getRoom() != 20) {
db::c()->query('UPDATE users, online SET users.room = 20, online.room = 20 WHERE online.user_id = users.id AND online.user_id = ?i', User::getInstance()->getId());
2019-09-17 14:37:44 +00:00
header('Location: city.php');
exit("<i>Топ-топ-топ...</i>");
2020-06-23 08:49:49 +00:00
} else {
err('Подали заявку на бой и убегаете из клуба? Нехорошо...');
}
if ($req->goto == 'arena' && User::getInstance()->getRoom() == 20 && $imove) {
db::c()->query('UPDATE users, online SET users.room = 1, online.room = 1 WHERE online.user_id = users.id AND online.user_id = ?i', User::getInstance()->getId());
2019-09-17 14:37:44 +00:00
header('Location: main.php');
exit("<i>Топ-топ-топ...</i>");
2019-09-17 14:37:44 +00:00
}
}
2021-08-26 16:15:47 +00:00
if ($req->use) {
usemagic($req->use, $req->target);
2019-09-17 14:37:44 +00:00
}
2021-08-26 16:15:47 +00:00
if ($req->obraz) {
User::getInstance()->setShadow($req->obraz);
User::getInstance()->saveUser();
2018-01-28 16:40:49 +00:00
}
2021-08-26 16:15:47 +00:00
if ($req->setshadow) {
Template::header('Образ персонажа');
2018-03-02 14:33:58 +00:00
?>
2020-07-21 09:20:44 +00:00
<div style="text-align: right;">
<input type=button value="Вернуться" onClick="location.href='main.php?edit=<?= mt_rand() ?>';" class="button">
2020-07-21 09:20:44 +00:00
</div>
<table style="padding:5px; margin:auto;">
2020-07-21 09:20:44 +00:00
<caption><b style="color: red;">Внимание! Образ персонажа выбирается только один раз.</b></caption>
<tr>
2020-07-21 09:20:44 +00:00
<td><a href="?edit=1&obraz=m1"><img alt="m01" src="i/shadow/m1.gif"></a>
<td><a href="?edit=1&obraz=m2"><img alt="m02" src="i/shadow/m2.gif"></a>
<td><a href="?edit=1&obraz=m3"><img alt="m03" src="i/shadow/m3.gif"></a>
<td><a href="?edit=1&obraz=m4"><img alt="m04" src="i/shadow/m4.gif"></a>
<td><a href="?edit=1&obraz=m5"><img alt="m05" src="i/shadow/m5.gif"></a>
<td><a href="?edit=1&obraz=m6"><img alt="m06" src="i/shadow/m6.gif"></a>
<td><a href="?edit=1&obraz=m7"><img alt="m07" src="i/shadow/m7.gif"></a>
<td><a href="?edit=1&obraz=m8"><img alt="m08" src="i/shadow/m8.gif"></a>
<td><a href="?edit=1&obraz=m9"><img alt="m09" src="i/shadow/m9.gif"></a>
<td><a href="?edit=1&obraz=m10"><img alt="m10" src="i/shadow/m10.gif"></a>
<tr>
2020-07-21 09:20:44 +00:00
<td><a href="?edit=1&obraz=f1"><img alt="f01" src="i/shadow/f1.gif"></a>
<td><a href="?edit=1&obraz=f2"><img alt="f02" src="i/shadow/f2.gif"></a>
<td><a href="?edit=1&obraz=f3"><img alt="f03" src="i/shadow/f3.gif"></a>
<td><a href="?edit=1&obraz=f4"><img alt="f04" src="i/shadow/f4.gif"></a>
<td><a href="?edit=1&obraz=f5"><img alt="f05" src="i/shadow/f5.gif"></a>
<td><a href="?edit=1&obraz=f6"><img alt="f06" src="i/shadow/f6.gif"></a>
<td><a href="?edit=1&obraz=f7"><img alt="f07" src="i/shadow/f7.gif"></a>
<td><a href="?edit=1&obraz=f8"><img alt="f08" src="i/shadow/f8.gif"></a>
<td><a href="?edit=1&obraz=f9"><img alt="f09" src="i/shadow/f9.gif"></a>
<td><a href="?edit=1&obraz=f10"><img alt="f10" src="i/shadow/f10.gif"></a>
2018-03-02 14:33:58 +00:00
</table>
<?php
exit();
2018-03-02 14:33:58 +00:00
}
Template::header('Игра');
?>
<script src="js/funcs.js"></script>
<script>
$(function () {
$(".tooltip").tipTip({maxWidth: "auto", edgeOffset: 0, fadeIn: 300, fadeOut: 500});
});
2018-03-02 14:33:58 +00:00
let Hint3Name = '';
2020-07-06 19:54:50 +00:00
function okno(title, script, name, errk) {
let errkom = '';
let com = '';
if (errk === 1) {
errkom = 'Нельзя использовать символы: /\:*?"<>|+%<br>';
}
2021-03-10 21:47:33 +00:00
document.getElementById("hint3").innerHTML = `
<table width=100% cellspacing=1 cellpadding=0 bgcolor=CCC3AA>
<tr>
<td align=center>
<b>${title}</b>
</td>
<td width=20 align=right valign=top style='cursor: pointer' onclick='closehint3();'>
<BIG><B>x
</td>
</tr>
<tr>
<td colspan=2>
<form action="${script}" method=POST>
<table width=100% cellspacing=0 cellpadding=2 bgcolor=FFF6DD>
<tr>
<INPUT TYPE=hidden name=sd4 value='6'>
<td colspan=2>
<span class='error'>${errkom}</span> введите название предмета
</TD>
</TR>
<TR>
<TD width=50% align=right>
<INPUT TYPE=text NAME="${name}" value="${com}">
</TD>
<TD width=50%>
<INPUT TYPE='submit' value=' »» '>
</TD>
</TR>
</TABLE>
</FORM>
</td>
</tr>
</table>
`;
document.getElementById("hint3").style.visibility = "visible";
document.getElementById("hint3").style.left = '100';
document.getElementById("hint3").style.top = '100';
document.getElementById(name).focus();
Hint3Name = name;
}
</script>
<div id=hint3 class=ahint></div>
<div id="chpassbank" style="display:none; position:absolute; top:50px; left:250px;"></div>
2021-08-26 16:15:47 +00:00
<?php $userInfo->showUserInfoMain() ?>
<table style="width: 100%;filter: sepia(1);background: white;">
<TR>
<td style="vertical-align: top; width: 350px">
2020-08-30 10:47:22 +00:00
<?php $userInfo->showUserDoll(0, 1); ?> <!-- Первый столбец -->
2021-03-10 21:47:33 +00:00
<div style="text-align: center;">
2020-08-30 01:09:52 +00:00
<a href='main.php?edit=1&undress=all' class="button">Снять все</a><BR>
2018-12-11 17:40:12 +00:00
<div class="effectList" style="padding-top: 15px; max-height: 150px; width: 220px;">
<?= $userInfo->showUserEffects() ?>
2018-12-11 17:40:12 +00:00
</div>
</div>
<br>
2018-03-02 14:33:58 +00:00
</td>
<td style="vertical-align: top; width: 250px"> <!-- Второй столбец -->
2018-12-11 17:40:12 +00:00
<div>
<br>Уровень: <strong><?= User::getInstance()->getLevel() ?></strong>
<br>Опыт: <strong><?= User::getInstance()->getExperience() ?></strong>
<br>Побед: <strong>??</strong>
<br>Поражений: <strong>??</strong>
<br>Ничьих: <strong>??</strong>
<br>Деньги: <strong><?= User::getInstance()->getMoney() ?></strong> кр.
2018-12-11 17:40:12 +00:00
<HR>
</div>
2018-03-02 14:33:58 +00:00
<!--Параметры-->
2018-12-11 17:40:12 +00:00
<div>
<div class="container">
Сила: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('strength', 1) . '(' . strval($stat->strength) . ')' : $stat->strength) ?>
2020-07-22 14:08:40 +00:00
<br>
Ловкость: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('dexterity', 1) . '(' . strval($stat->dexterity) . ')' : $stat->dexterity) ?>
<br>
Интуиция: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('intuition', 1) . '(' . strval($stat->intuition) . ')' : $stat->intuition) ?>
<br>
Выносливость: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('endurance', 1) . '(' . strval($stat->endurance) . ')' : $stat->endurance) ?>
2020-07-22 14:18:25 +00:00
<br>
Интеллект: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('intelligence', 1) . '(' . strval($stat->intelligence) . ')' : $stat->intelligence) ?>
2020-07-22 14:18:25 +00:00
<br>
Мудрость: <?= ($userStats->getFreeStatPoints() ? $userStats->getStat('wisdom', 1) . '(' . strval($stat->wisdom) . ')' : $stat->wisdom) ?>
<br>
<?php if ($userStats->getFreeStatPoints()): ?>
2020-07-22 14:08:40 +00:00
<small style="color: darkgreen;">Возможных
увеличений: <?= $userStats->getFreeStatPoints() ?></small><br>
2020-07-22 14:08:40 +00:00
<?php endif; ?>
<br>
<!-- #18 Разобраться в прогрессбарах -->
2021-08-26 16:15:47 +00:00
Здоровье:
<progress max="<?= $userStats->getMaxHealth() ?>"
value="<?= $userStats->getHealth() ?>"><?= $userStats->getHealth() ?></progress>
<br>
Пыль:
<progress max="<?= $userStats->getMaxMana() ?>"
value="<?= $userStats->getMana() ?>"><?= $userStats->getMana() ?></progress>
<br>
Уворот: <?= $stat->evasion ?><br>
Точность: <?= $stat->accuracy ?><br>
Шанс крита: <?= $stat->criticals ?><br>
Урон: <?= $stat->min_physical_damage ?>
- <?= $stat->max_physical_damage ?> <br>
<br>
Защита от огня: ?? <br>
Защита от воды: ?? <br>
Защита от вохдуха: ?? <br>
Защита от земли: ?? <br>
Защита от яда: ?? <br>
Броня головы: <?= $userStats->getHeadArmor() ?> <br>
Броня корпуса: <?= $userStats->getChestArmor() ?> <br>
Броня ног: <?= $userStats->getLegArmor() ?> <br>
</div>
2018-12-11 17:40:12 +00:00
</div>
</td>
2021-03-10 21:47:33 +00:00
<td style="vertical-align: top;">
<div class="button-container"> <!--Меню-кнопки-->
<FORM METHOD=POST ACTION="?edit=1" name=f1>
<?php if (User::getInstance()->getShadow() == '0.gif' || User::getInstance()->getAdmin() == 1): ?>
2020-07-22 14:08:40 +00:00
<INPUT class="button primary icon user" TYPE="submit" name="setshadow" value="Образы"
title="Образы">
<?php endif; ?>
<div class="button-group">
<?php if (User::getInstance()->getRoom() == 20): ?>
<input class="button icon move" type="submit" name="move_inside" value="Войти внутрь">
<?php elseif (User::getInstance()->getRoom() == 1): ?>
<input class="button primary" type="submit" name="battlefield" value="Поединки">
<input class="button icon move" type="submit" name="move_outside" value="Выйти на улицу">
<?php endif; ?>
<input class="button" type="submit" name="module_quest" value="Активные задания">
<input class="button" type="submit" name="main_page" value="На главную">
</div>
</div>
<div> <!--рюкзак-->
2021-03-10 21:47:33 +00:00
<table style="border: 0; padding: 2px; border-spacing: 1px; width: 100%; background-color: #a5a5a5">
<caption>Рюкзак
(масса: <?= '?? /' . $userStats->getMaxWeight() ?>)
</caption>
<?php
foreach ($iteminfo as $ii) {
2021-03-10 21:47:33 +00:00
echo "<tr><td style='width: 100px; text-align: center; background-color: #d3d3d3'>";
$ii->printImage();
$ii->printControls();
2021-03-10 21:47:33 +00:00
echo "<td style='vertical-align: top; background-color: #d3d3d3'>";
$ii->printInfo();
}
if (!$data) {
echo "<tr><th colspan='3' style='text-align: center; background-color: #c7c7c7'>Пусто";
2020-06-23 08:49:49 +00:00
}
2018-03-02 14:33:58 +00:00
?>
</table>
2020-07-06 19:54:50 +00:00
</div>
</td>
2018-03-02 14:33:58 +00:00
</tr>
</table>