From e619669ba3e2a49466d3f5f66528e0298db0c57e Mon Sep 17 00:00:00 2001 From: lopar Date: Tue, 27 Oct 2020 00:13:07 +0200 Subject: [PATCH 01/12] =?UTF-8?q?=D0=A1=D0=BD=D0=BE=D0=B2=D0=B0=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=B6=D0=B5=D0=BC=20=D0=B3=D1=83=D0=BB=D1=8F=D1=82=D1=8C?= =?UTF-8?q?=20=D0=BF=D0=BE=20=D0=B3=D0=BE=D1=80=D0=BE=D0=B4=D1=83.=20?= =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B8=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B7=D1=80=D0=B5=D1=88=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BD=D0=B0?= =?UTF-8?q?=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D1=89=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B8=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B3=D0=BE=D1=80=D0=BE=D0=B4=D0=B0?= =?UTF-8?q?=20=D1=80=D0=B0=D0=B7=D0=B1=D1=80=D0=BE=D1=81=D0=B0=D0=BD=D1=8B?= =?UTF-8?q?=20=D0=BF=D0=BE=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B0=D0=BC.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- city.php | 70 ++++++++++++++++++++++----------------------- classes/Travel.php | 71 +++++++++++++++++++++++++++++++++++++--------- functions.php | 4 +-- top_menu.php | 4 ++- 4 files changed, 98 insertions(+), 51 deletions(-) diff --git a/city.php b/city.php index a19fd70..b9c5787 100644 --- a/city.php +++ b/city.php @@ -63,31 +63,31 @@ switch ($location[0]) { exit; break; case 'level7': - Travel::toRoom(21); + Travel::toRoom(21,$user->room); break; case 'level8': - Travel::toRoom(26); + Travel::toRoom(26,$user->room); break; case 'level13': header('location: quest_room.php'); break; case 'level222': - Travel::toRoom(2702); + Travel::toRoom(2702,$user->room); break; case 'level17': - Travel::toRoom(50, 'ashop.php'); + Travel::toRoom(50,$user->room); break; case 'level2': - Travel::toRoom(22, 'shop.php'); + Travel::toRoom(22,$user->room); break; case 'level4': - Travel::toRoom(23, 'repair.php'); + Travel::toRoom(23,$user->room); break; case 'level6': - Travel::toRoom(27, 'post.php'); + Travel::toRoom(27,$user->room); break; case 'level3': - Travel::toRoom(25, 'comission.php'); + Travel::toRoom(25,$user->room); break; } } elseif ($user->room == 21) { @@ -95,25 +95,25 @@ switch ($location[0]) { default: break; case 'level4': - Travel::toRoom(20); + Travel::toRoom(20,$user->room); break; case 'level3': - Travel::toRoom(2111); + Travel::toRoom(2111,$user->room); break; case 'level13': - Travel::toRoom(34, 'fshop.php'); + Travel::toRoom(34,$user->room); break; case 'level5': - Travel::toRoom(29, 'bank.php'); + Travel::toRoom(29,$user->room); break; case 'level16': - Travel::toRoom(31, 'tower.php'); + Travel::toRoom(31,$user->room); break; case 'level14': - Travel::toRoom(30, 'clan_create.php'); + Travel::toRoom(30,$user->room); break; case 'level650': - Travel::toRoom(650, 'ul_clans.php'); + Travel::toRoom(650,$user->room); break; } } elseif ($user->room == 2111) { @@ -121,19 +121,19 @@ switch ($location[0]) { default: break; case 'level1': - Travel::toRoom(21); + Travel::toRoom(21,$user->room); break; case 'level2': header('location: city.php?haos'); break; case 'level203': - Travel::toRoom(1055, 'group_arena.php'); + Travel::toRoom(1055,$user->room); break; case 'level1000': - Travel::toRoom(620, 'enter_cave.php'); + Travel::toRoom(620,$user->room); break; case 'room666': - Travel::toRoom(666, 'jail.php'); + Travel::toRoom(666,$user->room); break; } } elseif ($user->room == 2601) { @@ -141,19 +141,19 @@ switch ($location[0]) { default: break; case 'level4': - Travel::toRoom(26); + Travel::toRoom(26,$user->room); break; case 'level55': - Travel::toRoom(2655); + Travel::toRoom(2655,$user->room); break; case 'level1': - Travel::toRoom(37, 'gotzamok.php'); + Travel::toRoom(37,$user->room); break; case 'level1051': - Travel::toRoom(1051, 'lab_enter.php'); + Travel::toRoom(1051,$user->room); break; case 'level5': - Travel::toRoom(404, 'vxod.php'); + Travel::toRoom(404,$user->room); break; } } elseif ($user->room == 2701) { @@ -161,10 +161,10 @@ switch ($location[0]) { default: break; case 'level1': - Travel::toRoom(2111); + Travel::toRoom(2111,$user->room); break; case 'level2': - Travel::toRoom(402, 'lab_chaos_enter.php'); + Travel::toRoom(402,$user->room); break; } } elseif ($user->room == 2702) { @@ -172,10 +172,10 @@ switch ($location[0]) { default: break; case 'level10': - Travel::toRoom(20); + Travel::toRoom(20,$user->room); break; case 'level6': - Travel::toRoom(61, 'akadem.php'); + Travel::toRoom(61,$user->room); break; } } elseif ($user->room == 2655) { @@ -183,10 +183,10 @@ switch ($location[0]) { default: break; case 'level10': - Travel::toRoom(2601); + Travel::toRoom(2601,$user->room); break; case 'level2055': - Travel::toRoom(603, 'aren_of_angels.php'); + Travel::toRoom(603,$user->room); break; } } elseif ($user->room == 26) { @@ -194,19 +194,19 @@ switch ($location[0]) { default: break; case 'level4': - Travel::toRoom(20); + Travel::toRoom(20,$user->room); break; case 'level3': - Travel::toRoom(2601); + Travel::toRoom(2601,$user->room); break; case 'level660': - Travel::toRoom(660, 'hostel.php'); + Travel::toRoom(660,$user->room); break; case 'level7': - Travel::toRoom(777, 'obshaga.php'); + Travel::toRoom(777,$user->room); break; case 'level56': - Travel::toRoom(401, 'hell.php'); + Travel::toRoom(401,$user->room); break; } } diff --git a/classes/Travel.php b/classes/Travel.php index c29253f..f24ea7b 100644 --- a/classes/Travel.php +++ b/classes/Travel.php @@ -3,9 +3,51 @@ class Travel { - public static function toRoom(int $roomId, string $redirectToFile = 'city.php'): void + /** + * Соответствие ID комнаты игровому файлу. + * @var string[] + */ + private static $roomFileName = [ + 20 => 'city.php', + 21 => 'city.php', + 22 => 'shop.php', + 23 => 'repair.php', + 25 => 'comission.php', + 26 => 'city.php', + 27 => 'post.php', + 29 => 'bank.php', + 30 => 'clan_create.php', + 31 => 'tower.php', + 34 => 'fshop.php', + 37 => 'gotzamok.php', + 50 => 'ashop.php', + 51 => 'city.php', + 61 => 'akadem.php', + 401 => 'hell.php', + 402 => 'lab_chaos_enter.php', + 404 => 'vxod.php', + 603 => 'aren_of_angels.php', + 620 => 'enter_cave.php', + 650 => 'ul_clans.php', + 660 => 'hostel.php', + 666 => 'jail.php', + 777 => 'obshaga.php', + 1051 => 'lab_enter.php', + 1055 => 'group_arena.php', + 2111 => 'city.php', + 2601 => 'city.php', + 2655 => 'city.php', + ]; + + /** + * Перемещение по комнатам. + * @param int $roomId ID куда идём. + * @param int $roomIdCurrent ID откуда идём. + * @throws \Krugozor\Database\Mysql\Exception + */ + public static function toRoom(int $roomId, int $roomIdCurrent = 0): void { - $itemsWeight = db::c()->query('SELECT SUM(weight) AS all_weight FROM `inventory` WHERE owner_id = ?i AND `setsale` = 0', $_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()) { @@ -21,9 +63,10 @@ class Travel foreach ($errors as $error) { echo sprintf('%s', $error); } - } elseif (in_array($roomId, self::allowedRoomMoves($roomId))) { - db::c()->query('UPDATE users, online SET users.room = ?i, online.room = ?i WHERE `online`.`user_id` = `users`.`id` AND `online`.`id` = ?i', $roomId, $roomId, $_SESSION['uid']); - header('location: ' . $redirectToFile); + } elseif (in_array($roomId, self::allowedRoomMoves($roomIdCurrent))) { + echo 111; + 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; } } @@ -47,7 +90,7 @@ class Travel * 17 Room 50 ashop.php * 222 Room 2702 [STREET] */ - $room[20] = [1, 2, 3, 4, 6, 7, 8, 9, 13, 14, 17, 222]; // level+n + $room[20] = [20, 401, 660, 777, 2601]; /* * 3 Room 2111 [STREET] * 4 Room 20 [STREET] @@ -57,11 +100,11 @@ class Travel * 16 Room 31 tower.php * 650 Room 650 ul_clans.php */ - $room[21] = [3, 4, 5, 13, 14, 16, 16555]; + $room[21] = [20, 29, 30, 31, 34, 650, 2111]; $room[26] = [3, 4, 6, 660]; - $room[2601] = [1, 4, 10, 55, 1051, 1052]; - $room[2655] = [10, 2055]; + $room[2601] = [26, 37, 404, 1051, 2655]; + $room[2655] = [603, 2601]; /* * 1 Room 21 [STREET] @@ -72,10 +115,12 @@ class Travel * [!not on map]666 Room 666 jail.php * 1000 */ - $room[2111] = [1, 2, 14, 21, 203, 1000]; - $room[2701] = [1, 2]; - $room[2702] = [6, 10, 16, 21, 16555]; - if (empty($room[$roomId])) { + $room[2111] = [21, 620, 666, 1055]; + $room[2701] = [402, 2111]; + $room[2702] = [20, 61]; + // Улицы + $room[0] = [20, 21, 26, 51, 2111, 2601, 2655, 2702]; + if ($room[$roomId] === null) { return []; } return $room[$roomId]; diff --git a/functions.php b/functions.php index de44dd6..b971ed2 100644 --- a/functions.php +++ b/functions.php @@ -1083,8 +1083,8 @@ function telegraph($userId, $text) function get_meshok() { global $user; - $d = db::c()->query('SELECT SUM(`gmeshok`) AS `ves` FROM `inventory` WHERE `owner` = ?i AND `setsale` = 0 AND `gmeshok` > 0', $_SESSION['uid'])->fetch_assoc(); - return ($user->strength * 4 + $d['ves']); + $itemsWeight = db::c()->query('SELECT SUM(weight) AS all_weight FROM `inventory` WHERE owner_id = ?i AND on_sale = 0', $_SESSION['uid'])->fetch_assoc(); + return ($user->strength * 4 + $itemsWeight['all_weight']); } /** diff --git a/top_menu.php b/top_menu.php index f64337e..f0e7c8a 100644 --- a/top_menu.php +++ b/top_menu.php @@ -1,4 +1,6 @@ - +