diff --git a/admin/admin.php b/admin/admin.php index 1e65c5f..41600a7 100644 --- a/admin/admin.php +++ b/admin/admin.php @@ -8,23 +8,24 @@ session_start(); require_once '../functions.php'; use Battles\Bank; +use Battles\Database\DBPDO; use Battles\GameConfigs; use Battles\Moderation; use Battles\Nick; use Battles\Template; use Battles\User; -if (!$user->getAdmin()) { +if (!User::$current->getAdmin()) { header("HTTP/1.0 404 Not Found"); exit; } if (isset($_GET['sleep'])) { - Moderation::muteChat($user->getId(), strtotime('15min')); + Moderation::muteChat(User::$current->getId(), strtotime('15min')); } if (isset($_POST['ldnick']) && isset($_POST['ldtext'])) { $u = new User($_POST['ldnick']); - Moderation::addToUserLog($u->getId(), $_POST['ldtext'], $user->getId()); + Moderation::addToUserLog($u->getId(), $_POST['ldtext'], User::$current->getId()); unset($u); } @@ -34,7 +35,7 @@ if (isset($_POST['syschatmsg'])) { //clans to reg $unregisteredClans = new class { - public $db; + public DBPDO $db; public function getList() { @@ -75,7 +76,7 @@ UNREGCLANLIST; $bank::setBankMoney($bank->getMoney() + GameConfigs::CLAN['clan_register_cost'], $id); } }; -$unregisteredClans->db = $db; +$unregisteredClans->db = DBPDO::$db; $unregisteredClans->getList(); if (isset($_GET['regclan'])) { @@ -91,19 +92,15 @@ if (isset($_GET['remclan'])) { # Телеграф. if (!empty($_POST['receiver']) && !empty($_POST['tgmsg'])) { - $receiver = $db->ofetch('SELECT id FROM users WHERE login= ?', $_POST['receiver']); + $receiver = DBPDO::$db->ofetch('SELECT id FROM users WHERE login= ?', $_POST['receiver']); telegraph($receiver->id, $_POST['tgmsg']); echo "Успешно."; } # Показывает невидимок. -$row = $db->ofetchAll('SELECT id,login FROM users LEFT JOIN users_effects ue on users.id = ue.owner_id WHERE type = 1022 ORDER BY `id` DESC'); -$i = 0; -$invisList = ''; -while ($i < count($row)) { - $invisList .= '[id] = ' . $row[$i]->id . ', ' . $row[$i]->login . '
'; - $i++; +$row = DBPDO::$db->ofetchAll('SELECT id,login FROM users LEFT JOIN users_effects ue on users.id = ue.owner_id WHERE type = 1022 ORDER BY `id` DESC'); +foreach ($row as $r) { + $invisList .= '[id] = ' .$r->id. ', ' .$r->login. '
'; } -unset($i); Template::header('ᐰdminка'); diff --git a/bank.php b/bank.php index f26c8e6..3f5d2c2 100644 --- a/bank.php +++ b/bank.php @@ -6,7 +6,6 @@ use Battles\Rooms; use Battles\Template; use Exceptions\GameException; -ob_start("ob_gzhandler"); session_start(); require_once "functions.php"; const SUCCESS = "Успешная операция!"; diff --git a/clan.php b/clan.php index 4c48a3f..9bc61ed 100644 --- a/clan.php +++ b/clan.php @@ -5,17 +5,17 @@ use Battles\GameConfigs; use Battles\Nick; use Battles\Rooms; use Battles\Template; +use Battles\User; session_start(); require_once 'functions.php'; - -if (!$user->getClan()) { +if (!User::$current->getClan()) { exit('Ошибка! Вы не состоите в клане!'); } -Clan::$current = new Clan($user, $db); -if ($user->getClan() != Clan::$current->getClanShortName()) { - exit('Ошибка! Клана ' . $user->getClan() . ' не существует!'); +Clan::$current = new Clan(); +if (User::$current->getClan() != Clan::$current->getClanShortName()) { + exit('Ошибка! Клана ' . User::$current->getClan() . ' не существует!'); } Template::header('clan'); @@ -65,7 +65,7 @@ Template::header('clan');

<?= Clan::$current->getClanShortName() ?>getClanName() ?>

- getClanOwnerId() === $user->getId()): ?> + getClanOwnerId() === User::$current->getId()): ?>
diff --git a/clan_create.php b/clan_create.php index 2722fb6..22cb6e4 100644 --- a/clan_create.php +++ b/clan_create.php @@ -17,7 +17,7 @@ if ($clanFullName && $clanShortName && $clanInfo && !$userClan) { $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 (GameConfigs::CLAN_REGISTER_LOCK) { + if (GameConfigs::CLAN['clan_register_lock']) { $errorMessage[10] = 'Регистрация кланов закрыта!
'; } if ($user->getAlign()) { @@ -26,7 +26,7 @@ if ($clanFullName && $clanShortName && $clanInfo && !$userClan) { if ($user->getClan()) { $errorMessage[1] = 'Вы уже состоите в клане!.
'; } - if (GameConfigs::CLAN_REGISTER_COST >= $userBank->getMoney()) { + if (GameConfigs::CLAN['clan_register_cost'] >= $userBank->getMoney()) { $errorMessage[2] = 'Не хватает денег на регистрацию клана.
'; } if (!$eff) { @@ -38,7 +38,7 @@ if ($clanFullName && $clanShortName && $clanInfo && !$userClan) { if (!$errorMessage || $user->getAdmin()) { try { 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() - GameConfigs::CLAN_REGISTER_COST); + $userBank->setMoney($userBank->getMoney() - GameConfigs::CLAN['clan_register_cost']); Battles\Bank::setBankMoney($userBank->getMoney(), $user->getId(), 'clanRegister'); // Заглушка для отображения данных по только что зарегистрированному клану, когда запрос в базу в начале файла ещё не проходит. $userClan = new stdClass(); diff --git a/classes/Battles/Bank.php b/classes/Battles/Bank.php index 8c672f8..bad8055 100644 --- a/classes/Battles/Bank.php +++ b/classes/Battles/Bank.php @@ -28,6 +28,7 @@ class Bank 'depositMoney' => 'Пополнение счёта.', 'withdrawMoney' => 'Снятие денег со счёта.', 'clanRegister' => 'Оплата стоимости регистрации клана.', + 'sellShop' => 'Продажа товара в магазине.' ]; public function __construct(int $user_id) @@ -214,12 +215,9 @@ class Bank */ public static function setWalletMoney(int $amount, int $user_id): void { - try { - self::$db->execute('UPDATE users SET money = ? WHERE id = ?', [$amount, $user_id]); - } catch (Throwable $e) { - echo "Не отработал запрос в БД в файле {$e->getFile()}({$e->getLine()})"; - } - + $u = new User($user_id); + $u->setMoney($amount); + $u->saveMoney(); } public function getMoney(): int diff --git a/classes/Battles/Check.php b/classes/Battles/Check.php new file mode 100644 index 0000000..5424706 --- /dev/null +++ b/classes/Battles/Check.php @@ -0,0 +1,28 @@ +user = $user; + $this->db = $db; + } + + public function Effects() + { + return $this->db->execute('delete from users_effects where remaining_time <= ?', strtotime('now')); + } +} \ No newline at end of file diff --git a/classes/Battles/Clan.php b/classes/Battles/Clan.php index b39c36f..f3484f3 100644 --- a/classes/Battles/Clan.php +++ b/classes/Battles/Clan.php @@ -11,24 +11,24 @@ class Clan private $clan; public static Clan $current; - public function __construct(User $user, DBPDO $db) + public function __construct() { - $this->db = $db; - $this->user = $user; + $this->db = DBPDO::$db; + $this->user = User::$current; $this->clan = $this->db->ofetch('select * from clans where owner_id = ?', $this->user->getId()); } public function addMember(string $login): string { + $target = new User($login); $error = null; - $check = $this->db->ofetch('select id, level, clan from users where login = ?', $login); - if (!$this->getProverka($check->id)) { + if (!$this->getProverka($target->getId())) { $error .= '
Нет проверки!'; } - if ($check->clan) { + if ($target->getClan()) { $error .= '
Персонаж уже состоит в клане!'; } - if ($check->level < 1) { + if ($target->getLevel() < 1) { $error .= '
Персонаж 0 уровня не может быть принят!'; } if ($this->user->getMoney() < GameConfigs::CLAN['add_member_cost']) { @@ -39,21 +39,21 @@ class Clan } $this->user->setMoney($this->user->getMoney() - GameConfigs::CLAN['add_member_cost']); $this->user->saveMoney(); - $this->db->execute('update users set clan = ? where id = ?', [$this->user->getClan(), $check->id]); + $target->setClan($this->user->getClan()); return "Персонаж «{$login}» успешно принят в клан."; } public function removeMember(string $login): string { + $target = new User($login); $error = null; - $check = $this->db->ofetch('select id, clan from users where login = ?', $login); if ($this->user->getMoney() < GameConfigs::CLAN['remove_member_cost']) { $error .= '
Недостаточно денег!'; } - if ($check->id === $this->user->getId()) { + if ($target->getId() === $this->user->getId()) { $error .= '
Себя выгонять нельзя!'; } - if ($check->clan !== $this->user->getClan()) { + if ($target->getClan() !== $this->user->getClan()) { $error .= '
Персонаж не состоит в этом клане!'; } if ($error) { @@ -61,28 +61,28 @@ class Clan } $this->user->setMoney($this->user->getMoney() - GameConfigs::CLAN['remove_member_cost']); $this->user->saveMoney(); - $this->db->execute('update users set clan = null where id = ?', $check->id); + $target->setClan(null); return "Персонаж «{$login}» покинул клан."; } public function changeOwner(string $login): string { + $target = new User($login); $error = null; - $check = $this->db->ofetch('select id, clan from users where login = ?', $login); - if ($check->id === $this->user->getId()) { + if ($target->getId() === $this->user->getId()) { $error .= '
Самоудовлетворяетесь? ;)'; } - if ($check->clan !== $this->user->getClan()) { + if ($target->getClan() !== $this->user->getClan()) { $error .= '
Персонаж не состоит в этом клане!'; } if ($error) { return $error; } - $this->db->execute('update clans set owner_id = ? where owner_id = ?', [$check->id, $this->user->getId()]); + $this->db->execute('update clans set owner_id = ? where owner_id = ?', [$target->getId(), $this->user->getId()]); return 'Вы передали управление кланом персонажу «' . $login . '».'; } - public function setClanInfo(string $text) + public function setClanInfo(string $text): string { $check = $this->db->ofetch('select id from users where clan = (select short_name from clans where owner_id = ?)', $this->user->getId()); if ($check->id !== $this->user->getId()) { @@ -94,8 +94,7 @@ class Clan public function getMemberlist(): array { - $query = 'select id, (select 1 from clans where short_name = clan and owner_id = id) as clan_owner, room from users where clan = ? order by clan_owner desc, room, login'; - return $this->db->ofetchAll($query, $this->user->getClan()); + return $this->db->ofetchAll('select id, (select 1 from clans where short_name = clan and owner_id = id) as clan_owner, room from users where clan = ? order by clan_owner desc, room, login', $this->user->getClan()); } private function getProverka($user_id) diff --git a/classes/Battles/Database/DBPDO.php b/classes/Battles/Database/DBPDO.php index d9f148e..5ce447f 100644 --- a/classes/Battles/Database/DBPDO.php +++ b/classes/Battles/Database/DBPDO.php @@ -9,6 +9,7 @@ class DBPDO public $pdo; private static $_instance = null; + public static DBPDO $db; function __construct() { diff --git a/classes/Battles/Magic/Sharpen.php b/classes/Battles/Magic/Sharpen.php index 7f6ac45..461b853 100644 --- a/classes/Battles/Magic/Sharpen.php +++ b/classes/Battles/Magic/Sharpen.php @@ -10,7 +10,7 @@ use Battles\User; class Sharpen extends Magic { - private $magicDifficulty; + private int $magicDifficulty; /** * Sharpen constructor. diff --git a/classes/Battles/Moderation.php b/classes/Battles/Moderation.php index 8df1497..4358111 100644 --- a/classes/Battles/Moderation.php +++ b/classes/Battles/Moderation.php @@ -15,72 +15,72 @@ class Moderation GameLogs::addUserLog($userId, $message, "moderation"); } - public static function muteChat(int $target, int $time): bool + public static function muteChat(int $target, int $time) { self::addEffectStatusToUserLog($target, UserEffects::$effectName[2]); - return User::setUserEffect($target, 2, UserEffects::$effectName[2], $time); + User::addUserEffect($target, 2, UserEffects::$effectName[2], $time); } - public static function unmuteChat(int $target): bool + public static function unmuteChat(int $target) { self::addEffectStatusToUserLog($target, UserEffects::$effectName[2] . self::STATUS_OFF); - return User::removeUserEffect($target, 2); + User::removeUserEffect($target, 2); } - public static function muteForum(int $target, int $time): bool + public static function muteForum(int $target, int $time) { self::addEffectStatusToUserLog($target, UserEffects::$effectName[3]); - return User::setUserEffect($target, 3, UserEffects::$effectName[3], $time); + User::addUserEffect($target, 3, UserEffects::$effectName[3], $time); } - public static function unmuteForum(int $target): bool + public static function unmuteForum(int $target) { self::addEffectStatusToUserLog($target, UserEffects::$effectName[3] . self::STATUS_OFF); - return User::removeUserEffect($target, 3); + User::removeUserEffect($target, 3); } - public static function hideUserInfo(int $target, int $time): bool + public static function hideUserInfo(int $target, int $time) { self::addEffectStatusToUserLog($target, UserEffects::$effectName[5]); - return User::setUserEffect($target, 5, UserEffects::$effectName[5], $time); + User::addUserEffect($target, 5, UserEffects::$effectName[5], $time); } - public static function unHideUserInfo(int $target): bool + public static function unHideUserInfo(int $target) { self::addEffectStatusToUserLog($target, UserEffects::$effectName[5] . self::STATUS_OFF); - return User::removeUserEffect($target, 5); + User::removeUserEffect($target, 5); } - public static function blockUser(int $target): void + public static function blockUser(int $target) { self::addEffectStatusToUserLog($target, "Блокировка"); DBPDO::INIT()->execute('UPDATE battles.users SET block = 1 WHERE id = ?', $target); } - public static function unBlockUser(int $target): void + public static function unBlockUser(int $target) { self::addEffectStatusToUserLog($target, "Блокировка" . self::STATUS_OFF); DBPDO::INIT()->execute('UPDATE battles.users SET block = 0 WHERE block = 1 AND id = ?', $target); } - public static function addToUserLog(int $target, string $message, int $senderId): void + public static function addToUserLog(int $target, string $message, int $senderId) { GameLogs::addUserLog($target, $message, "moderation", $senderId); } - public static function setAlign(int $target, int $align): void + public static function setAlign(int $target, int $align) { DBPDO::INIT()->execute('UPDATE users SET align = ? WHERE id = ?', [$align, $target]); } - public static function addChatSysMsg(string $message): void + public static function addChatSysMsg(string $message) { DBPDO::INIT()->execute('INSERT INTO chat (user_id,msg,type) VALUES (-1,?,?)', [$message, 'sys']); } - public static function addUserCheck(int $target): bool + public static function addUserCheck(int $target) { self::addEffectStatusToUserLog($target, UserEffects::$effectName[20]); - return User::setUserEffect($target, 20, UserEffects::$effectName[20], strtotime('3days')); + User::addUserEffect($target, 20, UserEffects::$effectName[20], strtotime('3days')); } } \ No newline at end of file diff --git a/classes/Battles/ShopItem.php b/classes/Battles/ShopItem.php index c8825b0..88fbfee 100644 --- a/classes/Battles/ShopItem.php +++ b/classes/Battles/ShopItem.php @@ -91,6 +91,7 @@ SQL; echo ""; } + //todo наличка после покупки отображается с задержкой. public static function buyItem($id, User $buyer): string { $db = new DBPDO(); diff --git a/classes/Battles/User.php b/classes/Battles/User.php index 2db0dd4..a286e25 100644 --- a/classes/Battles/User.php +++ b/classes/Battles/User.php @@ -6,38 +6,49 @@ use Battles\Database\DBPDO; class User { - protected $id = 0; - protected $login = 'Некто'; - protected $pass; - protected $email = 'неизвестно'; - protected $realname; - protected $borndate; - protected $info; - protected $level; - protected $align; - protected $clan; - protected $money; - protected $ip = 0; + protected int $id = 0; + protected string $login = ''; + protected ?string $pass = null; + protected ?string $email = null; + protected ?string $realname = null; + protected ?string $borndate = null; + protected ?string $info = null; + protected int $level = 0; + protected ?int $align = null; + protected ?string $clan = null; + protected ?int $money = null; + protected ?string $ip = null; - protected $admin = 0; - protected $enter_game; - protected $room; - protected $block; - protected $shadow; + protected ?int $admin = null; + protected int $room = 0; + protected int $block = 0; + protected string $shadow = ''; // Пока несуществующие, для совместимости. - protected $experience = 200; - protected $battle = 0; - protected $in_tower = 0; // Скорее башню похороним чем запустим... - protected $zayavka = 0; - protected static $db; + protected int $experience = 0; + protected int $battle = 0; + protected int $in_tower = 0; // Скорее башню похороним чем запустим... + protected int $zayavka = 0; + protected static DBPDO $db; public const INFO_CHAR_LIMIT = 1500; + /** + * @var User Переменная инициализируемая при запуске, хранящая объект текущего пользователя. + */ + public static User $current; + /** + * @param int|string $user + */ public function __construct($user) { self::$db = DBPDO::INIT(); - $user_query = self::$db->fetch('SELECT * FROM users WHERE id = ? OR login = ?', [$user, $user]); + $query = 'select * from users where login = ?'; + if (is_numeric($user)) { + $query = 'select * from users where id = ?'; + $user = (int)$user; + } + $user_query = self::$db->fetch($query, $user); foreach ($this as $key => $value) { if (isset($user_query[$key])) { $this->$key = $user_query[$key]; @@ -51,12 +62,11 @@ class User * @param string $name * @param int $time * @param string|null $json_modifiers_list (str, dex, int, end, intel, wis). - * @return bool */ - public static function setUserEffect(int $userId, int $type, string $name, int $time, string $json_modifiers_list = null): bool + public static function addUserEffect(int $userId, int $type, string $name, int $time, string $json_modifiers_list = null) { $mods = json_decode($json_modifiers_list); - return self::$db->execute('INSERT INTO users_effects (owner_id, type, name, remaining_time, mod_strength, mod_dexterity, mod_intuition, mod_endurance, mod_intelligence, mod_wisdom) VALUES (?,?,?,?,?,?,?,?,?,?)', [$userId, $type, $name, $time, $mods->str ?? null, $mods->dex ?? null, $mods->int ?? null, $mods->end ?? null, $mods->intel ?? null, $mods->wis ?? null]); + self::$db->execute('INSERT INTO users_effects (owner_id, type, name, remaining_time, mod_strength, mod_dexterity, mod_intuition, mod_endurance, mod_intelligence, mod_wisdom) VALUES (?,?,?,?,?,?,?,?,?,?)', [$userId, $type, $name, $time, $mods->str ?? null, $mods->dex ?? null, $mods->int ?? null, $mods->end ?? null, $mods->intel ?? null, $mods->wis ?? null]); } public static function removeUserEffect(int $userId, int $type): bool @@ -67,34 +77,17 @@ class User return false; } - /** - * @return int - */ public function getId(): int { return $this->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() + public function getPass(): string { return $this->pass; } @@ -112,26 +105,7 @@ class User self::$db->execute('UPDATE users SET pass = ? WHERE id = ?', [$this->pass, $this->id]); } - /** - * @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() + public function getRealname(): string { return $this->realname; } @@ -144,26 +118,7 @@ class User $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() + public function getInfo(): string { return $this->info; } @@ -171,71 +126,46 @@ class User /** * @param mixed $info */ - public function setInfo($info): void + public function setInfo($info) { $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 string - */ - public function getClan(): string + public function getClan(): ?string { return $this->clan; } /** - * @param int $clan + * @param string|null $short_name Короткое название клана. Передать null для очистки. */ - public function setClan(string $clan): void + public function setClan(?string $short_name) { - $this->clan = $clan; + if (is_null($short_name)) { + $this->clan = null; + self::$db->execute('update users set clan = null where id = ?', $this->id); + } else { + $this->clan = $short_name; + self::$db->execute('update users set clan = ? where id = ?', [$short_name, $this->id]); + } } - /** - * @return int - */ public function getMoney(): int { return $this->money; } - /** - * @param int $money - */ - public function setMoney(int $money): void + public function setMoney(int $money) { $this->money = $money < 0 ? 0 : $money; } @@ -245,52 +175,12 @@ class User self::$db->execute('update users set money = ? where id = ?', [$this->money, $this->id]); } - - /** - * @return mixed - */ - public function getIp() - { - return $this->ip; - } - - /** - * @param mixed $ip - */ - public function setIp($ip): void - { - $this->ip = $ip; - } - - - /** - * @return int - */ public function getAdmin(): int { return $this->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() + public function getRoom(): int { return $this->room; } @@ -298,31 +188,17 @@ class User /** * @param mixed $room */ - public function setRoom($room): void + public function setRoom($room) { $this->room = $room; } - /** - * @return mixed - */ - public function getBlock() + public function getBlock(): int { return $this->block; } - /** - * @param mixed $block - */ - public function setBlock($block): void - { - $this->block = $block; - } - - /** - * @return mixed - */ - public function getShadow() + public function getShadow(): string { return $this->shadow; } @@ -346,70 +222,26 @@ class User self::$db->execute('UPDATE users SET shadow = ? WHERE id = ?', [$this->shadow, $this->id]); } - /** - * @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; - } - public function saveAnketa() { self::$db->execute('UPDATE users SET realname = ?, info = ? WHERE id = ?', [$this->realname, $this->info, $this->id]); @@ -422,32 +254,32 @@ class User public function setInjury(int $type): bool { - if (!in_array($type,[11,12,13,14])) { + if (!in_array($type, [11, 12, 13, 14])) { return false; } $names1 = ['разбитый нос', 'сотрясение первой степени', 'потрепанные уши', 'прикушенный язык', 'перелом переносицы', 'растяжение ноги', 'растяжение руки', 'подбитый глаз', 'синяк под глазом', 'кровоточащее рассечение', 'отбитая «пятая точка»', 'заклинившая челюсть', 'выбитый зуб «мудрости»', 'косоглазие']; $names2 = ['отбитые почки', 'вывих «вырезано цензурой»', 'сотрясение второй степени', 'оторванное ухо', 'вывих руки', 'оторванные уши', 'поврежденный позвоночник', 'поврежденный копчик', 'разрыв сухожилия', 'перелом ребра', 'перелом двух ребер', 'вывих ноги', 'сломанная челюсть']; $names3 = ['пробитый череп', 'разрыв селезенки', 'смещение позвонков', 'открытый перелом руки', 'открытый перелом «вырезано цензурой»', 'излом носоглотки', 'непонятные, но множественные травмы', 'сильное внутреннее кровотечение', 'раздробленная коленная чашечка', 'перелом шеи', 'смещение позвонков', 'открытый перелом ключицы', 'перелом позвоночника', 'вывих позвоночника', 'сотрясение третьей степени']; - $param_names = ['str','dex','int','end','intel','wis',]; + $param_names = ['str', 'dex', 'int', 'end', 'intel', 'wis',]; shuffle($param_names); switch ($type) { case 11: shuffle($names1); $name = UserEffects::$effectName[$type] . ': ' . $names1(0); - self::setUserEffect($this->id, $type, $name, strtotime('30min'), json_encode([$param_names(0) => -1])); + self::addUserEffect($this->id, $type, $name, strtotime('30min'), json_encode([$param_names(0) => -1])); break; case 12: shuffle($names2); $name = UserEffects::$effectName[$type] . ': ' . $names2(0); - self::setUserEffect($this->id, $type, $name, strtotime('3hours'), json_encode([$param_names(0) => mt_rand(-3,-1), $param_names(1) => mt_rand(-3,-1)])); + self::addUserEffect($this->id, $type, $name, strtotime('3hours'), json_encode([$param_names(0) => mt_rand(-3, -1), $param_names(1) => mt_rand(-3, -1)])); break; case 13: shuffle($names3); $name = UserEffects::$effectName[$type] . ': ' . $names3(0); - self::setUserEffect($this->id, $type, $name, strtotime('12hours'), json_encode([$param_names(0) => mt_rand(-5,-1), $param_names(1) => mt_rand(-5,-1), $param_names(2) => mt_rand(-5,-1)])); + self::addUserEffect($this->id, $type, $name, strtotime('12hours'), json_encode([$param_names(0) => mt_rand(-5, -1), $param_names(1) => mt_rand(-5, -1), $param_names(2) => mt_rand(-5, -1)])); break; default: //type 14 - self::setUserEffect($this->id, $type, UserEffects::$effectName[$type], strtotime('1day'), json_encode([$param_names(0) => -10])); + self::addUserEffect($this->id, $type, UserEffects::$effectName[$type], strtotime('1day'), json_encode([$param_names(0) => -10])); break; } diff --git a/databases/logs.sqlite b/databases/logs.sqlite index 536cafe..c36eee7 100644 Binary files a/databases/logs.sqlite and b/databases/logs.sqlite differ diff --git a/fbattle.php b/fbattle.php index d682afd..678319c 100644 --- a/fbattle.php +++ b/fbattle.php @@ -1,5 +1,4 @@ query('SELECT `id` FROM `inventory` WHERE `id` = ?i AND `dressed` = 1', $_GET['use'])->fetch_row(); if ((int)$dressed[0] > 0) { $my_class = $fbattle->my_class; - ob_start(); usemagic($_GET['use'], "" . $_POST['target']); $bb = explode("
-
Уровень: getLevel() ?> -
Опыт: getExperience() ?> +
Уровень: getLevel() ?> +
Опыт: getExperience() ?>
Побед: ??
Поражений: ??
Ничьих: ?? -
Деньги: getMoney() ?> кр. +
Деньги: getMoney() ?> кр.
@@ -305,8 +307,9 @@ Template::header('Игра'); увеличений: getFreeStatPoints() ?>

- Здоровье: getHealth() ?>
- Пыль: getMana() ?>
+ + Здоровье: getHealth() ?>
+ Пыль: getMana() ?>
Уворот: getFullStats()->evasion ?>
Точность: getFullStats()->accuracy ?>
Шанс крита: getFullStats()->criticals ?>
@@ -327,14 +330,14 @@ Template::header('Игра');
- getShadow() == '0.gif' || $user->getAdmin() == 1): ?> + getShadow() == '0.gif' || User::$current->getAdmin() == 1): ?>
- getRoom() == 20): ?> + getRoom() == 20): ?> - getRoom() == 1): ?> + getRoom() == 1): ?> diff --git a/repair.php b/repair.php index d59c80a..90cb591 100644 --- a/repair.php +++ b/repair.php @@ -27,7 +27,7 @@ $gravirovka_query = null; if ($gravirovkaText && $itemId) { if ($user->getMoney() >= GRAV_COST) { if (iconv_strlen($gravirovkaText) <= GRAV_LIMIT) { - $db->execute('UPDATE inventory SET text = ? WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [$gravirovkaText, $user->getId(), $itemId]); + DBPDO::$db->execute('UPDATE inventory SET text = ? WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [$gravirovkaText, $user->getId(), $itemId]); $user->setMoney($user->getMoney() - GRAV_COST); Bank::setWalletMoney($user->getMoney(), $user->getId()); $status = REPAIR_STATUS['OK_GRAV_ADDED']; @@ -41,7 +41,7 @@ if ($gravirovkaText && $itemId) { // Снять гравировку. if ($gravirovkaRemove) { if ($user->getMoney() >= GRAV_COST) { - $db->execute('UPDATE inventory SET text = null WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [$user->getId(), $itemId]); + DBPDO::$db->execute('UPDATE inventory SET text = null WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [$user->getId(), $itemId]); $user->setMoney($user->getMoney() - GRAV_COST); Bank::setWalletMoney($user->getMoney(), $user->getId()); $status = REPAIR_STATUS['OK_GRAV_REMOVED']; @@ -52,9 +52,9 @@ if ($gravirovkaRemove) { // Ремонт 0,5 кред за единицу. // Пока что лимит ремонта поставлен на 25. Дальше можно обыграть. if ($action == 'repair' && $itemId) { - $q = $db->ofetch('SELECT name, durability FROM inventory WHERE item_id = ?', $itemId); + $q = DBPDO::$db->ofetch('SELECT name, durability FROM inventory WHERE item_id = ?', $itemId); if ($user->getMoney() > ceil($q->duration / 2)) { - $db->execute('UPDATE inventory SET duration = 25 WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [$user->getId(), $itemId]); + DBPDO::$db->execute('UPDATE inventory SET duration = 25 WHERE dressed_slot = 0 AND on_sale = 0 AND owner_id = ? AND id = ?', [$user->getId(), $itemId]); $user->setMoney($user->getMoney() - ceil($q->duration / 2)); Bank::setWalletMoney($user->getMoney(), $user->getId()); GameLogs::addUserLog($user->getId(), 'Отремонтирован предмет «' . $q->name . '» id:(' . $itemId . ') за ' . ceil($q->duration / 2) . ' кр.'); @@ -64,10 +64,10 @@ if ($action == 'repair' && $itemId) { } } if ($goto == 'remont') { - $remont_query = $db->ofetchAll('SELECT item_id, name, image, durability FROM inventory WHERE item_type < 12 AND dressed_slot = 0 AND on_sale = 0 AND durability < 25 AND owner_id = ? ORDER BY name', $user->getId()); + $remont_query = DBPDO::$db->ofetchAll('SELECT item_id, name, image, durability FROM inventory WHERE item_type < 12 AND dressed_slot = 0 AND on_sale = 0 AND durability < 25 AND owner_id = ? ORDER BY name', $user->getId()); } if ($goto == 'gravirovka') { - $gravirovka_query = $db->ofetchAll('SELECT item_id, name, image, text FROM inventory WHERE owner_id = ? AND dressed_slot = 0 AND item_type = 3 AND name NOT LIKE "%Букет%" AND on_sale = 0 OR text IS NOT NULL AND owner_id = ? AND dressed_slot = 0 AND on_sale = 0 ORDER BY name', [$user->getId(), $user->getId()]); + $gravirovka_query = DBPDO::$db->ofetchAll('SELECT item_id, name, image, text FROM inventory WHERE owner_id = ? AND dressed_slot = 0 AND item_type = 3 AND name NOT LIKE "%Букет%" AND on_sale = 0 OR text IS NOT NULL AND owner_id = ? AND dressed_slot = 0 AND on_sale = 0 ORDER BY name', [$user->getId(), $user->getId()]); } Template::header('Кузня'); ?> diff --git a/shop.php b/shop.php index 4b067f0..a12d496 100644 --- a/shop.php +++ b/shop.php @@ -1,11 +1,11 @@ ofetchAll("select * from items inner join trade_offers on id = shop_item_id where shop_id = 1 and shop_item_quantity !=0"); + $shopItems = DBPDO::$db->ofetchAll("select * from items inner join trade_offers on id = shop_item_id where shop_id = 1 and shop_item_quantity !=0"); foreach ($shopItems as $shopItemObject) { $iteminfo[] = new ShopItem($shopItemObject, 'buyshop'); } } else { - $inventoryItems = $db->ofetchall("select * from inventory where on_sale = 0 and dressed_slot = 0 and durability > 0 and owner_id = ?", $user->getId()); + $inventoryItems = DBPDO::$db->ofetchall("select * from inventory where on_sale = 0 and dressed_slot = 0 and durability > 0 and owner_id = ?", $user->getId()); foreach ($inventoryItems as $inventoryItemObject) { $iteminfo[] = new ShopItem($inventoryItemObject, 'sellshop'); } diff --git a/towerin.php b/towerin.php index 998619e..fff1f59 100644 --- a/towerin.php +++ b/towerin.php @@ -1,5 +1,4 @@