Будь проклят тот день, когда я решил ввести неймспейсы...

This commit is contained in:
lopar 2020-10-28 22:21:08 +02:00
parent f1b9ce6a45
commit d38d62c5b5
159 changed files with 339 additions and 304 deletions

View File

@ -7,7 +7,7 @@
session_start();
//require_once '../functions.php';
$user = new User($_SESSION['uid']);
$user = new \Battles\User($_SESSION['uid']);
if (!$user->admin) {
header("HTTP/1.0 404 Not Found");
exit;
@ -65,7 +65,7 @@ if ($_POST['ali']) { //Что делает эта штука?
}
$aligns = db::c()->query('SELECT `img`,`align`,`name` FROM `aligns` ORDER BY `align`');
Template::header('ᐰdminка');
\Battles\Template::header('ᐰdminка');
?>
<link rel=stylesheet href="/css/admin.css">
<form method='post'>
@ -554,7 +554,7 @@ foreach ($moj as $k => $v) {
$magic_name = "Лечение";
break;
case "al_neut_power":
$script_name = "RunMagicSelf";
$script_name = "RunmagicSelf";
$magic_name = "Сила нейтралитета";
break;
case "ct1":
@ -733,7 +733,7 @@ echo "</div>";
<button onclick="runmagic3('Test','0','0','0')">runmagic3</button>
<button onclick="runmagic4('Test','0','0','0')">runmagic4</button>
<button onclick="runmagicf('Test','0','0','0')">runmagicf</button>
<button onclick="RunMagicSelf('Test','0','0','0')">RunMagicSelf</button>
<button onclick="RunmagicSelf('Test','0','0','0')">RunmagicSelf</button>
<button onclick="vipad('Test','0','0','0')">vipad</button>
<button onclick="runmagicgold('Test','0','0','0')">new window test</button>
@ -960,7 +960,7 @@ if ($_POST['login'] && $_POST['krest']) {
Hint3Closed = false;
}
function RunMagicSelf(title, magic, name) {
function RunmagicSelf(title, magic, name) {
document.all("hint3").innerHTML = '<table width=100% cellspacing=1 cellpadding=0 bgcolor=CCC3AA><tr><td align=center><B>' + title + '</td><td width=20 align=right valign=top style="cursor: hand" onclick="closehint3();"><BIG><B>x</b></BIG></td></tr><tr><td colspan=2>' +
'<form action="admin.php" method=POST><table width=100% cellspacing=0 cellpadding=2 bgcolor=FFF6DD><tr><td colspan=2><INPUT TYPE=hidden name=sd4 value="<?php echo @$user['id']; ?>"> <INPUT TYPE=hidden NAME="use" value="' + magic + '">' +
'Использовать возможность "Сила Нейтралитета?"</TD></TR><TR><TD align=left><INPUT TYPE=hidden NAME="' + name + '" VALUE="<?php echo @$user['login']; ?>">' +

View File

@ -45,7 +45,7 @@ if ($del) {
}
db::c()->query('DELETE FROM `inventory` WHERE `id` = ?i', $del);
}
Template::header('ᐰdminка инвентаря');
\Battles\Template::header('ᐰdminка инвентаря');
?>
<h1>Администрирование инвентаря <?php if (isset($_SESSION['player_name'])) echo $_SESSION['player_name']; ?></h1>
<table class='adm'>

View File

@ -79,7 +79,7 @@ if ($get == 'exit') {
db::c()->query('UPDATE `users`,`online` SET `users`.`room` = 2702, `online`.`room` = 2702 WHERE `users`.`id` = ?i AND `online`.`id` = ?i', $user->id, $user->id);
header('Location: city.php');
}
Template::header('Академия');
\Battles\Template::header('Академия');
?>
<link href="css/secondary.css" rel="stylesheet"/>
<div style="float: right;">

View File

@ -126,7 +126,7 @@ if (isset($_GET['append'])) {
}
}
}
Template::header('Арена Ангелов');
\Battles\Template::header('Арена Ангелов');
?>
<link href="css/fight.css" rel="stylesheet"/>
<style>

View File

@ -18,34 +18,42 @@ if ($user->battle != 0) {
}
const SUCCESS = "Успешная операция!";
$bank = new Bank($user->id);
$bank = new \Battles\Bank($user->id);
$status = '';
$toid = (int)$_POST['to_id'] ?? 0;
$summa = (int)$_POST['summa'] ?? 0;
$toid = $_POST['to_id'] ?? 0;
$summa = $_POST['summa'] ?? 0;
$submit = $_POST['action'] ?? '';
try {
// Зачисление кредитов на счёт.
if ($submit === 'depositMoney' && $summa) {
$bank->depositMoney($summa);
$status = SUCCESS;
}
if ($submit === 'depositMoney' && $summa) {
$operation = $bank->depositMoney($summa);
$user->money = $operation['walletMoney'];
$bank->setMoney($operation['bankMoney']);
$status = SUCCESS;
}
// Снятие кредитов со счёта.
if ($submit === 'withdrawMoney' && $summa) {
$bank->withdrawMoney($summa);
$status = SUCCESS;
}
if ($submit === 'withdrawMoney' && $summa) {
$operation = $bank->withdrawMoney($summa);
$user->money = $operation['walletMoney'];
$bank->setMoney($operation['bankMoney']);
$status = SUCCESS;
}
// Перевод кредитов на другой счёт.
if ($submit === 'sendMoney' && $summa && $toid) {
$bank->sendMoney($toid, $summa);
$status = SUCCESS;
if ($submit === 'sendMoney' && $summa && $toid) {
$user->money = $bank->sendMoney($toid, $summa);
$status = SUCCESS;
}
} catch (\Exceptions\GameException $e) {
echo 'Банковская ошибка!';
} finally {
unset($submit, $summa, $toid);
}
unset($submit, $summa, $toid);
Template::header('Банк');
\Battles\Template::header('Банк');
?>
<link href="css/secondary.css" rel="stylesheet"/>
<script src="js/main.js"></script>
<?php Template::buildingTop(Rooms::$roomNames[29], 'strah') ?>
<?php \Battles\Template::buildingTop(\Battles\Rooms::$roomNames[29], 'strah') ?>
<div><?= $status ?></div>
<div class="appblock appblock-main">
<span class="wrap">На счету: <span class="num"><?= $bank->getMoney() ?></span></span>

View File

@ -11,7 +11,7 @@ $ch = $_GET['ch'] ?? null;
if ($header) {
exit;
} elseif ($ch != null) {
Template::header('buttons');
\Battles\Template::header('buttons');
?>
<script language="JavaScript" src="js/ch.js"></script>
<script language="JavaScript" src="js/sl2.js"></script>
@ -235,7 +235,7 @@ if ($header) {
<div id="oMenu" style="position: absolute; border:1px solid #666; background-color:#CCC; display:none; "></div>
<div id="ClearMenu" style="position: absolute; border:1px solid #666; background-color: #e2e0e0; display: none;"></div>
<? } else { Template::header(buttons); ?>
<? } else { \Battles\Template::header('buttons'); ?>
<script language="JavaScript" src="js/chat.js"></script>
<script language="JavaScript">

View File

@ -104,7 +104,7 @@ if ($map_user['Up'] == 1) {
onclick="location.href='?move=true&Dir=Up';" alt="Вверх">
MAP;
}
Template::header('forest');
\Battles\Template::header('forest');
?>
<link rel="stylesheet" type="text/css" href="css/hostel.css"/>
<style>

View File

@ -103,7 +103,7 @@ if ($in_haos['status'] == 2) {
}
}
$in_haos = mysql_fetch_array(mysql_query("SELECT * FROM `cit_haos_status` WHERE `id` = '{$user['id']}' LIMIT 1;"));
Template::header('Цитадель Хаоса');
\Battles\Template::header('Цитадель Хаоса');
?>
<!-- JS -->
<script>

View File

@ -130,7 +130,7 @@ if (!$ch_rooms[$in_haos['room']]) {
mysql_query("UPDATE `cit_haos_var` SET bots='',players='' WHERE group='" . $in_haos['group'] . "'; ");
header('location: c_haos.php');
}
Template::header('c_haos_in');
\Battles\Template::header('c_haos_in');
?>
<script>
function refreshPeriodic() {

View File

@ -121,7 +121,7 @@ if ($_POST['attack']) {
//старт боя - конец
Template::header('Городской Парк');
\Battles\Template::header('Городской Парк');
?>
<script>
function refreshPeriodic() {

View File

@ -63,7 +63,7 @@ if ($user->room == 403) {
}
}
}
Template::header('canalizaciya');
\Battles\Template::header('canalizaciya');
$ros = mysql_query("SELECT * FROM `labirint` WHERE `user_id`='{$_SESSION['uid']}'");
$mir = mysql_fetch_array($ros);

View File

@ -915,7 +915,7 @@ $standingon = $map[$y * 2][$x * 2];
foreach ($party as $k => $v) {
$map[$v['y'] * 2][$v['x'] * 2] = "u/" . $v['user'];
}
Template::header('cave');
\Battles\Template::header('cave');
?>
<style>
body {

2
ch.php
View File

@ -112,7 +112,7 @@ if (isset($_GET['online']) && $_GET['online'] != null) {
$ch4 = '_passive';
$ch5 = '_passive';
}
Template::header(sprintf('%s (%s)', $rooms[$user->room], mysql_num_rows($data)));
\Battles\Template::header(sprintf('%s (%s)', $rooms[$user->room], mysql_num_rows($data)));
?>
<script>
function fastshow(content) {

View File

@ -50,7 +50,7 @@ function show_messages()
show_messages();
Template::header('chat');
\Battles\Template::header('chat');
?>
<style>
form {

View File

@ -30,28 +30,28 @@ switch ($location[0]) {
default:
break;
case 'cp':
Travel::toRoom(20,$user->room);
Battles\Travel::toRoom(20,$user->room);
break;
case 'strah':
Travel::toRoom(21,$user->room);
Battles\Travel::toRoom(21,$user->room);
break;
case 'bps':
Travel::toRoom(26,$user->room);
Battles\Travel::toRoom(26,$user->room);
break;
case 'ps':
Travel::toRoom(51,$user->room);
Battles\Travel::toRoom(51,$user->room);
break;
case 'zaliv':
Travel::toRoom(2111,$user->room);
Battles\Travel::toRoom(2111,$user->room);
break;
case 'zamk':
Travel::toRoom(2601,$user->room);
Battles\Travel::toRoom(2601,$user->room);
break;
case 'abog':
Travel::toRoom(2655,$user->room);
Battles\Travel::toRoom(2655,$user->room);
break;
case 'torg':
Travel::toRoom(2702,$user->room);
Battles\Travel::toRoom(2702,$user->room);
break;
case 'got':
if ($user->room == 20) {
@ -59,34 +59,34 @@ switch ($location[0]) {
default:
break;
case 'level1':
Travel::toRoom(1,$user->room);
Battles\Travel::toRoom(1,$user->room);
break;
case 'level7':
Travel::toRoom(21,$user->room);
Battles\Travel::toRoom(21,$user->room);
break;
case 'level8':
Travel::toRoom(26,$user->room);
Battles\Travel::toRoom(26,$user->room);
break;
case 'level13':
header('location: quest_room.php');
break;
case 'level222':
Travel::toRoom(2702,$user->room);
Battles\Travel::toRoom(2702,$user->room);
break;
case 'level17':
Travel::toRoom(50,$user->room);
Battles\Travel::toRoom(50,$user->room);
break;
case 'level2':
Travel::toRoom(22,$user->room);
Battles\Travel::toRoom(22,$user->room);
break;
case 'level4':
Travel::toRoom(23,$user->room);
Battles\Travel::toRoom(23,$user->room);
break;
case 'level6':
Travel::toRoom(27,$user->room);
Battles\Travel::toRoom(27,$user->room);
break;
case 'level3':
Travel::toRoom(25,$user->room);
Battles\Travel::toRoom(25,$user->room);
break;
}
} elseif ($user->room == 21) {
@ -94,25 +94,25 @@ switch ($location[0]) {
default:
break;
case 'level4':
Travel::toRoom(20,$user->room);
Battles\Travel::toRoom(20,$user->room);
break;
case 'level3':
Travel::toRoom(2111,$user->room);
Battles\Travel::toRoom(2111,$user->room);
break;
case 'level13':
Travel::toRoom(34,$user->room);
Battles\Travel::toRoom(34,$user->room);
break;
case 'level5':
Travel::toRoom(29,$user->room);
Battles\Travel::toRoom(29,$user->room);
break;
case 'level16':
Travel::toRoom(31,$user->room);
Battles\Travel::toRoom(31,$user->room);
break;
case 'level14':
Travel::toRoom(30,$user->room);
Battles\Travel::toRoom(30,$user->room);
break;
case 'level650':
Travel::toRoom(650,$user->room);
Battles\Travel::toRoom(650,$user->room);
break;
}
} elseif ($user->room == 2111) {
@ -120,17 +120,17 @@ switch ($location[0]) {
default:
break;
case 'level1':
Travel::toRoom(21,$user->room);
Battles\Travel::toRoom(21,$user->room);
break;
case 'level203':
Travel::toRoom(1055,$user->room);
Battles\Travel::toRoom(1055,$user->room);
break;
case 'level1000':
Travel::toRoom(620,$user->room);
Battles\Travel::toRoom(620,$user->room);
break;
case 'room666':
//Нет на карте
//Travel::toRoom(666,$user->room);
//Battles\Travel::toRoom(666,$user->room);
break;
}
} elseif ($user->room == 2601) {
@ -138,19 +138,19 @@ switch ($location[0]) {
default:
break;
case 'level4':
Travel::toRoom(26,$user->room);
Battles\Travel::toRoom(26,$user->room);
break;
case 'level55':
Travel::toRoom(2655,$user->room);
Battles\Travel::toRoom(2655,$user->room);
break;
case 'level1':
Travel::toRoom(37,$user->room);
Battles\Travel::toRoom(37,$user->room);
break;
case 'level1051':
Travel::toRoom(1051,$user->room);
Battles\Travel::toRoom(1051,$user->room);
break;
case 'level5':
Travel::toRoom(404,$user->room);
Battles\Travel::toRoom(404,$user->room);
break;
}
} elseif ($user->room == 2701) {
@ -158,10 +158,10 @@ switch ($location[0]) {
default:
break;
case 'level1':
Travel::toRoom(2111,$user->room);
Battles\Travel::toRoom(2111,$user->room);
break;
case 'level2':
Travel::toRoom(402,$user->room);
Battles\Travel::toRoom(402,$user->room);
break;
}
} elseif ($user->room == 2702) {
@ -169,10 +169,10 @@ switch ($location[0]) {
default:
break;
case 'level10':
Travel::toRoom(20,$user->room);
Battles\Travel::toRoom(20,$user->room);
break;
case 'level6':
Travel::toRoom(61,$user->room);
Battles\Travel::toRoom(61,$user->room);
break;
}
} elseif ($user->room == 2655) {
@ -180,10 +180,10 @@ switch ($location[0]) {
default:
break;
case 'level10':
Travel::toRoom(2601,$user->room);
Battles\Travel::toRoom(2601,$user->room);
break;
case 'level2055':
Travel::toRoom(603,$user->room);
Battles\Travel::toRoom(603,$user->room);
break;
}
} elseif ($user->room == 26) {
@ -191,25 +191,25 @@ switch ($location[0]) {
default:
break;
case 'level4':
Travel::toRoom(20,$user->room);
Battles\Travel::toRoom(20,$user->room);
break;
case 'level3':
Travel::toRoom(2601,$user->room);
Battles\Travel::toRoom(2601,$user->room);
break;
case 'level660':
Travel::toRoom(660,$user->room);
Battles\Travel::toRoom(660,$user->room);
break;
case 'level7':
Travel::toRoom(777,$user->room);
Battles\Travel::toRoom(777,$user->room);
break;
case 'level56':
Travel::toRoom(401,$user->room);
Battles\Travel::toRoom(401,$user->room);
break;
}
}
}
Template::header('city');
\Battles\Template::header('city');
echo sprintf('<div style="text-align: right;">Сейчас в игре: %s игроков.></div>', $online->getNumRows());
if (in_array($user->room, [20, 21, 26, 2601, 2655, 2111, 2701, 2702])) {
/* Улицы:
@ -222,5 +222,5 @@ if (in_array($user->room, [20, 21, 26, 2601, 2655, 2111, 2701, 2702])) {
* 2701 С ещё одним ристалищем?
* 2702 Торговая
*/
City::showStreet($user->room);
Battles\City::showStreet($user->room);
}

View File

@ -100,7 +100,7 @@ if ($login && $action == 'edit_status') {
}
$clan_memberlist = db::c()->query('SELECT `id`, `login`, `status`, `level`, `room`, `align`, (select `id` from `online` WHERE `date` >= ?i AND `id` = users.`id`) AS `online` FROM `users` WHERE `klan` = ?i ORDER BY `online` DESC , `login` ASC', (time() - 60), $clanRow['id']);
Template::header('clan');
\Battles\Template::header('clan');
?>
<div>
<button onclick="location.href='main.php'">Вернуться</button>

View File

@ -37,7 +37,7 @@ if ($_POST['add_zay']) {
mysql_query("INSERT INTO `clan_castle` VALUES ('{$user['id']}','{$user['klan']}');");
exit("<script>location.href='clan_castle.php';</script>");
}
Template::header('Замок Мэра');
\Battles\Template::header('Замок Мэра');
?>
<script>
function refreshPeriodic() {

View File

@ -14,7 +14,7 @@ $userClan = db::c()->query('SELECT short_name, full_name, info FROM clans where
$clanFullName = $_POST['clan_full_name'] ?? '';
$clanShortName = $_POST['clan_short_name'] ?? '';
$clanInfo = $_POST['clan_info'] ?? '';
$userBank = new Bank($user->id);
$userBank = new \Battles\Bank($user->id);
if ($clanFullName && $clanShortName && $clanInfo && !$userClan) {
$eff = db::c()->query('SELECT 1 FROM users_effects WHERE type = 20 AND owner_id = ?i', $user->id);
@ -59,8 +59,8 @@ if ($clanFullName && $clanShortName && $clanInfo && !$userClan) {
}
}
}
Template::header(Rooms::$roomNames[30]);
Template::buildingTop(Rooms::$roomNames[30], 'strah');
\Battles\Template::header(Rooms::$roomNames[30]);
\Battles\Template::buildingTop(Rooms::$roomNames[30], 'strah');
if ($userClan): ?>
<div>
<fieldset style="display: inline;">

View File

@ -4,7 +4,7 @@
* Author: Igor Barkov <lopar.4ever@gmail.com>
* Project name: Battles-Game
*/
Template::header('Список кланов');
\Battles\Template::header('Список кланов');
include_once "config.php";
$claninf = urldecode(filter_input(INPUT_SERVER,'QUERY_STRING'));

View File

@ -4,6 +4,7 @@
* Date: 03.07.2020
* Time: 07:24
*/
namespace Battles;
class Bank
{
@ -25,8 +26,8 @@ class Bank
public function __construct($row)
{
$bank_row = db::c()->query('SELECT user_id, money FROM bank WHERE user_id = ?i', $row)->fetch_assoc();
$this->user = db::c()->query('SELECT money FROM users WHERE id = ?i', $row)->fetch_object();
$bank_row = \db::c()->query('SELECT user_id, money FROM bank WHERE user_id = ?i', $row)->fetch_assoc();
$this->user = \db::c()->query('SELECT money FROM users WHERE id = ?i', $row)->fetch_object();
foreach ($this as $key => $value) {
if (isset($bank_row[$key])) {
$this->$key = $bank_row[$key];
@ -34,7 +35,7 @@ class Bank
}
// Если ВДРУГ у человека нет счёта в банке - создаём.
if (empty($this->user_id)) {
db::c()->query('INSERT INTO bank (user_id) VALUES (?i)', $row);
\db::c()->query('INSERT INTO bank (user_id) VALUES (?i)', $row);
$this->user_id = $row;
}
}
@ -48,7 +49,7 @@ class Bank
*/
private function bankCommission(int $amount): int
{
$bankCommission = round($amount * Config::$bank_commission);
$bankCommission = round($amount * \Config::$bank_commission);
if ($bankCommission < 1) {
return 1;
} else {
@ -82,7 +83,7 @@ class Bank
$text .= " Комиссия: " . $this->bankCommission($amount);
}
db::c()->query('INSERT INTO `bank_logs` (sender_id, receiver_id, amount_result, type, text)
\db::c()->query('INSERT INTO `bank_logs` (sender_id, receiver_id, amount_result, type, text)
VALUES (?i, ?i, ?i, "?s", "?s")', $senderId, $receiverId, $amount, $operationType, $text);
}
@ -92,21 +93,21 @@ class Bank
* @param int $receiver ID получателя.
* @param int $amount сумма.
*
* @return void
* @return int
* @throws \Krugozor\Database\Mysql\Exception
*/
public function sendMoney(int $receiver, int $amount): void
public function sendMoney(int $receiver, int $amount): int
{
$receiverWallet = db::c()->query('SELECT money FROM bank WHERE user_id = ?i', $receiver)->fetch_object();
$receiverWallet = \db::c()->query('SELECT money FROM bank WHERE user_id = ?i', $receiver)->fetch_object();
if ($amount <= 0) {
throw new Exception(self::ERROR_WRONG_AMOUNT);
throw new \Exceptions\GameException(self::ERROR_WRONG_AMOUNT);
}
if (!$receiverWallet) {
throw new Exception(self::ERROR_NO_BANK_ACCOUNT);
throw new \Exceptions\GameException(self::ERROR_NO_BANK_ACCOUNT);
}
$amountWithComission = $amount + $this->bankCommission($amount);
if ($amountWithComission > $this->money) {
throw new Exception(self::ERROR_NO_MONEY_IN_BANK_ACCOUNT);
throw new \Exceptions\GameException(self::ERROR_NO_MONEY_IN_BANK_ACCOUNT);
}
// Снимаем сумму с комиссией у отправителя
$this->money -= $amountWithComission;
@ -116,6 +117,8 @@ class Bank
$receiverWallet->money += $amount;
self::setBankMoney($receiverWallet->money, $receiver);
$this->bankLogs($receiver, $receiverWallet->money, "receiveMoney");
// Возвращаем изменившиеся значения
return $this->money;
}
/**
@ -123,26 +126,30 @@ class Bank
*
* @param int $amount сумма.
*
* @return void
* @return array
* @throws \Krugozor\Database\Mysql\Exception
*/
public function depositMoney(int $amount): void
public function depositMoney(int $amount): array
{
if ($amount <= 0) {
throw new Exception(self::ERROR_WRONG_AMOUNT);
throw new \Exceptions\GameException(self::ERROR_WRONG_AMOUNT);
}
$wallet = db::c()->query('SELECT money FROM users WHERE id = ?i', $this->user_id)->fetch_object();
$wallet = \db::c()->query('SELECT money FROM users WHERE id = ?i', $this->user_id)->fetch_object();
if ($wallet->money < $amount) {
throw new Exception(self::ERROR_NO_MONEY_IN_WALLET);
throw new \Exceptions\GameException(self::ERROR_NO_MONEY_IN_WALLET);
}
// Забираем деньги из кошелька получателя
//todo check it!
$this->user->money -= $amount;
self::setWalletMoney($this->user->money, $this->user_id);
// Отдаём сумму на счёт получателю
$this->money += $amount;
self::setBankMoney($this->money, $this->user_id);
$this->bankLogs(0, $this->money, "depositMoney");
// Возвращаем изменившиеся значения
return [
'walletMoney' => $this->user->money,
'bankMoney' => $this->money
];
}
/**
@ -150,26 +157,30 @@ class Bank
*
* @param int $amount сумма.
*
* @return void
* @return array
* @throws \Krugozor\Database\Mysql\Exception
*/
public function withdrawMoney(int $amount): void
public function withdrawMoney(int $amount):array
{
if ($amount <= 0) {
throw new Exception(self::ERROR_WRONG_AMOUNT);
throw new \Exceptions\GameException(self::ERROR_WRONG_AMOUNT);
}
$amountWithComission = $amount + $this->bankCommission($amount);
if ($this->money < $amountWithComission) {
throw new Exception(self::ERROR_NO_MONEY_IN_BANK_ACCOUNT);
throw new \Exceptions\GameException(self::ERROR_NO_MONEY_IN_BANK_ACCOUNT);
}
// Снимаем сумму с комиссией у отправителя
$this->money -= $amountWithComission;
self::setBankMoney($this->money, $this->user_id);
$this->bankLogs(0, $this->money, "withdrawMoney");
// Отдаём сумму в кошелёк получателя
//todo check it!
$this->user->money += $amount;
self::setWalletMoney($this->user->money, $this->user_id);
// Возвращаем изменившиеся значения
return [
'walletMoney' => $this->user->money,
'bankMoney' => $this->money
];
}
/**
@ -184,10 +195,15 @@ class Bank
*/
public static function setBankMoney(int $amount, int $user_id, string $operationType = ''): void
{
db::c()->query('UPDATE bank SET money = ?i WHERE user_id = ?i', $amount, $user_id);
if ($operationType) {
(new Bank($user_id))->bankLogs(0, $amount, $operationType);
try {
\db::c()->query('UPDATE bank SET money = ?i WHERE user_id = ?i', $amount, $user_id);
if ($operationType) {
(new Bank($user_id))->bankLogs(0, $amount, $operationType);
}
} catch (\Throwable $e) {
echo "Не отработал запрос в БД в файле {$e->getFile()}({$e->getLine()})";
}
}
/**
@ -201,7 +217,12 @@ class Bank
*/
public static function setWalletMoney(int $amount, int $user_id): void
{
db::c()->query('UPDATE users SET money = ?i WHERE `id` = ?i', $amount, $user_id);
try {
\db::c()->query('UPDATE users SET money = ?i WHERE `id` = ?i', $amount, $user_id);
} catch (\Throwable $e) {
echo "Не отработал запрос в БД в файле {$e->getFile()}({$e->getLine()})";
}
}
public function getMoney()

View File

@ -1,5 +1,6 @@
<?php
# Date: 26.10.2020 (17:56)
namespace Battles;
// todo: #10
class City
{

View File

@ -4,7 +4,7 @@
* Date: 06.07.2020
* Time: 22:41
*/
namespace Battles;
class DressedItems
{
private $DB;

View File

@ -1,5 +1,5 @@
<?php
namespace Battles;
class InventoryItem extends Item
{
private $present;

View File

@ -1,5 +1,5 @@
<?php
namespace Battles;
abstract class Item
{
protected $item_id;

View File

@ -1,8 +1,11 @@
<?php
# Date: 16.09.2020 (08:23)
// Магия лечения травм
namespace Battles\Magic;
use Battles\UserEffects;
use Battles\User;
class CureInjury extends Magic
class CureInjury extends magic
{
private $target;
use UserEffects;
@ -17,10 +20,10 @@ class CureInjury extends Magic
{
$this->target = $target;
if ($target && $this->isUsable()) {
$injury = db::c()->query('SELECT effect_id, type, name FROM users_effects WHERE type IN (11,12,13,14) AND owner_id = ?i ORDER BY type DESC LIMIT 1', $target)->fetch_object();
$injury = \db::c()->query('SELECT effect_id, type, name FROM users_effects WHERE type IN (11,12,13,14) AND owner_id = ?i ORDER BY type DESC LIMIT 1', $target)->fetch_object();
$targetName = $this->target->login;
if (in_array($injury->effect_id, [11, 12, 13, 14]) && $injuryType >= $injury->type) {
db::c()->query('DELETE FROM users_effects WHERE effect_id = ?i', $injury->effect_id);
\db::c()->query('DELETE FROM users_effects WHERE effect_id = ?i', $injury->effect_id);
if (empty($injury->name) || $injury->name == 'Неизвестный эффект') {
$injuryName = self::$effectName[$injury->type];
} else {
@ -28,7 +31,7 @@ class CureInjury extends Magic
}
return "Вы вылечили повреждение ${injuryName} персонажу ${targetName}.";
} elseif ($injury->effect_id && $injuryType == 15) {
db::c()->query('DELETE FROM users_effects WHERE type IN (11,12,13,14) AND owner_id = ?i', $target);
\db::c()->query('DELETE FROM users_effects WHERE type IN (11,12,13,14) AND owner_id = ?i', $target);
return "Вы вылечили все повреждения персонажу ${targetName}.";
} else {
return false;

View File

@ -1,6 +1,6 @@
<?php
# Date: 16.09.2020 (08:45)
namespace Battles\Magic;
class Magic
{
protected $status;

View File

@ -1,6 +1,6 @@
<?php
namespace magic\attack;
namespace Battles\Magic;
use db;

View File

@ -4,15 +4,15 @@
* Date: 05.07.2020
* Time: 23:32
*/
namespace Battles\Models;
class EffectsModel
{
protected $DB;
const EFFECT_HIDEUSERINFO = 5; // Обезлик
public function __construct(int $user_id) {
try {
$this->DB = db::c()->query('SELECT * FROM users_effects WHERE owner_id = ?i', $user_id);
} catch (Exception $e) {echo '<div class="debug">class EffectsModel: Не могу подключиться к таблице effects!</div>';}
$this->DB = \db::c()->query('SELECT * FROM users_effects WHERE owner_id = ?i', $user_id);
} catch (\Throwable $e) {echo '<div class="debug">class EffectsModel: Не могу подключиться к таблице effects!</div>';}
}
private function getEffects($user_id)

View File

@ -4,6 +4,8 @@
* Date: 04.07.2020
* Time: 13:17
*/
namespace Battles\Models;
use Exceptions\GameException;
class PresentsModel
{
@ -12,12 +14,10 @@ class PresentsModel
public function __construct(int $user_id)
{
if (!$this->DB) {
try {
$this->DB = db::c()->query('SELECT sender_id, image FROM `users_presents` WHERE owner_id = ?i', $user_id);
} catch (Exception $e) {
echo "<div class='debug'>class PresentsModel: Не прогрузилась база!</div>";
$this->DB = \db::c()->query('SELECT sender_id, image FROM `users_presents` WHERE owner_id = ?i', $user_id);
if ($this->DB->getNumRows() == 0) {
throw new GameException("<div class='debug'>class PresentsModel: Не прогрузилась база!</div>");
}
}
}

View File

@ -4,14 +4,14 @@
* Date: 05.07.2020
* Time: 22:38
*/
namespace Battles\Models;
class UserLogModel
{
protected $DB;
public function __construct(int $user_id)
{
$this->DB = db::c()->query('SELECT * FROM users_logs WHERE user_id = ?i ORDER BY `id` ASC', $user_id);
$this->DB = \db::c()->query('SELECT * FROM users_logs WHERE user_id = ?i ORDER BY `id` ASC', $user_id);
}

View File

@ -1,5 +1,5 @@
<?php
namespace Battles;
/**
* Разные способы отображения строки с логином персонажа.
*/

View File

@ -1,4 +1,5 @@
<?php
namespace Battles;
/*
* Список наименований игровых комнат.
*/

View File

@ -1,5 +1,5 @@
<?php
namespace Battles;
class ShopItem extends Item
{
public function printInfo()

View File

@ -1,6 +1,6 @@
<?php
# Date: 30.09.2020 (09:42)
namespace Battles;
class Template
{
/**

View File

@ -1,6 +1,6 @@
<?php
# Date: 26.10.2020 (16:08)
namespace Battles;
class Travel
{
/**
@ -48,8 +48,8 @@ class Travel
*/
public static function toRoom(int $roomId, int $roomIdCurrent): void
{
$itemsWeight = db::c()->query('SELECT SUM(weight) AS all_weight FROM `inventory` WHERE owner_id = ?i AND on_sale = 0', $_SESSION['uid'])->fetch_assoc();
$eff = db::c()->query('SELECT type FROM users_effects WHERE owner_id = ?i AND (`type` = 10 OR `type` = 13 OR `type` = 14)', $_SESSION['uid'])->fetch_assoc();
$itemsWeight = \db::c()->query('SELECT SUM(weight) AS all_weight FROM `inventory` WHERE owner_id = ?i AND on_sale = 0', $_SESSION['uid'])->fetch_assoc();
$eff = \db::c()->query('SELECT type FROM users_effects WHERE owner_id = ?i AND (`type` = 10 OR `type` = 13 OR `type` = 14)', $_SESSION['uid'])->fetch_assoc();
$errors = [];
if ($itemsWeight['all_weight'] > get_meshok()) {
$errors[0] = 'У вас переполнен рюкзак, вы не можете передвигаться...';
@ -65,7 +65,7 @@ class Travel
echo sprintf('<span class="error">%s</span>', $error);
}
} elseif (in_array($roomId, self::allowedRoomMoves($roomIdCurrent))) {
db::c()->query('UPDATE users, online SET users.room = ?i, online.room = ?i WHERE `online`.`user_id` = `users`.`id` AND `online`.`user_id` = ?i', $roomId, $roomId, $_SESSION['uid']);
\db::c()->query('UPDATE users, online SET users.room = ?i, online.room = ?i WHERE `online`.`user_id` = `users`.`id` AND `online`.`user_id` = ?i', $roomId, $roomId, $_SESSION['uid']);
header('location: ' . self::$roomFileName[$roomId]);
exit;
}

View File

@ -1,4 +1,6 @@
<?php
namespace Battles;
use Exceptions\GameException;
class User
{
@ -51,7 +53,7 @@ class User
public function __construct($user)
{
$user_query = db::c()->query('SELECT * FROM users WHERE id = "?s" OR login = "?s"', $user, $user)->fetch_assoc();
$user_query = \db::c()->query('SELECT * FROM users WHERE id = "?s" OR login = "?s"', $user, $user)->fetch_assoc();
foreach ($this as $key => $value) {
if (isset($user_query[$key])) {
$this->$key = $user_query[$key];
@ -66,7 +68,7 @@ class User
* @param $stat_name - имя стата. Может принимать значения 'strength', 'dexterity', 'intuition', 'endurance', 'intelligence', 'wisdom'.
* @param int $isMainWindow - переключатель "главного окна". Если включить, дополнительно будет показывать ссылку на повышение стата на 1, при условии наличия свободных очков статов.
* @return string
* @throws Exception
* @throws GameException
*/
public function getStat($stat_name, $isMainWindow = 0)
{
@ -78,14 +80,14 @@ class User
return $this->$stat_name;
}
} else {
throw new Exception(self::ERROR_STAT_UNKNOWN);
throw new \Exceptions\GameException(self::ERROR_STAT_UNKNOWN);
}
}
/**
* Повышает один из выбранных статов на 1, но не выше self::STAT_MAXIMUM_AMOUNT при условии наличия свободных очков статов.
* @param $stat_name - имя стата. Может принимать значения 'strength', 'dexterity', 'intuition', 'endurance', 'intelligence', 'wisdom'.
* @throws \Krugozor\Database\Mysql\Exception
* @throws GameException
*/
public function addOnePointToStat($stat_name)
{
@ -93,12 +95,12 @@ class User
if (in_array($stat_name, $allowed)) {
if ($this->free_stat_points > 0 && $this->$stat_name <= self::STAT_MAXIMUM_AMOUNT) {
$query = 'UPDATE users SET ?f = ?f + 1, free_stat_points = free_stat_points - 1 WHERE id = ?i';
db::c()->query($query, $stat_name, $stat_name, $this->id);
\db::c()->query($query, $stat_name, $stat_name, $this->id);
} else {
throw new Exception(self::ERROR_STAT_IS_MAXIMUM);
throw new \Exceptions\GameException(self::ERROR_STAT_IS_MAXIMUM);
}
} else {
throw new Exception(self::ERROR_STAT_UNKNOWN);
throw new \Exceptions\GameException(self::ERROR_STAT_UNKNOWN);
}
}

View File

@ -1,7 +1,7 @@
<?php
# Date: 16.09.2020 (08:28)
# Названия эффектов, налагаемых на персонажа.
namespace Battles;
trait UserEffects
{
public static $effectName = [

View File

@ -1,5 +1,5 @@
<?php
namespace Battles;
class UserInfo extends User
{
use Rooms;
@ -141,7 +141,7 @@ class UserInfo extends User
$infoString = '<br><span>ИД Игрока: %s<br> ИД Комнаты: %s<br> Деньги: %s<br> Деньги в банке: %s<br> Опыт: %s<br> Нераспределённые очки: %s<br> Текущая сессия: %s</span>';
echo sprintf($infoString, $this->id, $this->room, $this->money, $this->Bank->getMoney(), $this->experience, $this->free_stat_points, $this->session_id);
}
$this->UserLogs = new UserLogModel($this->id);
$this->UserLogs = new \Battles\Models\UserLogModel($this->id);
echo '<div class="secret-info-user-log"><b>Личное дело</b><br>';
while ($userLogRow = $this->UserLogs->getUserLog()->fetch_object()) {
echo sprintf('<code>%s</code><br>', date("d.m.Y H:i ", strtotime($userLogRow->date)) . $userLogRow->text);
@ -153,18 +153,18 @@ class UserInfo extends User
public function showUserInfo()
{
$this->effects = new EffectsModel($this->id);
$this->effects = new \Battles\Models\EffectsModel($this->id);
$this->WatcherStatus();
if ($this->block && (!$this->watcherIsAdmin || !$this->watcherIsModerator)) {
throw new Exception('<span class="error">Персонаж ' . $this->login . ' заблокирован!</span>');
throw new \Exceptions\GameException('<span class="error">Персонаж ' . $this->login . ' заблокирован!</span>');
} elseif ($this->effects->getHideUserInfoStatus() && (!$this->watcherIsAdmin || !$this->watcherIsModerator)) {
if ($this->effects->getHideUserInfoStatus() == -1) {
$date = 'навсегда';
} else {
$date = 'до' . date('d.m.Y', strtotime($this->effects->getHideUserInfoStatus()));
}
throw new Exception('<span class="error">Персонаж ' . $this->login . ' обезличен ' . $date . '.</span>');
throw new \Exceptions\GameException('<span class="error">Персонаж ' . $this->login . ' обезличен ' . $date . '.</span>');
} else {
$this->Info();
}

View File

@ -141,10 +141,10 @@ FROM `inventory` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `dressed` = 0
$iteminfo = [];
while ($row = $data->fetch_assoc()) {
$iteminfo[] = new ShopItem($row);
$iteminfo[] = new \Battles\ShopItem($row);
}
Template::header('Рынок');
\Battles\Template::header('Рынок');
?>
<script src="js/main.js"></script>
<h1>Рынок</h1>

View File

@ -18,24 +18,21 @@ header("Pragma: no-cache");
/**
* Классы для работы с базой данных.
*/
require_once('Database/Mysql.php');
require_once('Database/Exception.php');
require_once('Database/Statement.php');
require_once('Database/db.php');
require_once 'classes/Database/Mysql.php';
require_once 'classes/Database/Exception.php';
require_once 'classes/Database/Statement.php';
require_once 'classes/Database/db.php';
/**
* Автозагрузка классов.
* Автозагрузка классов с учётом неймспейсов.
*/
spl_autoload_register(function ($class_name) {
$class_name .= '.php';
if (file_exists('classes/' . $class_name)) {
require_once 'classes/' . $class_name;
} elseif (file_exists('models/' . $class_name)) {
require_once 'models/' . $class_name;
} else {
throw new Exception(sprintf('Невозможно загрузить класс %s', $class_name));
}
spl_autoload_register(function ($className){
$fileName = __DIR__ . '/classes/' . str_replace('\\', '/', $className . '.php');
if (file_exists($fileName)) {
require_once $fileName;
}
});
trait Config
@ -206,5 +203,5 @@ trait Config
1250000000 => [1, 0, 0, 450, 0, 1500000000],
1500000000 => [10, 1, 5, 8000, 1, 9999999999], # Это тринадцатый уровень
];
public static $cavedata = [621 => ['x1' => 6, 'y1' => 11, 'dir1' => 1, 'x2' => 10, 'y2' => 8, 'dir2' => 1, 'x3' => 20, 'y3' => 4, 'dir3' => 1, 'x4' => 10, 'y4' => 10, 'dir4' => 1, 'delay' => 360, 'name1' => 'Проклятый Рудник', 'name2' => 'Проклятого Рудника']];
public static $cavedata = [621 => ['x1' => 6, 'y1' => 11, 'dir1' => 1, 'x2' => 10, 'y2' => 8, 'dir2' => 1, 'x3' => 20, 'y3' => 4, 'dir3' => 1, 'x4' => 10, 'y4' => 10, 'dir4' => 1, 'delay' => 360, 'name1' => 'Проклятый Рудник', 'name2' => 'Проклятого Рудника']];
}

View File

@ -52,7 +52,7 @@ if ($username && $password) {
$error = ERROR_EMPTY_CREDENTIALS;
}
Template::header('Входим...');
\Battles\Template::header('Входим...');
if ($error) {
echo sprintf('<a href="/"> ← на главную</a><h1>%s</h1>', $error);

View File

@ -75,7 +75,7 @@ if (in_array($user->room, Config::$canalenters)) {
$cavedata = [620 => ['x1' => 3, 'y1' => 2, 'dir1' => 2]];
$podzemdata = [621 => ['name1' => 'Проклятый Рудник', 'name2' => 'Проклятого Рудника']];
$warning = $_GET["warning"] ?? '';
Template::header('enter_cave');
\Battles\Template::header('enter_cave');
if ($warning) {
echo sprintf('<b style="color: #f80000">%s</b>', $warning);
}

View File

@ -21,7 +21,7 @@ if (isset($user['id'])) {
include('./classes/battle_new.class.php');
$fbattle = new fbattle($user['battle']);
Template::header('fbattle');
\Battles\Template::header('fbattle');
?>
<script type="text/javascript" src="js/sl2.js"></script>
<script type="text/javascript" src="js/ch.js"></script>
@ -139,7 +139,7 @@ Template::header('fbattle');
<tr>
<td valign=top width=250 nowrap>
<?php
$myinfo = new User($_SESSION['uid']);
$myinfo = new \Battles\User($_SESSION['uid']);
$myinfo->showUserDoll(1);
?>
</td>
@ -476,7 +476,7 @@ Template::header('fbattle');
<?php
if ($fbattle->return == 1) {
$enemyInfo = new User($fbattle->enemy);
$enemyInfo = new \Battles\User($fbattle->enemy);
$enemyInfo->showUserDoll(1);
} else {
if ($fbattle->battle_data['type'] == 4 || $fbattle->battle_data['type'] == 5) {

View File

@ -4,6 +4,7 @@ if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
require_once 'config.php';
$userLoginStatus = db::c()->query('SELECT enter_game FROM users WHERE id = ?i', $_SESSION['uid'])->getNumRows() ?? 0;
if (empty($userLoginStatus)) {
@ -11,7 +12,8 @@ if (empty($userLoginStatus)) {
} else {
db::c()->query('UPDATE `users` SET `enter_game` = 0 WHERE `enter_game` = 1 AND `id` = ?i', $_SESSION['uid']);
}
Template::header('Окно игры');
\Battles\Template::header('Окно игры');
?>
<script>
if (!navigator.cookieEnabled) {

View File

@ -118,7 +118,7 @@ if ($_GET['res']) {
echo "&nbsp;<font style='font-size:12px; color:cc0000;'>Кто-то оказался быстрее!</font>";
}
}
Template::header('Лес');
\Battles\Template::header('Лес');
?>
<script src="i/forest/char1.32.js"></script>
<script src="i/forest/funcs1.6.js"></script>

View File

@ -5,7 +5,7 @@ if (empty($_SESSION['uid'])) {
header("Location: index.php");
exit;
}
$user = new User($_SESSION['uid']);
$user = new \Battles\User($_SESSION['uid']);
$sleep = db::c()->query('SELECT `id` FROM `effects` WHERE `owner` = ?i AND `time` > ?i AND `type` = 3', $user['id'], time())->fetch_assoc();
$ps = $_GET['page'] ?? 0;
$isModerator = false;
@ -206,7 +206,7 @@ if (isset($_GET['do']) && $isModerator == true) {
exit();
}
}
Template::header('Форум');
\Battles\Template::header('Форум');
?>
<link rel="stylesheet" href="css/wysibb/theme/default/wbbtheme.css"/>
<script type="text/javascript" language="JavaScript" src='js/forum.js'></script>

View File

@ -7,9 +7,9 @@
*/
require_once 'config.php';
if (empty($_SESSION['uid'])) {
throw new Exception('Не могу проинициализировать игрока!');
throw new \Exceptions\GameException('Не могу проинициализировать игрока!');
}
$user = new User($_SESSION['uid']);
$user = new \Battles\User($_SESSION['uid']);
if ($user->id && $user->block) {
exit('user blocked!');
}

View File

@ -12,7 +12,7 @@ if (empty($_SESSION['uid'])) header("Location: index.php");
//$msg = filter_input(INPUT_POST,'msg');
//$uid = $_SESSION['uid'];
//if ($msg) db::c()->query('INSERT INTO `chat` (`cid`, `uid`, `msg`) VALUES (?i, ?i, "?s")', 1, $uid, $msg);
Template::header('Окно игры');
\Battles\Template::header('Окно игры');
?>
<style>
form {

View File

@ -12,7 +12,7 @@ if (empty($_SESSION['uid'])) header("Location: index.php");
//$msg = filter_input(INPUT_POST,'msg');
//$uid = $_SESSION['uid'];
//if ($msg) db::c()->query('INSERT INTO `chat` (`cid`, `uid`, `msg`) VALUES (?i, ?i, "?s")', 1, $uid, $msg);
Template::header('Окно игры');
\Battles\Template::header('Окно игры');
?>
<style>
form {

View File

@ -96,7 +96,7 @@ if ($user->room == 40) {
} else $status = 'Не хватает денег!';
}
}
Template::header('Клановый замок');
\Battles\Template::header('Клановый замок');
?>
<script src="js/main.js"></script>
<style>

View File

@ -204,7 +204,7 @@ if ($_GET['exit'] == 1) {
header('Location: city.php');
}
Template::header('group_arena');
\Battles\Template::header('group_arena');
?>
<script>
function growl(title, color, message, stycky) {

View File

@ -42,7 +42,7 @@ $hr = new hellround;
$mytrip = $hr->is_in_trip($user['id']);
$tr = $hr->get_par($mytrip);
Template::header('hell');
\Battles\Template::header('hell');
if ($mytrip > 0) {
?>

View File

@ -5,7 +5,7 @@ if (empty($_SESSION['uid'])) {
exit;
}
include('config.php');
$user = new User($_SESSION['uid']);
$user = new \Battles\User($_SESSION['uid']);
$hostel = mysql_fetch_array(mysql_query('SELECT `id`, `uid`, `type`, `time` FROM `hostel` WHERE `uid` = "' . $user['id'] . '" LIMIT 1'));
#include('functions.php');
$error = '';
@ -154,7 +154,7 @@ if ($_GET['unsleep'] && $user['sleep'] > 0) {
}
header('Location: hostel.php');
}
Template::header('Хостел');
\Battles\Template::header('Хостел');
?>
<script src="js/ajaxLoad.js"></script>
<? if (isset($hostel['id'])) { ?>

View File

@ -334,7 +334,7 @@ if ($_GET['go_back'] == 1) {
header('Location: hostel.php');
}
Template::header('hostel_room');
\Battles\Template::header('hostel_room');
?>
<script src="js/ajaxLoad.js"></script>
<link rel="stylesheet" type="text/css" href="css/hostel.css"/>

View File

@ -4,8 +4,8 @@ if ($_SESSION['uid']) {
header('Location: fight.php');
exit;
}
require_once './classes/Template.php';
Template::header('Вход');
require_once './classes/Battles/Template.php';
\Battles\Template::header('Вход');
?>
<h1>Демонстрационная версия</h1>
<div>

View File

@ -2,11 +2,11 @@
session_start();
include_once 'config.php';
$login = urldecode($_SERVER['QUERY_STRING']) ?? '';
$userInfo = new UserInfo($login);
$presentsModel = new PresentsModel($userInfo->id);
$userInfo = new \Battles\UserInfo($login);
$presentsModel = new \Battles\Models\PresentsModel($userInfo->id);
$presentsList = $presentsModel->getAllPresents();
$userInfo->watcher_id = $_SESSION['uid'] ?? null;
Template::header('Информация о ' . $userInfo->login);
\Battles\Template::header('Информация о ' . $userInfo->login);
if (!$userInfo->id) {
echo sprintf('Ошибка: персонаж <em>%s</em> не найден...<p><a style="color: #99f;" href="javascript:window.history.go(-1);">←назад</a></p>', $login);
exit;

View File

@ -371,7 +371,7 @@ if ((time() - $_SESSION['time']) > 3) {
} else {
$tt = (time() - $_SESSION['time']);
}
Template::header('lab');
\Battles\Template::header('lab');
echo Nick::id($user)->battle();
echo " <a href=\"#\" onclick=\"javascript:if (confirm('Желаете выбраться из квестового лабиринта? Теряете все, что здесь нашли.')){ location.href='lab.php?eexit=1';}\">Выйти?</a>";

View File

@ -369,7 +369,7 @@ if ((time() - $_SESSION['time']) > 3) {
} else {
$tt = (time() - $_SESSION['time']);
}
Template::header('lab2');
\Battles\Template::header('lab2');
echo Nick::id($user)->battle();
echo " <a href=\"#\" onclick=\"javascript:if (confirm('Желаете выбраться из лабиринта? Теряете все что здесь нашли.')){ location.href='lab.php?eexit=1';}\">Выйти?</a>";

View File

@ -299,7 +299,7 @@ if ($user->room == 1051) {
header('Location: labirint.php');
}
}
Template::header('Вход в Лабиринты');
\Battles\Template::header('Вход в Лабиринты');
?>
<div style="float: right;">
<input type="button" onclick="location.href='lab_enter.php';" value="Обновить">

View File

@ -469,7 +469,7 @@ if ($user->room == 1052) {
$effed .= '<div><img width="40" height="25" src="/i/sh/event_timer_trap.gif" /> - Время перехода +3 секунды (Осталось : ' . timeOut($varos['trap1']['time'] - time()) . ')</div>';
}
unset($varos);
Template::header('labirint');
\Battles\Template::header('labirint');
?>
<script type="text/javascript" src="js/jquery.js"></script>
<script>

View File

@ -14,7 +14,7 @@ if ($user->battle) {
header('location: fbattle.php');
exit;
}
Template::header('Библиотека Просвещения');
\Battles\Template::header('Библиотека Просвещения');
?>
<TABLE border=0 width=600 cellspacing="0" cellpadding="0" align=left>

View File

@ -4,7 +4,7 @@ $_REQUEST['log'] = $_REQUEST['log'] ?? 0;
require_once "functions.php";
$data = mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id` = '" . $_REQUEST['log'] . "'"));
$log = file("backup/logs/battle" . $_REQUEST['log'] . ".txt");
Template::header('Лог поединка');
\Battles\Template::header('Лог поединка');
?>
<H3>Лог поединка</H3>
<FORM>

View File

@ -1,7 +1,7 @@
<?php
// Магия восстагновления здоровья
class Healing extends Magic
use Battles\User;
class Healing extends magic
{
private $target;
private $magicPower;

View File

@ -40,13 +40,13 @@ $ids = $_GET['ids'] ?? null;
$setShadow = $_POST['setshadow'] ?? null;
$edit = $_GET['edit'] ?? null;
// Подготавливаем отображение инфы и предметов.
$userInfo = new UserInfo($user->id);
$getItemsBonuses = new DressedItems($_SESSION['uid']);
$userInfo = new \Battles\UserInfo($user->id);
$getItemsBonuses = new \Battles\DressedItems($_SESSION['uid']);
$data_query = 'SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot = 0 AND on_sale = 0';
$data = db::c()->query($data_query, $_SESSION['uid']);
$iteminfo = [];
while ($row = $data->fetch_assoc()) {
$iteminfo[] = new InventoryItem($row);
$iteminfo[] = new \Battles\InventoryItem($row);
}
//Обработчики нажатий на кнопки.
@ -378,7 +378,7 @@ if ($mfs && $ids) {
}
}
if ($setShadow) {
Template::header('Образ персонажа');
\Battles\Template::header('Образ персонажа');
?>
<div style="text-align: right;">
<input type=button value="Вернуться" onClick="location.href='main.php?edit=<?= mt_rand() ?>';" class="button">
@ -429,7 +429,7 @@ if ($edit) {
addOnePoint($upm, 'mastery');
}
if ($drop) {
$items = new DressedItems($_SESSION['uid']);
$items = new \Battles\DressedItems($_SESSION['uid']);
$items->undressItem($drop);
}
//Пока что одеваем предмет отсюда.
@ -458,7 +458,7 @@ if ($edit) {
undressall($_SESSION['uid']);
}
}
Template::header('Игра');
\Battles\Template::header('Игра');
?>
<script src="js/funcs.js"></script>
<script>

View File

@ -23,7 +23,7 @@ $qsee = '';
$qx = 0;
$error = '';
Template::header('module_quest');
\Battles\Template::header('module_quest');
?>
<link rel="stylesheet" href="css/hostel.css"/>
<?php

View File

@ -16,7 +16,7 @@ $fd = mysql_fetch_array($df);
$cd = mysql_query("select `n18` from `podzem3` where `glava`='" . $fd['glava'] . "' and `name`='Канализация 1 этаж'");
$vb = mysql_fetch_array($cd);
if ($fd['location'] == '28' and $fd['name'] == 'Канализация 1 этаж' and $vb['n18'] == '8') {
Template::header('Подземелье Луки');
\Battles\Template::header('Подземелье Луки');
?>
<div id=hint3 class=ahint></div>
<TABLE width=100% cellspacing=0 cellpadding=0 border=0>
@ -24,7 +24,7 @@ if ($fd['location'] == '28' and $fd['name'] == 'Канализация 1 эта
<TD valign=top>
<div style="width: 250px; text-align: center;">
<?php
$userInfo = new User($_SESSION['uid']);
$userInfo = new \Battles\User($_SESSION['uid']);
$userInfo->showUserDoll();
?>
</div>
@ -791,7 +791,7 @@ if ($fd['location'] == '28' and $fd['name'] == 'Канализация 1 эта
$bot = "Лука";
$buser = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `login` = '$bot' LIMIT 1;"));
//FIXME Этот класс не умеет работать с ботами! Этот вызов - заглушка!
$botInfo = new User('Лука');
$botInfo = new \Battles\User('Лука');
$botInfo->showUserDoll();
?>
</TD>

View File

@ -62,11 +62,11 @@ if ($_SESSION['receiverName']) {
$queryItems = db::c()->query('SELECT * FROM inventory WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ?i', $user->id);
while ($row = $queryItems->fetch_assoc()) {
$iteminfo[] = new InventoryItem($row);
$iteminfo[] = new \Battles\InventoryItem($row);
}
}
}
Template::header('Почта');
\Battles\Template::header('Почта');
?>
<div style="float: right">
<button onclick="top.frames['gameframe'].location = 'city.php?cp'">Вернуться</button>

View File

@ -17,7 +17,7 @@ session_start();
if ($_SESSION['uid'] != 2) header("Location: index.php");
require_once 'config.php';
$user = new User($_SESSION['uid']);
$user = new \Battles\User($_SESSION['uid']);
$status = '';
$dirname = "i/presents/";
$images = glob($dirname . "*.png");
@ -62,7 +62,7 @@ if (!empty($_POST['sendAction'])) {
db::c()->query('INSERT INTO `telegraph` (receiver, text) VALUES (?i,"?s")', $receiver['id'], $telegraphText);
$status = "Подарок удачно доставлен к {$_POST['receiver']}! Вы потратили <b>{$cost}</b> кр.";
}
Template::header('Дарильня');
\Battles\Template::header('Дарильня');
?>
<script src="js/main.js"></script>
<style>

View File

@ -54,7 +54,7 @@ function info_quest($id)
if (!empty($q->error)) {
$status = $q->error;
}
Template::header('Памятник');
\Battles\Template::header('Памятник');
?>
<div style="float: right;">
<?php if (($user->level < 5 || $user->admin) && $user->health < $user->maxHealth): ?>

View File

@ -33,7 +33,7 @@ if ($_COOKIE[GAMEDOMAIN] ?? null) {
}
}
}
Template::header('Регистрация персонажа');
\Battles\Template::header('Регистрация персонажа');
?>
<a href="/"> на главную</a>
<?php if ($error ?? null): ?>

View File

@ -72,7 +72,7 @@ if ($newPassword && $hashCheck) {
$statusMessage = ERROR_WRONG_HASH;
}
}
Template::header('Восстановление пароля');
\Battles\Template::header('Восстановление пароля');
?>
<a href="/"> на главную</a>
<?php if (!empty($statusMessage)): ?>

View File

@ -74,7 +74,7 @@ if ($goto == 'remont') {
if ($goto == 'gravirovka') {
$gravirovka_query = db::c()->query('SELECT `id`,`name`,`img`,`text` FROM `inventory` WHERE `owner` = ?i AND `dressed` = 0 AND `type` = 3 AND `name` NOT LIKE "?S" AND `setsale` = 0 OR `text` <> "?s" AND `owner` = ?i AND `dressed` = 0 AND `setsale` = 0 ORDER by `update` DESC', $_SESSION['uid'], '%Букет%', '', $_SESSION['uid']);
}
Template::header('Кузня');
\Battles\Template::header('Кузня');
?>
<link href="css/secondary.css" rel="stylesheet"/>
<script src="js/main.js"></script>

View File

@ -105,7 +105,7 @@ FROM `shop` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE `count` > 0 AND `c
$iteminfo = [];
while ($row = $shopItems->fetch_assoc()) {
$iteminfo[] = new ShopItem($row);
$iteminfo[] = new \Battles\ShopItem($row);
}
} else {
$inventoryItems = db::c()->query('SELECT `inventory`.*,
@ -125,7 +125,7 @@ ORDER BY `update` DESC', null, $_SESSION['uid']);
$iteminfo = [];
while ($row = $inventoryItems->fetch_assoc()) {
$iteminfo[] = new ShopItem($row);
$iteminfo[] = new \Battles\ShopItem($row);
}
}
@ -248,7 +248,7 @@ if (!empty($_GET['buy'])) {
$status = "Недостаточно денег или нет вещей в наличии.";
}
}
Template::header('Магазин');
\Battles\Template::header('Магазин');
?>
<script src="js/main.js"></script>
<h1>Государственный магазин</h1>

View File

@ -1,6 +1,6 @@
<?php
require_once 'classes/Template.php';
Template::header('top_menu') ?>
require_once 'classes/Battles/Template.php';
\Battles\Template::header('top_menu') ?>
<style>
* {
margin: 0;

View File

@ -12,7 +12,7 @@ if ($user->battle) {
exit;
}
$Tournament = new Tournament();
Template::header('Турниры');
\Battles\Template::header('Турниры');
?>
<META HTTP-EQUIV="REFRESH" CONTENT="10">
<div style='color:#8F0000; font-weight:bold; font-size:16px; text-align:center; float:left;'>Турнирная</div>

View File

@ -98,7 +98,7 @@ if ($_GET['st'] == 'startmegaturnirnow') {
}
$tr = $bania->get_turnir();
$bania->get_fond();
Template::header('Башня смерти')
\Battles\Template::header('Башня смерти')
?>
<table border=0 width=100% cellspacing="0" cellpadding="0">
<td align=right>

View File

@ -275,7 +275,7 @@ if ($user['hp'] <= 0) {
header('Location: tower.php');
exit;
}
Template::header('towerin');
\Battles\Template::header('towerin');
?>
<script>
let Hint3Name = '';

View File

@ -1,5 +1,5 @@
<?php
require_once "config.php";
$tr = mysql_fetch_array(mysql_query("SELECT `id`, `coin`, `log` FROM `deztow_turnir` WHERE `id` = '" . mysql_real_escape_string($_GET['id']) . "' LIMIT 1"));
Template::header('Башня смерти. Отчет о турнире #'. $tr['id']);
\Battles\Template::header('Башня смерти. Отчет о турнире #'. $tr['id']);
echo sprintf('<h3>Башня смерти. Отчет о турнире.</h3><b>%s</b> кр.<br>%s', $tr['coin'], $tr['log']);

View File

@ -41,7 +41,7 @@ if($_GET['setdef']){
echo "<font color=red><b>Сохранено.</b></font>".mysql_error();
}
Template::header('towerstamp');
\Battles\Template::header('towerstamp');
?>
<h3>Профили характеристик</h3>
Статы не позволяют сходить в БС? Раскиньте ваши статы так, как вы хотите, и участвуйте в турнире! Выбранный по умолчанию профиль, загрузится сам. Вы можете создавать неограниченное число профилей, и менять их за секунды до турнира!

View File

@ -6,7 +6,7 @@ if (empty($_SESSION['uid'])) {
}
require_once "config.php";
$user = new User($_SESSION['uid']);
$user = new \Battles\User($_SESSION['uid']);
if ($user->room != 650) {
header("Location: main.php");
@ -26,7 +26,7 @@ if ($_GET['id'] && $user->admin) {
header("location: city.php");
exit;
}
Template::header('Клановый перекрёсток');
\Battles\Template::header('Клановый перекрёсток');
?>
<a href="/city.php?strah=1"> назад</a>
<h1>Переход к клановым улицам</h1>

View File

@ -543,7 +543,7 @@ if (empty($user->clan)) {
$bank = db::c()->query('SELECT `ekr` FROM `bank` WHERE `id` = ?i ', $_SESSION['uid'])->fetch_assoc();
Template::header('user_abilities');
\Battles\Template::header('user_abilities');
?>
<div style="float: right;">
<?php if ($user->admin == 1): ?>
@ -570,7 +570,7 @@ Template::header('user_abilities');
$magic_name = "Лечение";
break;
case "al_neut_power":
$script_name = "RunMagicSelf";
$script_name = "RunmagicSelf";
$magic_name = "Сила нейтралитета";
break;
case "ct1":

View File

@ -48,7 +48,7 @@ if ($oldpsw && $newpsw) {
err('Неверный текущий пароль!');
}
}
Template::header('Анкета');
\Battles\Template::header('Анкета');
?>
<a href="main.php"> на главную</a>
<h1>Анкета персонажа <?= $user->login ?></h1>

View File

@ -24,7 +24,7 @@ if ($user->room != 402) {
exit;
}
Template::header('Вход в водосток');
\Battles\Template::header('Вход в водосток');
?>
<style>
legend {

View File

@ -601,7 +601,7 @@ if (!empty($_POST['open'])) {
fputs($f, time());
fclose($f);
}
Template::header('zayavka');
\Battles\Template::header('zayavka');
?>
<style>
.m {