This commit is contained in:
lopar 2021-03-11 00:55:08 +02:00
parent 9a75e9d949
commit cbccdd754f
3 changed files with 55 additions and 55 deletions

View File

@ -3,7 +3,6 @@
namespace Battles;
use Battles\Database\DBPDO;
use Exceptions\GameException;
class User
{
@ -448,4 +447,8 @@ class User
self::$db->execute('UPDATE users SET realname = ?, info = ? WHERE id = ?', [$this->realname, $this->info, $this->id]);
}
public function setOnline()
{
self::$db->execute('update online set real_time = ? where user_id = ?', [time(), $this->getId()]);
}
}

View File

@ -1,7 +1,6 @@
<?php
namespace Battles;
use Battles\Models\EffectsModel;
use Exceptions\GameException;
class UserInfo extends UserStats
{

104
main.php
View File

@ -17,11 +17,7 @@ if ($get == 'exit') {
}
require_once 'functions.php';
try {
db::c()->query('UPDATE `online` SET `real_time` = ?i WHERE `user_id` = ?i', time(), $user->getId());
} catch (\Krugozor\Database\Mysql\Exception $e) {
echo "<div class='debug' '>Ошибка: " . $e->getMessage() . "<br> Стек: " . $e->getTraceAsString() . "</div>";
}
$user->setOnline();
// Инициализируем входящие GET\POST переменные.
$goto = $_GET['goto'] ?? null;
@ -34,10 +30,59 @@ $mfs = $_GET['modif_mf'] ?? null;
$ids = $_GET['ids'] ?? null;
$setShadow = $_POST['setshadow'] ?? null;
$edit = $_GET['edit'] ?? null;
if ($edit) {
$ups = $_GET['ups'] ?? null;
$upm = $_GET['upm'] ?? null;
$use = $_GET['use'] ?? null;
$useTarget = $_POST['target'] ?? null;
$drop = $_GET['drop'] ?? null;
$dress = $_GET['dress'] ?? null;
$undress = $_GET['undress'] ?? null;
$destruct = $_GET['destruct'] ?? null;
if ($ups) {
$user->addOnePointToStat($ups);
}
if ($upm) {
addOnePoint($upm, 'mastery');
}
if ($drop) {
$items = new DressedItems($_SESSION['uid']);
$items->undressItem($drop);
}
//Пока что одеваем предмет отсюда.
if ($dress) {
echo dressitem($dress);
}
if ($destruct) {
$q = db::c()->query('SELECT `id`, `dressed`, `name`, `duration`, `maxdur` FROM `inventory` WHERE `owner` = ?i AND `id` = ?i', $_SESSION['uid'], $destruct);
if ($q->getNumRows()) {
$q = $q->fetch_assoc();
if (empty($q['dressed'])) {
destructitem($q['id']);
GameLogs::addUserLog($user->getId(), $user->getLogin() . ' выбросил предмет ' . $q['name'] . ' id:(cap' . $q['id'] . ')');
err('Предмет ' . $q['name'] . ' выброшен.');
} else {
err('Ошибка: нельзя выбросить одетый предмет!');
}
} else {
err('Ошибка: предмет не найден!');
}
}
if ($use) {
usemagic($use, $useTarget);
}
if ($undress) {
undressall($_SESSION['uid']);
}
}
// Подготавливаем отображение инфы и предметов.
$userInfo = new UserInfo($user->getId());
$userStats = new UserStats($user->getId());
$getItemsBonuses = new DressedItems($_SESSION['uid']);
$getItemsBonuses = new DressedItems($user->getId());
$data = \Battles\Database\DBPDO::INIT()->ofetchAll('SELECT * FROM inventory WHERE owner_id = ? AND dressed_slot = 0 AND on_sale = 0', $user->getId());
$iteminfo = [];
foreach ($data as $row) {
@ -240,53 +285,6 @@ if ($setShadow) {
<?php
exit();
}
if ($edit) {
$ups = $_GET['ups'] ?? null;
$upm = $_GET['upm'] ?? null;
$use = $_GET['use'] ?? null;
$useTarget = $_POST['target'] ?? null;
$drop = $_GET['drop'] ?? null;
$dress = $_GET['dress'] ?? null;
$undress = $_GET['undress'] ?? null;
$destruct = $_GET['destruct'] ?? null;
if ($ups) {
$user->addOnePointToStat($ups);
}
if ($upm) {
addOnePoint($upm, 'mastery');
}
if ($drop) {
$items = new DressedItems($_SESSION['uid']);
$items->undressItem($drop);
}
//Пока что одеваем предмет отсюда.
if ($dress) {
echo dressitem($dress);
}
if ($destruct) {
$q = db::c()->query('SELECT `id`, `dressed`, `name`, `duration`, `maxdur` FROM `inventory` WHERE `owner` = ?i AND `id` = ?i', $_SESSION['uid'], $destruct);
if ($q->getNumRows()) {
$q = $q->fetch_assoc();
if (empty($q['dressed'])) {
destructitem($q['id']);
GameLogs::addUserLog($user->getId(), $user->getLogin() . " выбросил предмет " . $q['name'] . " id:(cap" . $q['id'] . ")");
err('Предмет ' . $q['name'] . ' выброшен.');
} else {
err('Ошибка: нельзя выбросить одетый предмет!');
}
} else {
err('Ошибка: предмет не найден!');
}
}
if ($use) {
usemagic($use, $useTarget);
}
if ($undress) {
undressall($_SESSION['uid']);
}
}
Template::header('Игра');
?>
<script src="js/funcs.js"></script>