From 7dd6368b845ee18fc1c6c2f6e5bedfbdc912cb10 Mon Sep 17 00:00:00 2001 From: "Igor Barkov (iwork)" Date: Mon, 1 Feb 2021 18:42:52 +0200 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D1=87=D0=B5=D0=BC-=D1=82=D0=BE=20?= =?UTF-8?q?=D0=B8=D0=BD=D0=BA=D0=B0=D0=BF=D1=81=D1=83=D0=BB=D1=8F=D1=86?= =?UTF-8?q?=D0=B8=D1=8F...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/admin.php | 7 +- akadem.php | 12 +- bank.php | 25 +- buy_klan.php | 2 +- canalizaciya.php | 12 +- ch.php | 2 +- clan.php | 34 +-- clan_create.php | 26 +- classes/Battles/Nick.php | 10 +- classes/Battles/User.php | 616 ++++++++++++++++++++++++++++++++++++++- comission.php | 26 +- functions.php | 24 +- main.php | 32 +- module_quest.php | 9 +- post.php | 16 +- presents.php | 23 +- quest_room.php | 7 +- repair.php | 30 +- shop.php | 8 +- user_abilities.php | 69 ++--- user_anketa.php | 17 +- vxod.php | 2 +- zayavka.php | 94 +++--- 23 files changed, 867 insertions(+), 236 deletions(-) diff --git a/admin/admin.php b/admin/admin.php index 6c6e1b0..84e2626 100644 --- a/admin/admin.php +++ b/admin/admin.php @@ -11,6 +11,7 @@ use Battles\Bank; use Battles\Database\DBPDO; use Battles\Moderation; use Battles\Nick; +use Battles\Template; use Battles\User; $user = $user ?? new User($_SESSION['uid']); @@ -20,11 +21,11 @@ if (!$user->admin) { } if (isset($_GET['sleep'])) { - Moderation::muteChat($user->id, strtotime('15min')); + Moderation::muteChat($user->getId(), strtotime('15min')); } if (isset($_POST['ldnick']) && isset($_POST['ldtext'])) { - Moderation::addToUserLog($_POST['ldnick'], $_POST['ldtext'], $user->id); + Moderation::addToUserLog($_POST['ldnick'], $_POST['ldtext'], $user->getId()); } if (isset($_POST['syschatmsg'])) { @@ -105,7 +106,7 @@ while ($i < count($row)) { unset($i); -\Battles\Template::header('ᐰdminка'); +Template::header('ᐰdminка'); ?> diff --git a/akadem.php b/akadem.php index de879be..90a224f 100644 --- a/akadem.php +++ b/akadem.php @@ -45,9 +45,9 @@ function setProfession($name, $type, $needMoney, $needLevel) $profId = 22; } if (!empty($profId)) { - $user->money -= $needMoney; - Bank::setWalletMoney($user->money, $user->id); - db::c()->query('UPDATE `users` SET ?f = ?i WHERE `id` = ?i', 'prof' . $type, $profId, $user->id); + $user->setMoney($user->getMoney() - $needMoney); + Bank::setWalletMoney($user->getMoney(), $user->getId()); + db::c()->query('UPDATE `users` SET ?f = ?i WHERE `id` = ?i', 'prof' . $type, $profId, $user->getId()); $deloText = "{$user['login']} купил профессию «{$name}» в академии за {$needMoney} кр."; GameLogs::addUserLog($_SESSION['uid'], $deloText); $user['prof' . $type] = true; @@ -69,7 +69,7 @@ if ($get == 'medic') { } 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); + db::c()->query('UPDATE `users`,`online` SET `users`.`room` = 2702, `online`.`room` = 2702 WHERE `users`.`id` = ?i AND `online`.`id` = ?i', $user->getId(), $user->getId()); header('Location: city.php'); } Template::header('Академия'); @@ -82,8 +82,8 @@ Template::header('Академия');
Информация - Кредитыmoney ?> - Уровень персонажаlevel ?> + КредитыgetMoney() ?> + Уровень персонажаgetLevel() ?>
Наёмник diff --git a/bank.php b/bank.php index ce0eda0..b68583a 100644 --- a/bank.php +++ b/bank.php @@ -1,11 +1,18 @@ id); +$bank = new Bank($user->getId()); $status = ''; $toid = $_POST['to_id'] ?? 0; @@ -15,37 +22,37 @@ try { // Зачисление кредитов на счёт. if ($submit === 'depositMoney' && $summa) { $operation = $bank->depositMoney($summa); - $user->money = $operation['walletMoney']; + $user->setMoney($operation['walletMoney']); $bank->setMoney($operation['bankMoney']); $status = SUCCESS; } // Снятие кредитов со счёта. if ($submit === 'withdrawMoney' && $summa) { $operation = $bank->withdrawMoney($summa); - $user->money = $operation['walletMoney']; + $user->setMoney($operation['walletMoney']); $bank->setMoney($operation['bankMoney']); $status = SUCCESS; } // Перевод кредитов на другой счёт. if ($submit === 'sendMoney' && $summa && $toid) { - $user->money = $bank->sendMoney($toid, $summa); + $user->setMoney($bank->sendMoney($toid, $summa)); $status = SUCCESS; } -} catch (\Exceptions\GameException $e) { +} catch (GameException $e) { echo 'Банковская ошибка!'; } finally { unset($submit, $summa, $toid); } -\Battles\Template::header('Банк'); +Template::header('Банк'); ?> - +
На счету: getMoney() ?>
- На руках: money ?> + На руках: getMoney() ?>
Работа со счётом diff --git a/buy_klan.php b/buy_klan.php index b33c4e0..5e57cd8 100644 --- a/buy_klan.php +++ b/buy_klan.php @@ -5,7 +5,7 @@ if (empty($_SESSION['uid'])) { } require_once "functions.php"; -if (empty($user->clan)) { +if (empty($user->getClan())) { exit; } $is_now = db::c()->query('SELECT `id` FROM `abils_klan` WHERE `klan` = ?i', $user['klan'])->fetch_assoc(); diff --git a/canalizaciya.php b/canalizaciya.php index 923c3f9..e27d828 100644 --- a/canalizaciya.php +++ b/canalizaciya.php @@ -1,7 +1,11 @@ room == 403) { include "startpodzemel.php"; if ($_GET['act'] == "cexit") { @@ -37,7 +41,7 @@ if ($user->room == 403) { 'Ключик №9', 'Ключик №10' ]; - db::c()->query('DELETE FROM inventory WHERE name IN ("?s") AND owner_id = ?i', implode(",", $items_to_delete), $user->id); + db::c()->query('DELETE FROM inventory WHERE name IN ("?s") AND owner_id = ?i', implode(",", $items_to_delete), $user->getId()); } } $e = mysql_query("DELETE FROM labirint WHERE user_id='" . $user['id'] . "'"); @@ -50,11 +54,11 @@ if ($user->room == 403) { { $frt = mysql_query("select user_id from `labirint` where glava='" . $glava . "'"); while ($rbb = mysql_fetch_array($frt)) { - addchp('' . $user->login . ' поднял предмет "' . $mis . '". ', '{[]}' . Nick::id($rbb["user_id"])->short() . '{[]}'); + addchp('' . $user->getLogin() . ' поднял предмет "' . $mis . '". ', '{[]}' . Nick::id($rbb["user_id"])->short() . '{[]}'); } } } -\Battles\Template::header('canalizaciya'); +Template::header('canalizaciya'); $ros = mysql_query("SELECT * FROM `labirint` WHERE `user_id`='{$_SESSION['uid']}'"); $mir = mysql_fetch_array($ros); diff --git a/ch.php b/ch.php index 7727bd9..8868786 100644 --- a/ch.php +++ b/ch.php @@ -414,7 +414,7 @@ if (isset($_GET['online']) && $_GET['online'] != null) { $_GET['text'] = preg_replace('/private \[klan-([a-zA-Z]*)\]/', '', $_GET['text']); - if (empty($user->clan)) { + if (empty($user->getClan())) { $_GET['text'] = str_replace('private [klan]', '', $_GET['text']); $_GET['text'] = str_replace('private [klan]', 'private [klan-' . $user['klan'] . ']', $_GET['text']); } else { diff --git a/clan.php b/clan.php index 3d53393..d466c2c 100644 --- a/clan.php +++ b/clan.php @@ -13,11 +13,11 @@ require_once 'functions.php'; $user = $user ?? new User($_SESSION['uid']); $db = new DBPDO(); $clanRow = []; -if (!$user->clan) { +if (!$user->getClan()) { exit(err('Вы не состоите в клане!')); } try { - $clanRow = $db->fetch('SELECT * FROM `clans` WHERE short_name = ?', $user->clan); + $clanRow = $db->fetch('SELECT * FROM `clans` WHERE short_name = ?', $user->getClan()); } catch (Exception $e) { echo "
MYSQL_ERROR: Таблица clans сломана!
"; } @@ -37,14 +37,14 @@ $tus = $_POST['tus'] ?? null; $lock = true; // блокировка функций if ($zamok && !$lock) { - $db->execute('UPDATE `clans` SET `zamok` = 1 WHERE `glava` = ?', $user->id); + $db->execute('UPDATE `clans` SET `zamok` = 1 WHERE `glava` = ?', $user->getId()); $status = "Начат сбор средств на строительство Кланового Замка."; header("Location: clan.php"); } if ($kr && $kolv > 0 && !$lock) { - if ($user->money >= $kolv) { - $db->execute('UPDATE clans SET zbor = zbor + ? WHERE id = ?', [$kolv, $user->clan]); - Bank::setWalletMoney($user->money -= $kolv, $user->id); + if ($user->getMoney() >= $kolv) { + $db->execute('UPDATE clans SET zbor = zbor + ? WHERE id = ?', [$kolv, $user->getClan()]); + Bank::setWalletMoney($user->setMoney($user->getMoney() - $kolv), $user->getId()); header("Location: clan.php"); } else { $status = 'Не хватает денег!'; @@ -57,8 +57,8 @@ if ($login && $action == 'add_member') { echo "Нет проверки!"; } elseif ($sok['clan']) { echo 'Персонаж уже состоит в клане!'; - } elseif ($sok['level'] > 0 && $user->money >= COST_ADD_MEMBER) { - Bank::setWalletMoney($user->money - COST_ADD_MEMBER, $user->id); + } elseif ($sok['level'] > 0 && $user->getMoney() >= COST_ADD_MEMBER) { + Bank::setWalletMoney($user->setMoney($user->getMoney() - COST_ADD_MEMBER), $user->getId()); $db->execute('UPDATE users SET clan = ?, align = ? WHERE id = ?', [$clanRow['id'], $clanRow['align'], $sok['id']]); $status = "Персонаж «{$login}» успешно принят в клан."; } else { @@ -68,12 +68,12 @@ if ($login && $action == 'add_member') { if ($login) { $sok = $db->fetch('SELECT id FROM users WHERE clan = ? AND login = ?', [$clanRow['id'], $login]); - if ($action == 'remove_member' && $sok['id'] != $clanRow['owner_id'] && $user->money >= COST_REMOVE_MEMBER) { - Bank::setWalletMoney($user->money - COST_REMOVE_MEMBER, $user->id); + if ($action == 'remove_member' && $sok['id'] != $clanRow['owner_id'] && $user->getMoney() >= COST_REMOVE_MEMBER) { + Bank::setWalletMoney($user->setMoney($user->getMoney() - COST_REMOVE_MEMBER), $user->getId()); $db->execute('UPDATE users SET clan = null, align = 0 WHERE id = ?', $sok['id']); $status = "Персонаж «{$login}» покинул клан."; } - if ($action == 'change_owner' && $clanRow['owner_id'] == $user->id) { + if ($action == 'change_owner' && $clanRow['owner_id'] == $user->getId()) { $db->execute('UPDATE clans SET owner_id = ? WHERE id = ?', [$sok['id'], $clanRow['id']]); $clanRow['owner_id'] = $sok['id']; } @@ -108,7 +108,7 @@ $clanRow['zbor'] = null; // И копилки.

- id): ?> + getId()): ?>
@@ -123,18 +123,18 @@ $clanRow['zbor'] = null; // И копилки.
- id): ?> + getId()): ?>
- id): ?> - id): ?> + getId()): ?> + getId()): ?>
Может принимать/выгонять членов клана
Может принимать/выгонять членов клана - id): ?> + getId()): ?>
Может менять статус членов клана
Может менять статус членов клана @@ -152,7 +152,7 @@ $clanRow['zbor'] = null; // И копилки. - id): ?> + getId()): ?>
diff --git a/clan_create.php b/clan_create.php index 803a72b..794819b 100644 --- a/clan_create.php +++ b/clan_create.php @@ -1,24 +1,30 @@ query('SELECT short_name, full_name, info FROM clans where owner_id = ?i', $user->id)->fetch_object(); +$user = $user ?? new User($_SESSION['uid']); +$userClan = db::c()->query('SELECT short_name, full_name, info FROM clans where owner_id = ?i', $user->getId())->fetch_object(); $clanFullName = $_POST['clan_full_name'] ?? ''; $clanShortName = $_POST['clan_short_name'] ?? ''; $clanInfo = $_POST['clan_info'] ?? ''; -$userBank = new \Battles\Bank($user->id); +$userBank = new Bank($user->getId()); if ($clanFullName && $clanShortName && $clanInfo && !$userClan) { - $eff = db::c()->query('SELECT 1 FROM users_effects WHERE type = 20 AND owner_id = ?i', $user->id); + $eff = db::c()->query('SELECT 1 FROM users_effects WHERE type = 20 AND owner_id = ?i', $user->getId()); $name_check = db::c()->query('SELECT owner_id FROM clans WHERE full_name = "?s" OR short_name = "?s"', $clanFullName, $clanShortName); $errorMessage = []; if (Config::$clan_register_lock) { $errorMessage[10] = 'Регистрация кланов закрыта!
'; } - if ($user->align) { + if ($user->getAlign()) { $errorMessage[0] = 'Вы уже имеете направленность!.
'; } - if ($user->clan) { + if ($user->getClan()) { $errorMessage[1] = 'Вы уже состоите в клане!.
'; } if (Config::$clan_register_cost >= $userBank->getMoney()) { @@ -32,9 +38,9 @@ if ($clanFullName && $clanShortName && $clanInfo && !$userClan) { } if (!$errorMessage || $user->admin) { try { - db::c()->query('INSERT INTO clans (owner_id, full_name, short_name, info) VALUES (?i,"?s","?s","?s")', $user->id, $clanFullName, $clanShortName, $clanInfo); + db::c()->query('INSERT INTO clans (owner_id, full_name, short_name, info) VALUES (?i,"?s","?s","?s")', $user->getId(), $clanFullName, $clanShortName, $clanInfo); $userBank->setMoney($userBank->getMoney() - Config::$clan_register_cost); - Battles\Bank::setBankMoney($userBank->getMoney(), $user->id, 'clanRegister'); + Battles\Bank::setBankMoney($userBank->getMoney(), $user->getId(), 'clanRegister'); // Заглушка для отображения данных по только что зарегистрированному клану, когда запрос в базу в начале файла ещё не проходит. $userClan = new stdClass(); $userClan->full_name = $clanFullName; @@ -51,8 +57,8 @@ if ($clanFullName && $clanShortName && $clanInfo && !$userClan) { } } } -\Battles\Template::header(\Battles\Rooms::$roomNames[30]); -\Battles\Template::buildingTop(\Battles\Rooms::$roomNames[30], 'strah'); +Template::header(Rooms::$roomNames[30]); +Template::buildingTop(Rooms::$roomNames[30], 'strah'); if ($userClan): ?>
diff --git a/classes/Battles/Nick.php b/classes/Battles/Nick.php index a987dc8..229afdc 100644 --- a/classes/Battles/Nick.php +++ b/classes/Battles/Nick.php @@ -15,9 +15,9 @@ class Nick extends User * Отображение иконки склонности. * @return string */ - private function getAlign():?string + private function getAlignToNickname():?string { - if (isset($this->align)) { + if ($this->align) { return sprintf('', $this->align); } else { return null; @@ -28,9 +28,9 @@ class Nick extends User * Отображение иконки клана. * @return string */ - private function getClan():?string + private function getClanToNickname():?string { - if (isset($this->clan)) { + if ($this->clan) { return sprintf('', $this->clan); } else { return null; @@ -60,7 +60,7 @@ class Nick extends User if ($showInvisibility && $this->getInvisibilityStatus()) { return INVIS; } - return $this->getAlign().$this->getClan().sprintf('%s [%s] ', $this->login, $this->level, $this->login); + return $this->getAlignToNickname().$this->getClanToNickname().sprintf('%s [%s] ', $this->login, $this->level, $this->login); } /** diff --git a/classes/Battles/User.php b/classes/Battles/User.php index 79143eb..8ccde5d 100644 --- a/classes/Battles/User.php +++ b/classes/Battles/User.php @@ -7,17 +7,17 @@ use Exceptions\GameException; class User { - public $id = 0; - public $login = 'Некто'; - public $pass; - public $email = 'неизвестно'; - public $realname; - public $borndate; - public $info; - public $level = 0; - public $align = 0; - public $clan = 0; - public $money = 0; + protected $id = 0; + protected $login = 'Некто'; + protected $pass; + protected $email = 'неизвестно'; + protected $realname; + protected $borndate; + protected $info; + protected $level = 0; + protected $align = 0; + protected $clan = 0; + protected $money = 0; public $strength = 0; public $dexterity = 0; public $intuition = 0; @@ -176,4 +176,598 @@ class User } return false; } + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @param int $id + */ + public function setId(int $id): void + { + $this->id = $id; + } + + /** + * @return string + */ + public function getLogin(): string + { + return $this->login; + } + + /** + * @param string $login + */ + public function setLogin(string $login): void + { + $this->login = $login; + } + + /** + * @return mixed + */ + public function getPass() + { + return $this->pass; + } + + /** + * @param mixed $pass + */ + public function setPass($pass): void + { + $this->pass = $pass; + } + + /** + * @return string + */ + public function getEmail(): string + { + return $this->email; + } + + /** + * @param string $email + */ + public function setEmail(string $email): void + { + $this->email = $email; + } + + /** + * @return mixed + */ + public function getRealname() + { + return $this->realname; + } + + /** + * @param mixed $realname + */ + public function setRealname($realname): void + { + $this->realname = $realname; + } + + /** + * @return mixed + */ + public function getBorndate() + { + return $this->borndate; + } + + /** + * @param mixed $borndate + */ + public function setBorndate($borndate): void + { + $this->borndate = $borndate; + } + + /** + * @return mixed + */ + public function getInfo() + { + return $this->info; + } + + /** + * @param mixed $info + */ + public function setInfo($info): void + { + $this->info = $info; + } + + /** + * @return int + */ + public function getLevel(): int + { + return $this->level; + } + + /** + * @param int $level + */ + public function setLevel(int $level): void + { + $this->level = $level; + } + + /** + * @return int + */ + public function getAlign(): int + { + return $this->align; + } + + /** + * @param int $align + */ + public function setAlign(int $align): void + { + $this->align = $align; + } + + /** + * @return int + */ + public function getClan(): int + { + return $this->clan; + } + + /** + * @param int $clan + */ + public function setClan(int $clan): void + { + $this->clan = $clan; + } + + /** + * @return int + */ + public function getMoney(): int + { + return $this->money; + } + + /** + * @param int $money + */ + public function setMoney(int $money): void + { + $this->money = $money; + } + + /** + * @return int + */ + public function getStrength(): int + { + return $this->strength; + } + + /** + * @param int $strength + */ + public function setStrength(int $strength): void + { + $this->strength = $strength; + } + + /** + * @return int + */ + public function getDexterity(): int + { + return $this->dexterity; + } + + /** + * @param int $dexterity + */ + public function setDexterity(int $dexterity): void + { + $this->dexterity = $dexterity; + } + + /** + * @return int + */ + public function getIntuition(): int + { + return $this->intuition; + } + + /** + * @param int $intuition + */ + public function setIntuition(int $intuition): void + { + $this->intuition = $intuition; + } + + /** + * @return int + */ + public function getEndurance(): int + { + return $this->endurance; + } + + /** + * @param int $endurance + */ + public function setEndurance(int $endurance): void + { + $this->endurance = $endurance; + } + + /** + * @return int + */ + public function getIntelligence(): int + { + return $this->intelligence; + } + + /** + * @param int $intelligence + */ + public function setIntelligence(int $intelligence): void + { + $this->intelligence = $intelligence; + } + + /** + * @return int + */ + public function getWisdom(): int + { + return $this->wisdom; + } + + /** + * @param int $wisdom + */ + public function setWisdom(int $wisdom): void + { + $this->wisdom = $wisdom; + } + + /** + * @return mixed + */ + public function getIp() + { + return $this->ip; + } + + /** + * @param mixed $ip + */ + public function setIp($ip): void + { + $this->ip = $ip; + } + + /** + * @return mixed + */ + public function getSessionId() + { + return $this->session_id; + } + + /** + * @param mixed $session_id + */ + public function setSessionId($session_id): void + { + $this->session_id = $session_id; + } + + /** + * @return int + */ + public function getAdmin(): int + { + return $this->admin; + } + + /** + * @param int $admin + */ + public function setAdmin(int $admin): void + { + $this->admin = $admin; + } + + /** + * @return mixed + */ + public function getEnterGame() + { + return $this->enter_game; + } + + /** + * @param mixed $enter_game + */ + public function setEnterGame($enter_game): void + { + $this->enter_game = $enter_game; + } + + /** + * @return mixed + */ + public function getRoom() + { + return $this->room; + } + + /** + * @param mixed $room + */ + public function setRoom($room): void + { + $this->room = $room; + } + + /** + * @return mixed + */ + public function getBlock() + { + return $this->block; + } + + /** + * @param mixed $block + */ + public function setBlock($block): void + { + $this->block = $block; + } + + /** + * @return mixed + */ + public function getShadow() + { + return $this->shadow; + } + + /** + * @param mixed $shadow + */ + public function setShadow($shadow): void + { + $this->shadow = $shadow; + } + + /** + * @return int + */ + public function getMinDamage(): int + { + return $this->minDamage; + } + + /** + * @param int $minDamage + */ + public function setMinDamage(int $minDamage): void + { + $this->minDamage = $minDamage; + } + + /** + * @return int + */ + public function getMaxDamage(): int + { + return $this->maxDamage; + } + + /** + * @param int $maxDamage + */ + public function setMaxDamage(int $maxDamage): void + { + $this->maxDamage = $maxDamage; + } + + /** + * @return int + */ + public function getHeadArmor(): int + { + return $this->headArmor; + } + + /** + * @param int $headArmor + */ + public function setHeadArmor(int $headArmor): void + { + $this->headArmor = $headArmor; + } + + /** + * @return int + */ + public function getChestArmor(): int + { + return $this->chestArmor; + } + + /** + * @param int $chestArmor + */ + public function setChestArmor(int $chestArmor): void + { + $this->chestArmor = $chestArmor; + } + + /** + * @return int + */ + public function getLegArmor(): int + { + return $this->legArmor; + } + + /** + * @param int $legArmor + */ + public function setLegArmor(int $legArmor): void + { + $this->legArmor = $legArmor; + } + + /** + * @return int + */ + public function getFreeStatPoints(): int + { + return $this->free_stat_points; + } + + /** + * @param int $free_stat_points + */ + public function setFreeStatPoints(int $free_stat_points): void + { + $this->free_stat_points = $free_stat_points; + } + + /** + * @return string + */ + public function getMarried(): string + { + return $this->married; + } + + /** + * @param string $married + */ + public function setMarried(string $married): void + { + $this->married = $married; + } + + /** + * @return int + */ + public function getExperience(): int + { + return $this->experience; + } + + /** + * @param int $experience + */ + public function setExperience(int $experience): void + { + $this->experience = $experience; + } + + /** + * @return int + */ + public function getBattle(): int + { + return $this->battle; + } + + /** + * @param int $battle + */ + public function setBattle(int $battle): void + { + $this->battle = $battle; + } + + /** + * @return int + */ + public function getInTower(): int + { + return $this->in_tower; + } + + /** + * @param int $in_tower + */ + public function setInTower(int $in_tower): void + { + $this->in_tower = $in_tower; + } + + /** + * @return int + */ + public function getZayavka(): int + { + return $this->zayavka; + } + + /** + * @param int $zayavka + */ + public function setZayavka(int $zayavka): void + { + $this->zayavka = $zayavka; + } + + /** + * @return float|int + */ + public function getMaxHealth() + { + return $this->maxHealth; + } + + /** + * @param float|int $maxHealth + */ + public function setMaxHealth($maxHealth): void + { + $this->maxHealth = $maxHealth; + } + + /** + * @return float|int + */ + public function getMaxMana() + { + return $this->maxMana; + } + + /** + * @param float|int $maxMana + */ + public function setMaxMana($maxMana): void + { + $this->maxMana = $maxMana; + } + + } \ No newline at end of file diff --git a/comission.php b/comission.php index 8699c5e..7eb647f 100644 --- a/comission.php +++ b/comission.php @@ -20,11 +20,11 @@ if ($putItemId) { $putItemCost = $dress['cost']; } $commission = ceil($putItemCost / 10); # 10% от суммы с округлением вверх. - if ($user->money > $commission) { + if ($user->getMoney() > $commission) { if (db::c()->getAffectedRows()) { - $deloText = "{$user->login} выставил товар: «{$dress['name']}» id:({$putItemId}) [{$dress['duration']}/{$dress['maxdur']}] на продажу в комиссионку за {$putItemCost} кр. "; - GameLogs::addUserLog($user->id, $deloText); + $deloText = "{$user->getLogin()} выставил товар: «{$dress['name']}» id:({$putItemId}) [{$dress['duration']}/{$dress['maxdur']}] на продажу в комиссионку за {$putItemCost} кр. "; + GameLogs::addUserLog($user->getId(), $deloText); db::c()->query('UPDATE `inventory` SET `setsale` = ?i WHERE `id` = ?i', $putItemCost, $putItemId); db::c()->query('UPDATE `users` SET `money` = `money` - ?i WHERE `id` = ?i', $commission, $_SESSION['uid']); $status = "Вы сдали в магазин «{$dress['name']}» за {$putItemCost} кр. Вычтено за услуги магазина: {$commission} кр."; @@ -32,15 +32,15 @@ if ($putItemId) { $status = "Предмет не найден в инвентаре!"; } } else { - $status = "У вас не хватает " . $commission - $user->money . " кр. чтобы оплатить комиссию!"; + $status = "У вас не хватает " . $commission - $user->getMoney() . " кр. чтобы оплатить комиссию!"; } } if ($returningItemId) { $dress = db::c()->query('SELECT `name`,`duration`,`maxdur` FROM `inventory` WHERE `dressed` = 0 AND `setsale` > 0 AND `id` = ?i AND `owner` = ?i', $returningItemId, $_SESSION['uid'])->fetch_assoc(); if (db::c()->getAffectedRows()) { - $deloText = "{$user->login} забрал свой товар: «{$dress['name']}» id:({$returningItemId}) [{$dress['duration']}/{$dress['maxdur']}] из комиссионки."; - GameLogs::addUserLog($user->id, $deloText); + $deloText = "{$user->getLogin()} забрал свой товар: «{$dress['name']}» id:({$returningItemId}) [{$dress['duration']}/{$dress['maxdur']}] из комиссионки."; + GameLogs::addUserLog($user->getId(), $deloText); db::c()->query('UPDATE `inventory` SET `setsale` = 0 WHERE `id` = ?i', $returningItemId); $status = "Вы забрали из магазина ваш «{$dress['name']}»."; } else { @@ -53,16 +53,16 @@ if ($byingItemId) { $seller = db::c()->query('SELECT `login` FROM `users` WHERE `id` =?i', $dress['owner'])->fetch_assoc(); if ($dress['setsale']) { - if ($user->money >= $dress['setsale']) { - db::c()->query('UPDATE `inventory` SET `setsale` = 0, `owner` = ?i WHERE `id` = ?i', $user->id, $byingItemId); - db::c()->query('UPDATE `users` set `money` = `money` - ?i WHERE `id` = ?i', $dress['setsale'], $user->id); + if ($user->getMoney() >= $dress['setsale']) { + db::c()->query('UPDATE `inventory` SET `setsale` = 0, `owner` = ?i WHERE `id` = ?i', $user->getId(), $byingItemId); + db::c()->query('UPDATE `users` set `money` = `money` - ?i WHERE `id` = ?i', $dress['setsale'], $user->getId()); db::c()->query('UPDATE `users` set `money` = `money` + ?i WHERE `id` = ?i', $dress['setsale'], $dress['owner']); $status = "Вы купили «{$dress['name']}» за {$dress['setsale']} кр."; - $deloText = "{$user->login} купил на рынке товар: «{$dress['name']}» id:({$byingItemId}) [{$dress['duration']}/{$dress['maxdur']}] у {$seller['login']} за {$dress['setsale']} кр."; - GameLogs::addUserLog($user->id, $deloText); - $deloText = "{$seller['login']} продал на рынке товар: «{$dress['name']}» id:({$byingItemId}) [{$dress['duration']}/{$dress['maxdur']}] персонажу {$user->login} за {$dress['setsale']} кр."; + $deloText = "{$user->getLogin()} купил на рынке товар: «{$dress['name']}» id:({$byingItemId}) [{$dress['duration']}/{$dress['maxdur']}] у {$seller['login']} за {$dress['setsale']} кр."; + GameLogs::addUserLog($user->getId(), $deloText); + $deloText = "{$seller['login']} продал на рынке товар: «{$dress['name']}» id:({$byingItemId}) [{$dress['duration']}/{$dress['maxdur']}] персонажу {$user->getLogin()} за {$dress['setsale']} кр."; GameLogs::addUserLog($dress['owner'], $deloText); - $user->money -= $dress['setsale']; + $user->setMoney($user->getMoney() - $dress['setsale']); telegraph($dress['owner'], "Предмет «{$dress['name']}» продан на рынке за {$dress['setsale']} кр."); } else { $status = "Недостаточно средств!"; diff --git a/functions.php b/functions.php index 6690569..5e61270 100644 --- a/functions.php +++ b/functions.php @@ -17,7 +17,7 @@ if (empty($_SESSION['uid'])) { $user = new User($_SESSION['uid']); } -if ($user->id && $user->block) { +if ($user->getId() && $user->block) { exit('user blocked!'); } @@ -140,7 +140,7 @@ function takeshopitem($item, $table = "shop", $present = '', $onlyonetrip = '', $flds = []; $goden = ''; if (!$uid) { - $uid = $user->id; + $uid = $user->getId(); } $r = db::c()->query('SHOW FIELDS FROM ?f', $table); @@ -300,7 +300,7 @@ function echoscroll($slot) $dress = db::c()->query('SELECT `id`, `magic`, `name`, `img`, `duration`, `maxdur` FROM `inventory` WHERE `id` = ?i', $user->$slot)->fetch_assoc(); $need_charge = db::c()->query('SELECT `needcharge` FROM `magic` WHERE `id` = ?i', $dress['magic'])->fetch_assoc(); - if (($user->$slot > 0) && ($all_magic[$user->id] < 1 || empty($need_charge['needcharge']))) { + if (($user->$slot > 0) && ($all_magic[$user->getId()] < 1 || empty($need_charge['needcharge']))) { $row['id'] = $user->$slot; if ($dress['magic']) { $magic = db::c()->query('SELECT targeted FROM `magic` WHERE `id` = ?i', $dress['magic'])->fetch_assoc(); @@ -318,7 +318,7 @@ function echoscroll($slot) echo << ACTIVE_SCROLL; - } elseif (($user->$slot > 0) && ($all_magic[$user->id] >= 1) && $need_charge['needcharge'] > 0) { + } elseif (($user->$slot > 0) && ($all_magic[$user->getId()] >= 1) && $need_charge['needcharge'] > 0) { echo << INACTIVE_SCROLL; @@ -650,11 +650,11 @@ function dropitem($slot) `u`.`fauvorot` = `u`.`fauvorot` - `i`.`mfauvorot`, `u`.`uminu` = `u`.`uminu` - `i`.`minu`, `u`.`umaxu` = `u`.`umaxu` - `i`.`maxu` - WHERE `i`.`id` = `u`.?f AND `i`.`dressed` = 1 AND `i`.`owner` = ?i AND u.id = ?i', $slot1, $slot1, $user->id, $user->id)) { - db::c()->query('UPDATE `users` SET `hp` = `maxhp`, `fullhptime` = ?i WHERE `hp` > `maxhp` AND `id` = ?i', time(), $user->id); + WHERE `i`.`id` = `u`.?f AND `i`.`dressed` = 1 AND `i`.`owner` = ?i AND u.id = ?i', $slot1, $slot1, $user->getId(), $user->getId())) { + db::c()->query('UPDATE `users` SET `hp` = `maxhp`, `fullhptime` = ?i WHERE `hp` > `maxhp` AND `id` = ?i', time(), $user->getId()); } - $wear_raw = db::c()->query('SELECT * FROM `inventory` where `owner` = ?i AND `dressed` = 1', $user->id); + $wear_raw = db::c()->query('SELECT * FROM `inventory` where `owner` = ?i AND `dressed` = 1', $user->getId()); while ($wear_list = $wear_raw->fetch_assoc()) { $wear_arr[] = $wear_list['prototype']; } @@ -714,7 +714,7 @@ function dropitem($slot) `u`.`mlight = `u`.`mlight - `s`.`glight`, `u`.`mgray = `u`.`mgray - `s`.`ggray` WHERE - `u`.`id` = ?i AND `s`.`set_id`= ?i', $user->id, $set_id); + `u`.`id` = ?i AND `s`.`set_id`= ?i', $user->getId(), $set_id); } } return true; @@ -781,7 +781,7 @@ function ref_drop() function destructitem($id) { global $user; - $item = db::c()->query('SELECT 1 FROM inventory WHERE owner_id = ?i AND item_id = ?i', $user->id, $id); + $item = db::c()->query('SELECT 1 FROM inventory WHERE owner_id = ?i AND item_id = ?i', $user->getId(), $id); if ($item->getNumRows()) { db::c()->query('DELETE FROM `inventory` WHERE `id` = ?i', $id); } @@ -791,7 +791,7 @@ function destructitem($id) function usemagic($id, $target) { global $user; - $row = db::c()->query('SELECT * FROM `inventory` WHERE `owner` = ?i AND id = ?i', $user->id, $id)->fetch_assoc_array(); + $row = db::c()->query('SELECT * FROM `inventory` WHERE `owner` = ?i AND id = ?i', $user->getId(), $id)->fetch_assoc_array(); $bat = db::c()->query('SELECT * FROM `battle` WHERE `id` = ?i', $user->battle)->fetch_assoc_array(); $all_magic = unserialize($bat['magic']); $charge = 0; @@ -806,7 +806,7 @@ function usemagic($id, $target) $charge = $incmagic['needcharge']; } //Переделать под новую базу - if (($all_magic[$user->id] < 1 || $charge == 0) && + if (($all_magic[$user->getId()] < 1 || $charge == 0) && ($user['sila'] >= $row['nsila'] && $user['lovk'] >= $row['nlovk'] && $user['inta'] >= $row['ninta'] && @@ -867,7 +867,7 @@ function usemagic($id, $target) } else { $all_magic = unserialize($bat['magic']); } - $all_magic[$user->id] += $charge; + $all_magic[$user->getId()] += $charge; db::c()->query('UPDATE `battle` SET `magic`= "?s" WHERE id = ?i', serialize($all_magic), $user->battle); } } diff --git a/main.php b/main.php index d387346..93c125e 100644 --- a/main.php +++ b/main.php @@ -17,7 +17,7 @@ if ($get == 'exit') { require_once 'functions.php'; try { - db::c()->query('UPDATE `online` SET `real_time` = ?i WHERE `user_id` = ?i', time(), $user->id); + db::c()->query('UPDATE `online` SET `real_time` = ?i WHERE `user_id` = ?i', time(), $user->getId()); } catch (\Krugozor\Database\Mysql\Exception $e) { echo "
Ошибка: " . $e->getMessage() . "
Стек: " . $e->getTraceAsString() . "
"; } @@ -34,7 +34,7 @@ $ids = $_GET['ids'] ?? null; $setShadow = $_POST['setshadow'] ?? null; $edit = $_GET['edit'] ?? null; // Подготавливаем отображение инфы и предметов. -$userInfo = new UserInfo($user->id); +$userInfo = new UserInfo($user->getId()); $getItemsBonuses = new 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']); @@ -170,8 +170,8 @@ function dressitem($id) // Входим и выходим если можем. if ($goto) { $imove = true; - $d = db::c()->query('SELECT SUM(weight) AS sum_weight FROM inventory WHERE owner_id = ?i AND on_sale = 0', $user->id)->fetch_assoc(); - $eff = db::c()->query('SELECT 1 FROM `users_effects` WHERE `owner_id` = ?i AND (`type` = 14 OR `type` = 13)', $user->id); + $d = db::c()->query('SELECT SUM(weight) AS sum_weight FROM inventory WHERE owner_id = ?i AND on_sale = 0', $user->getId())->fetch_assoc(); + $eff = db::c()->query('SELECT 1 FROM `users_effects` WHERE `owner_id` = ?i AND (`type` = 14 OR `type` = 13)', $user->getId()); //(масса: getItemsWeight() . '/' . $user->strength * 4 if ($d['sum_weight'] > $user->strength * 4 && $goto) { @@ -210,7 +210,7 @@ function setShadow($image) ]; if (in_array($image, $shadows)) { $i = $image . '.png'; - db::c()->query('UPDATE `users` SET `shadow` = "?s" WHERE `id` = ?i', $i, $user->id); + db::c()->query('UPDATE `users` SET `shadow` = "?s" WHERE `id` = ?i', $i, $user->getId()); } else { err('Ошибка!'); } @@ -221,7 +221,7 @@ if ($obraz && ($user->shadow == 'g0.gif' || $user->shadow == 'man0.gif')) { } if ($del == 1 && $effectId > 0) { - $pl = db::c()->query('SELECT type FROM users_effects WHERE owner_id = ?i AND effect_id = ?i', $user->id, $effectId)->fetch_assoc(); + $pl = db::c()->query('SELECT type FROM users_effects WHERE owner_id = ?i AND effect_id = ?i', $user->getId(), $effectId)->fetch_assoc(); if (isset($pl['type'])) { echo del_efs($effectId, $pl['type']); } else { @@ -231,26 +231,26 @@ if ($del == 1 && $effectId > 0) { if ($brons && $ids) { try { - $cur = db::c()->query('SELECT free_bron, bron1, bron2, bron3, bron4 FROM inventory WHERE owner = ?i AND id = ?i', $user->id, $ids)->fetch_assoc(); + $cur = db::c()->query('SELECT free_bron, bron1, bron2, bron3, bron4 FROM inventory WHERE owner = ?i AND id = ?i', $user->getId(), $ids)->fetch_assoc(); } catch (\Krugozor\Database\Mysql\Exception $e) { echo "
Ошибка: " . $e->getMessage() . "
В файле: " . $e->getFile() . " (" . $e->getLine() . ")
"; } if ($cur['free_bron'] > 0 && $cur[$brons] > 0) { - db::c()->query('UPDATE inventory SET free_bron = free_bron - 1, ?f = ?f +1 WHERE owner_id = ?i AND item_id = ?i', $brons, $brons, $user->id, $ids); + db::c()->query('UPDATE inventory SET free_bron = free_bron - 1, ?f = ?f +1 WHERE owner_id = ?i AND item_id = ?i', $brons, $brons, $user->getId(), $ids); echo "Параметр брони увеличен!"; } } if ($stats && $ids) { - $cur = db::c()->query('SELECT free_stat, gsila, glovk, ginta, gintel FROM inventory WHERE owner_id = ?i AND item_id = ?i', $user->id, $ids); + $cur = db::c()->query('SELECT free_stat, gsila, glovk, ginta, gintel FROM inventory WHERE owner_id = ?i AND item_id = ?i', $user->getId(), $ids); if ($cur['free_stat'] > 0 && $cur[$stats] > 0) { - db::c()->query('UPDATE inventory SET free_stat = free_stat - 1, ?f = ?f +1 WHERE owner_id = ?i AND item_id = ?i', $stats, $stats, $user->id, $ids); + db::c()->query('UPDATE inventory SET free_stat = free_stat - 1, ?f = ?f +1 WHERE owner_id = ?i AND item_id = ?i', $stats, $stats, $user->getId(), $ids); echo "Параметр увеличен!"; } } if ($mfs && $ids) { - $cur = db::c()->query('SELECT free_mf, mfkrit, mfuvorot, mfakrit, mfauvorot FROM inventory WHERE owner_id = ?i AND item_id = ?i', $user->id, $ids); + $cur = db::c()->query('SELECT free_mf, mfkrit, mfuvorot, mfakrit, mfauvorot FROM inventory WHERE owner_id = ?i AND item_id = ?i', $user->getId(), $ids); if (isset($cur['id']) && $cur['free_mf'] > 0 && $cur[$mfs] > 0) { - db::c()->query('UPDATE inventory SET free_mf = free_mf - 1, ?f = ?f +1 WHERE owner_id = ?i AND item_id = ?i', $mfs, $mfs, $user->id, $ids); + db::c()->query('UPDATE inventory SET free_mf = free_mf - 1, ?f = ?f +1 WHERE owner_id = ?i AND item_id = ?i', $mfs, $mfs, $user->getId(), $ids); echo "Параметр увеличен!"; } } @@ -319,7 +319,7 @@ if ($edit) { $q = $q->fetch_assoc(); if (empty($q['dressed'])) { destructitem($q['id']); - GameLogs::addUserLog($user->id, $user->login . " выбросил предмет " . $q['name'] . " id:(cap" . $q['id'] . ")"); + GameLogs::addUserLog($user->getId(), $user->getLogin() . " выбросил предмет " . $q['name'] . " id:(cap" . $q['id'] . ")"); err('Предмет ' . $q['name'] . ' выброшен.'); } else { err('Ошибка: нельзя выбросить одетый предмет!'); @@ -371,19 +371,19 @@ Template::header('Игра');
Снять все
- id) ?> + getId()) ?>

-
Уровень: level ?> +
Уровень: getLevel() ?>
Опыт: experience ?>
Побед: ??
Поражений: ??
Ничьих: ?? -
Деньги: money ?> кр. +
Деньги: getMoney() ?> кр.
diff --git a/module_quest.php b/module_quest.php index a28a080..40c246b 100644 --- a/module_quest.php +++ b/module_quest.php @@ -1,4 +1,7 @@ query('SELECT `vars` FROM `actions` WHERE `vars` LIKE "?S" AND `vals` = "?s" AND `uid` = ?i LIMIT 100', "%start_quest%", "go", $user->id); +$sp = db::c()->query('SELECT `vars` FROM `actions` WHERE `vars` LIKE "?S" AND `vals` = "?s" AND `uid` = ?i LIMIT 100', "%start_quest%", "go", $user->getId()); while ($pl = $sp->fetch_assoc()) { $questId = str_replace('start_quest', '', $pl['vars']); $pq = db::c()->query('SELECT `id`,`name`,`info` FROM `quests` WHERE `id` = ?i', $questId)->fetch_assoc(); - $qsee .= sprintf(' %sВыполнить
%s
$s

', $pq['id'], $pq['name'], $pq['id'], $pq['info'], $q->info($pq, $user->id)); + $qsee .= sprintf(' %sВыполнить
%s
$s

', $pq['id'], $pq['name'], $pq['id'], $pq['info'], $q->info($pq, $user->getId())); $qx++; } diff --git a/post.php b/post.php index db76b1d..579b960 100644 --- a/post.php +++ b/post.php @@ -29,11 +29,11 @@ if ($_SESSION['receiverName']) { $sendItemId = $_POST['item_id'] ?? 0; $telegraphText = $_POST['message'] ?? 0; - if ($submit == 'sendMessage' && $telegraphText && $user->money) { + if ($submit == 'sendMessage' && $telegraphText && $user->getMoney()) { if ($telegraphText) { - $user->money -= 1; - Bank::setWalletMoney($user->money, $user->id); + $user->setMoney($user->getMoney() - 1); + Bank::setWalletMoney($user->getMoney(), $user->getId()); db::c()->query('INSERT INTO `telegraph` (`receiver`,`text`) VALUES (?i,"?s")', $receiverId, $telegraphText); $statusMessage = 'Сообщение отправлено.'; } else { @@ -41,13 +41,13 @@ if ($_SESSION['receiverName']) { } } - if ($submit == 'sendItem' && $sendItemId && $user->money) { - $res = db::c()->query('SELECT name FROM inventory WHERE owner_id = ?i AND item_id = ?i AND dressed_slot = 0 AND on_sale = 0', $user->id, $sendItemId)->fetch_assoc(); + if ($submit == 'sendItem' && $sendItemId && $user->getMoney()) { + $res = db::c()->query('SELECT name FROM inventory WHERE owner_id = ?i AND item_id = ?i AND dressed_slot = 0 AND on_sale = 0', $user->getId(), $sendItemId)->fetch_assoc(); if (!$res) { $statusMessage = "Предмет не найден в рюкзаке."; } else { - $user->money -= 1; - Bank::setWalletMoney($user->money, $user->id); + $user->setMoney($user->getMoney() - 1); + Bank::setWalletMoney($user->getMoney(), $user->getId()); db::c()->query('UPDATE `inventory` SET owner_id = ?i WHERE item_id= ?i AND owner_id = ?i', $receiverId, $sendItemId, $_SESSION['uid']); $statusMessage = 'Предмет "' . $res['name'] . '" передан персонажу ' . Nick::id($receiverId)->short(1); $receiverLogMessage = 'Получен предмет "' . $res['name'] . '" от персонажа ' . Nick::id($_SESSION['uid'])->short(1); @@ -59,7 +59,7 @@ if ($_SESSION['receiverName']) { } } - $queryItems = db::c()->query('SELECT * FROM inventory WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ?i', $user->id); + $queryItems = db::c()->query('SELECT * FROM inventory WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ?i', $user->getId()); while ($row = $queryItems->fetch_assoc()) { $iteminfo[] = new InventoryItem($row); } diff --git a/presents.php b/presents.php index 24639c3..2322772 100644 --- a/presents.php +++ b/presents.php @@ -13,6 +13,9 @@ * */ +use Battles\Template; +use Battles\User; + session_start(); if ($_SESSION['uid'] != 2) { header("Location: index.php"); @@ -20,7 +23,7 @@ if ($_SESSION['uid'] != 2) { } require_once 'config.php'; -$user = new \Battles\User($_SESSION['uid']); +$user = new User($_SESSION['uid']); $status = ''; $dirname = "i/presents/"; $images = glob($dirname . "*.png"); @@ -44,28 +47,28 @@ if (!empty($_POST['sendAction'])) { $_POST['days'] = 1; } $cost = $_POST['days'] * 5; - if ($user->money < $cost) { + if ($user->getMoney() < $cost) { $status = "Не хватает кредитов на оплату подарка!"; return; } if ($_POST['sender'] == 1) { $sender = "Анонимный подарок"; - } elseif ($_POST['sender'] == 2 && $user->clan) { - $sender = "Подарок от клана {$user->clan}"; + } elseif ($_POST['sender'] == 2 && $user->getClan()) { + $sender = "Подарок от клана {$user->getClan()}"; } else { - $sender = "Подарок от {$user->login}"; + $sender = "Подарок от {$user->getLogin()}"; } - $user->money -= $cost; - Bank::setWalletMoney($user->money, $user->id); + $user->setMoney($user->getMoney() - $cost); + Bank::setWalletMoney($user->getMoney(), $user->getId()); db::c()->query('INSERT INTO users_presents (owner, img, text, sender, expiration_date) VALUES (?i,"?s","?s","?s",DATE_ADD(CURDATE(),INTERVAL ?i DAY))', $receiver['id'], $_POST['present'], $_POST['text'], $sender, $_POST['days']); $telegraphText = "Вам пришёл подарок от {$sender}!"; db::c()->query('INSERT INTO `telegraph` (receiver, text) VALUES (?i,"?s")', $receiver['id'], $telegraphText); $status = "Подарок удачно доставлен к {$_POST['receiver']}! Вы потратили {$cost} кр."; } -\Battles\Template::header('Дарильня'); +Template::header('Дарильня'); ?>