Снова можем гулять по городу. Проверки разрешения на перемещение и отображение города разбросаны по классам.
This commit is contained in:
@@ -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('<span class="error">%s</span>', $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];
|
||||
|
||||
Reference in New Issue
Block a user