dev #41

Merged
lopar merged 29 commits from dev into master 2021-05-25 15:28:14 +00:00
3 changed files with 55 additions and 55 deletions
Showing only changes of commit cbccdd754f - Show all commits

View File

@ -3,7 +3,6 @@
namespace Battles; namespace Battles;
use Battles\Database\DBPDO; use Battles\Database\DBPDO;
use Exceptions\GameException;
class User class User
{ {
@ -448,4 +447,8 @@ class User
self::$db->execute('UPDATE users SET realname = ?, info = ? WHERE id = ?', [$this->realname, $this->info, $this->id]); 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 <?php
namespace Battles; namespace Battles;
use Battles\Models\EffectsModel; use Battles\Models\EffectsModel;
use Exceptions\GameException;
class UserInfo extends UserStats class UserInfo extends UserStats
{ {

104
main.php
View File

@ -17,11 +17,7 @@ if ($get == 'exit') {
} }
require_once 'functions.php'; require_once 'functions.php';
try { $user->setOnline();
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>";
}
// Инициализируем входящие GET\POST переменные. // Инициализируем входящие GET\POST переменные.
$goto = $_GET['goto'] ?? null; $goto = $_GET['goto'] ?? null;
@ -34,10 +30,59 @@ $mfs = $_GET['modif_mf'] ?? null;
$ids = $_GET['ids'] ?? null; $ids = $_GET['ids'] ?? null;
$setShadow = $_POST['setshadow'] ?? null; $setShadow = $_POST['setshadow'] ?? null;
$edit = $_GET['edit'] ?? 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()); $userInfo = new UserInfo($user->getId());
$userStats = new UserStats($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()); $data = \Battles\Database\DBPDO::INIT()->ofetchAll('SELECT * FROM inventory WHERE owner_id = ? AND dressed_slot = 0 AND on_sale = 0', $user->getId());
$iteminfo = []; $iteminfo = [];
foreach ($data as $row) { foreach ($data as $row) {
@ -240,53 +285,6 @@ if ($setShadow) {
<?php <?php
exit(); 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('Игра'); Template::header('Игра');
?> ?>
<script src="js/funcs.js"></script> <script src="js/funcs.js"></script>