fixes
This commit is contained in:
+26
-46
@@ -5,6 +5,7 @@
|
||||
* Project name: Battles-Game
|
||||
*/
|
||||
|
||||
use Battles\Chat;
|
||||
use Battles\Database\Db;
|
||||
use Battles\DressedItems;
|
||||
use Battles\InventoryItem;
|
||||
@@ -24,7 +25,7 @@ if (User::getInstance()->getBlock()) {
|
||||
}
|
||||
|
||||
//Проверки на соответствие скрипта и комнаты, которые были натыканы по всем файлам.
|
||||
Travel::roomRedirects(User::$current->getRoom(), User::$current->getBattle(), User::$current->getInTower());
|
||||
Travel::roomRedirects(User::getInstance()->getRoom(), User::getInstance()->getBattle(), User::getInstance()->getInTower());
|
||||
|
||||
///*
|
||||
// * Проверки на соответствие скрипта и комнаты, которые были натыканы по всем файлам.
|
||||
@@ -78,26 +79,26 @@ Travel::roomRedirects(User::$current->getRoom(), User::$current->getBattle(), Us
|
||||
// exit;
|
||||
//}
|
||||
|
||||
if (!empty($_GET['goto']) && !empty($_GET['tStamp']) && !empty($_GET['vcode']) && $_GET['vcode'] == md5(sha1($_GET['goto'] . $_GET['tStamp']))) {
|
||||
if (
|
||||
!empty($_GET['goto']) &&
|
||||
!empty($_GET['tStamp']) &&
|
||||
!empty($_GET['vcode']) &&
|
||||
$_GET['vcode'] == md5(sha1($_GET['goto'] . $_GET['tStamp']))
|
||||
) {
|
||||
$query = 'update users u, online o set u.room = ?, o.room = ? where user_id = id and user_id = ?';
|
||||
Db::getInstance()->execute($query, [$_GET['goto'], $_GET['goto'], User::getInstance()->getId()]);
|
||||
User::getInstance()->setRoom(intval($_GET['goto']));
|
||||
}
|
||||
|
||||
function createbot($bot, $login = "")
|
||||
function createbot($bot, $login = null)
|
||||
{
|
||||
$rec = db::c()->query('SELECT `id`, `login`, `maxhp` FROM `users` WHERE `id` = "?s" LIMIT 1', $bot)->fetch_assoc();
|
||||
if (isset($rec['id'])) {
|
||||
if ($login) {
|
||||
$rec['login'] = $login;
|
||||
}
|
||||
$botname = $rec['login'];
|
||||
db::c()->query('INSERT INTO `bots` (`name`, `prototype`, `hp`) VALUES ("?s", "?s", "?s")', $botname, $bot, $rec['maxhp']);
|
||||
$nid = db::c()->getLastInsertId();
|
||||
return ["id" => $nid, "login" => $botname];
|
||||
} else {
|
||||
if (!User::getInstance($bot)->getId()) {
|
||||
return false;
|
||||
}
|
||||
$botname = $login ?: User::getInstance($bot)->getLogin();
|
||||
Db::getInstance()->execute('insert into bots (name, prototype, hp) values (?, ?, ?)',
|
||||
[$botname, $bot, (new UserStats($bot))->getMaxHealth()]);
|
||||
return ["id" => Db::getInstance()->lastInsertId(), "login" => $botname];
|
||||
}
|
||||
|
||||
$var_map = [
|
||||
@@ -123,15 +124,15 @@ function savecavedata($cavedata, $caveleader, $floor)
|
||||
|
||||
function GiveExp($id, $exp)
|
||||
{
|
||||
db::c()->query('UPDATE users SET exp = exp + ?i WHERE id = ?i', $exp, $id);
|
||||
User::getInstance($id)->addExperience($exp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Генератор прогрессбара.
|
||||
* @param $current - Текущее значение.
|
||||
* @param $maximum - Максимальное значение.
|
||||
* @param $current - Текущее значение.
|
||||
* @param $maximum - Максимальное значение.
|
||||
* @param string $line_color - Цвет полоски прогрессбара.
|
||||
* @param string $bg_color - Фон прогрессбара.
|
||||
* @param string $bg_color - Фон прогрессбара.
|
||||
* @return string
|
||||
*/
|
||||
function showProgressBar($current, $maximum, string $line_color = 'limegreen', string $bg_color = 'silver'): string
|
||||
@@ -199,22 +200,18 @@ EMPTY_SLOT;
|
||||
}
|
||||
|
||||
// ссылка на магию
|
||||
function showhrefmagic($dress)
|
||||
function showhrefmagic(array $dress): string
|
||||
{
|
||||
$user = db::c()->query('SELECT `battle` FROM `users` WHERE `id` = ?i', $_SESSION['uid'])->fetch_assoc();
|
||||
$magic = db::c()->query('SELECT * FROM `magic` WHERE `id` = ?i', $dress['includemagic'])->fetch_assoc();
|
||||
$magic = new Battles\Magic\Magic(Db::getInstance(), $dress['includemagic']);
|
||||
|
||||
$r = '';
|
||||
$script = 'main';
|
||||
if ($user['battle']) {
|
||||
$script = 'fbattle';
|
||||
}
|
||||
$script = User::getInstance()->getBattle() ? 'fbattle' : 'main';
|
||||
|
||||
$r .= "<a onclick=\"";
|
||||
if ($magic['targeted'] == 1) {
|
||||
if ($magic->getMagic()->targeted == 1) {
|
||||
$r .= "okno('Введите название предмета', '{$script}.php?use={$dress['id']}', 'target')";
|
||||
} elseif ($magic['targeted'] == 2) {
|
||||
$r .= "findlogin('" . $magic['name'] . "', '{$script}.php?use={$dress['id']}', 'target')";
|
||||
} elseif ($magic->getMagic()->targeted == 2) {
|
||||
$r .= "findlogin('" . $magic->getMagic()->name . "', '{$script}.php?use={$dress['id']}', 'target')";
|
||||
} else {
|
||||
$r .= "if (confirm('Использовать сейчас?')) window.location='" . $script . ".php?use=" . $dress['id'] . "';";
|
||||
}
|
||||
@@ -435,30 +432,13 @@ function usemagic($id, $target)
|
||||
|
||||
function addch($text, $room = 0)
|
||||
{
|
||||
if ($room == 0) {
|
||||
$room = User::getInstance()->getRoom();
|
||||
}
|
||||
if ($fp = @fopen("tmp/chat.txt", "a")) { //открытие
|
||||
flock($fp, LOCK_EX); //БЛОКИРОВКА ФАЙЛА
|
||||
fwrite($fp, ":[" . time() . "]:[!sys!!]:[" . ($text) . "]:[" . $room . "]\r\n"); //работа с файлом
|
||||
fflush($fp); //ОЧИЩЕНИЕ ФАЙЛОВОГО БУФЕРА И ЗАПИСЬ В ФАЙЛ
|
||||
flock($fp, LOCK_UN); //СНЯТИЕ БЛОКИРОВКИ
|
||||
fclose($fp); //закрытие
|
||||
}
|
||||
Chat::sendSys($text);
|
||||
}
|
||||
|
||||
|
||||
function addchp($text, $who, $room = 0)
|
||||
{
|
||||
if ($room == 0) {
|
||||
$room = User::getInstance()->getRoom();
|
||||
}
|
||||
$fp = fopen("tmp/chat.txt", "a"); //открытие
|
||||
flock($fp, LOCK_EX); //БЛОКИРОВКА ФАЙЛА
|
||||
fwrite($fp, ":[" . time() . "]:[{$who}]:[" . ($text) . "]:[" . $room . "]\r\n"); //работа с файлом
|
||||
fflush($fp); //ОЧИЩЕНИЕ ФАЙЛОВОГО БУФЕРА И ЗАПИСЬ В ФАЙЛ
|
||||
flock($fp, LOCK_UN); //СНЯТИЕ БЛОКИРОВКИ
|
||||
fclose($fp); //закрытие
|
||||
Chat::sendSys($text, $who);
|
||||
}
|
||||
|
||||
function err($t)
|
||||
|
||||
Reference in New Issue
Block a user