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

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

@ -9,7 +9,7 @@ if (empty($_SESSION['uid'])) {
if ($user['battle'] == 0) {
echo "Это боевая магия...";
} else {
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;"));
if ($user['intel'] >= 8) {
$int=$magic['chanse'] + ($user['intel'] - 8)*3;
if ($int>98){$int=99;}

View File

@ -9,7 +9,7 @@ if (empty($_SESSION['uid'])) {
if ($user['battle'] == 0) {
echo "Это боевая магия...";
} else {
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;"));
if ($user['intel'] >= 8) {
$int=$magic['chanse'] + ($user['intel'] - 8)*3;
if ($int>98){$int=99;}

View File

@ -9,7 +9,7 @@ if (empty($_SESSION['uid'])) {
if ($user['battle'] == 0) {
echo "Это боевая магия...";
} else {
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;"));
if ($user['intel'] >= 8) {
$int=$magic['chanse'] + ($user['intel'] - 8)*3;
if ($int>98){$int=99;}

View File

@ -9,7 +9,7 @@ if (empty($_SESSION['uid'])) {
if ($user['battle'] == 0) {
echo "Это боевая магия...";
} else {
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;"));
if ($user['intel'] >= 8) {
$int=$magic['chanse'] + ($user['intel'] - 8)*3;
if ($int>98){$int=99;}

View File

@ -9,7 +9,7 @@ if (empty($_SESSION['uid'])) {
if ($user['battle'] == 0) {
echo "Это боевая магия...";
} else {
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;"));
if ($user['intel'] >= 8) {
$int=$magic['chanse'] + ($user['intel'] - 8)*3;
if ($int>98){$int=99;}

View File

@ -9,7 +9,7 @@ if (empty($_SESSION['uid'])) {
if ($user['battle'] == 0) {
echo "Это боевая магия...";
} else {
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;"));
if ($user['intel'] >= 8) {
$int=$magic['chanse'] + ($user['intel'] - 8)*3;
if ($int>98){$int=99;}

View File

@ -9,7 +9,7 @@ if (empty($_SESSION['uid'])) {
if ($user['battle'] == 0) {
echo "Это боевая магия...";
} else {
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '16' ;"));
if ($user['intel'] >= 8) {
$int=$magic['chanse'] + ($user['intel'] - 8)*3;
if ($int>98){$int=99;}

View File

@ -1,6 +1,6 @@
<?php
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_escape_string($_POST['target'])."' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '76' ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '76' ;"));
$effect = mysql_fetch_array(mysql_query("SELECT `time` FROM `effects` WHERE `owner` = '{$us['id']}' and `type` = '205' LIMIT 1;"));
if ($user['intel'] >= 0) {

View File

@ -1,7 +1,7 @@
<?php
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_escape_string($_POST['target'])."' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '77' ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '77' ;"));
$effect = mysql_fetch_array(mysql_query("SELECT `time` FROM `effects` WHERE `owner` = '{$us['id']}' and `type` = '204' LIMIT 1;"));
if ($user['intel'] >= 0) {

View File

@ -4,7 +4,7 @@ if ($user['battle'] > 0) {
echo "Не в бою...";
} else {
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '3' ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '3' ;"));
if ($user['intel'] >= 2) {
$int=$magic['chanse'] + ($user['intel'] - 2)*3;
if ($int>98){$int=99;}

View File

@ -9,7 +9,7 @@ $forbidden=array("1","2","3","7","6","8","18","19","20","21","22","43","46","47"
"91", "92", "93", "94", "95", "96", "97", "98", "99", "100", "101", "102", "103", "104", "105", "106",
"107", "108", "109", "110", "111", "112", "113", "114", "115", "116", "117", "118", "119", "120", "121",
"122", "123", "124", "125", "126", "127", "128", "129", "130", "131", "132", "133", "134", "135", "136", "137", "138","139",);
// magic
// magic
// встраивание магии
if ($user['battle'] > 0) {
echo "Не в бою...";
@ -47,7 +47,7 @@ if ($user['battle'] > 0) {
".($dress['ngray']<$svitok['ngray']?"`ngray`='".$svitok['ngray']."',":"")."
".($dress['ndark']<$svitok['ndark']?"`ndark`='".$svitok['ndark']."',":"")."
".($dress['nlight']<$svitok['nlight']?"`nlevel`='".$svitok['nlight']."',":"")."
`massa`=`massa`+1,`cost`=`cost`+'".$svitok['cost']."', `includemagic` = '".$svitok['magic']."', `includemagicdex` = '".$svitok['maxdur']."', `includemagicmax` = '".$svitok['maxdur']."', `includemagicname` = '".$svitok['name']."', `includemagicuses` = '100+".$user['intel']."', `includemagiccost` = '".($svitok['cost']/2)."' WHERE `id` = '{$dress['id']}' LIMIT 1;");
`massa`=`massa`+1,`cost`=`cost`+'".$svitok['cost']."', `includemagic` = '".$svitok['magic']."', `includemagicdex` = '".$svitok['maxdur']."', `includemagicmax` = '".$svitok['maxdur']."', `includemagicname` = '".$svitok['name']."', `includemagicuses` = '100+".$user['intel']."', `includemagiccost` = '".($svitok['cost']/2)."' WHERE `id` = '{$dress['id']}' LIMIT 1;");
$bet=1;
}
}

View File

@ -19,7 +19,7 @@ $us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `
<?php*/
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '22' ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '22' ;"));
$effect = mysql_fetch_array(mysql_query("SELECT `time` FROM `effects` WHERE `owner` = '{$us['id']}' and `type` = '203' LIMIT 1;"));
if($user['invis'] == 1) { $user['login'] = '<b><i>невидимка</i></b>'; }

View File

@ -1,7 +1,7 @@
<?php
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '14' ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '14' ;"));
$effect = mysql_fetch_array(mysql_query("SELECT `time` FROM `effects` WHERE `owner` = '{$us['id']}' and `type` = '2' LIMIT 1;"));
if ($user['intel'] >= 1) {

View File

@ -1,7 +1,7 @@
<?php
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '15' ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '15' ;"));
$effect = mysql_fetch_array(mysql_query("SELECT `time` FROM `effects` WHERE `owner` = '{$us['id']}' and `type` = '2' LIMIT 1;"));
if ($user['intel'] >= 1) {

View File

@ -28,7 +28,7 @@ if (($user->room > 2000) && ($user->room < 2100)) {echo "Не в Проходе.
$messch="Персонаж &quot;{$user['login']}&quot; $action путы на &quot;$target&quot;";
addch("<img src=i/magic/chains.gif> $messch");
addch("<img src=i/magic/chains.gif> $messch");
echo "<font color=red><b>Вы наложили путы на персонажа \"$target\"</b></font>";
$bet=1;
}

View File

@ -28,7 +28,7 @@ if (($user->room > 2000) && ($user->room < 2100)) {echo "Не в Проходе.
$messch="Персонаж &quot;{$user['login']}&quot; $action &quot;$target&quot;";
addch("<img src=i/magic/chains.gif> $messch");
addch("<img src=i/magic/chains.gif> $messch");
echo "<font color=red><b>Вы парализовали персонажа \"$target\"</b></font>";
$bet=1;
}

View File

@ -10,7 +10,7 @@ $book=866;$have_book=mysql_fetch_array(mysql_query("SELECT `id` FROM `inventory`
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;"));
$mag_def="`type` = '215'";
$md_arr=array("216","217","218","219","220","221","222","223","224","225","226");

View File

@ -10,7 +10,7 @@ $book=908;$have_book=mysql_fetch_array(mysql_query("SELECT `id` FROM `inventory`
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;"));
$mag_def="`type` = '215'";
$md_arr=array("216","217","218","219","220","221","222","223","224","225","226");

View File

@ -10,7 +10,7 @@ $book=909;$have_book=mysql_fetch_array(mysql_query("SELECT `id` FROM `inventory`
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;"));
$mag_def="`type` = '215'";
$md_arr=array("216","217","218","219","220","221","222","223","224","225","226");

View File

@ -17,7 +17,7 @@ if (empty($_SESSION['uid'])) {
exit;
}
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' LIMIT 1 ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' LIMIT 1 ;"));
$bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';"));
//mana needed
$t1 = explode(";",$bat['t1']);

View File

@ -15,7 +15,7 @@ if (empty($_SESSION['uid'])) {
}
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `real_time` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' LIMIT 1 ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' LIMIT 1 ;"));
$bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';"));
if(!$us) $bot= mysql_fetch_array(mysql_query ("SELECT * FROM `bots` WHERE `name` = '".$_POST['target']."' LIMIT 1;"));
//mana needed

View File

@ -15,7 +15,7 @@ if (empty($_SESSION['uid'])) {
}
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `real_time` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' LIMIT 1 ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' LIMIT 1 ;"));
$bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';"));
if(!$us) $bot= mysql_fetch_array(mysql_query ("SELECT * FROM `bots` WHERE `name` = '".$_POST['target']."' LIMIT 1;"));
//mana needed

View File

@ -15,7 +15,7 @@ if (empty($_SESSION['uid'])) {
}
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `real_time` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '{$_POST['target']}' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' LIMIT 1 ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' LIMIT 1 ;"));
$bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';"));
if(!$us) $bot= mysql_fetch_array(mysql_query ("SELECT * FROM `bots` WHERE `name` = '".$_POST['target']."' LIMIT 1;"));
//mana needed

View File

@ -11,7 +11,7 @@ $book=866;$have_book=mysql_fetch_array(mysql_query("SELECT `id` FROM `inventory`
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;"));
$bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';"));
$mag_def="`type` = '203'";
$md_arr=array("204","205","206","207","208","209","210","211","212","213","214");

View File

@ -12,7 +12,7 @@ $book=908;$have_book=mysql_fetch_array(mysql_query("SELECT `id` FROM `inventory`
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;"));
$bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';"));
$mag_def="`type` = '203'";
$md_arr=array("204","205","206","207","208","209","210","211","212","213","214");

View File

@ -12,7 +12,7 @@ $book=909;$have_book=mysql_fetch_array(mysql_query("SELECT `id` FROM `inventory`
$us = mysql_fetch_array(mysql_query("SELECT *,(select `id` from `online` WHERE `date` >= ".(time()-60)." AND `id` = users.`id`) as `online` FROM `users` WHERE `login` = '".mysql_real_escape_string($_POST['target'])."' LIMIT 1;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' ;"));
$bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';"));
$mag_def="`type` = '203'";
$md_arr=array("204","205","206","207","208","209","210","211","212","213","214");

View File

@ -16,7 +16,7 @@ if (empty($_SESSION['uid'])) {
exit;
}
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' LIMIT 1 ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' LIMIT 1 ;"));
$bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';"));
//mana needed
$t1 = explode(";",$bat['t1']);

View File

@ -16,7 +16,7 @@ if (empty($_SESSION['uid'])) {
exit;
}
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' LIMIT 1 ;"));
$magic = mysql_fetch_array(mysql_query("SELECT `chanse` FROM `magic` WHERE `id` = '{$mag_id}' LIMIT 1 ;"));
$bat=mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `id`='{$user['battle']}';"));
//mana needed
$t1 = explode(";",$bat['t1']);

Some files were not shown because too many files have changed in this diff Show More