new-travel #11

Merged
lopar merged 13 commits from new-travel into master 2020-10-27 19:08:19 +00:00
4 changed files with 98 additions and 51 deletions
Showing only changes of commit e619669ba3 - Show all commits

View File

@ -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;
}
}

View File

@ -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];

View File

@ -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']);
}
/**

View File

@ -1,4 +1,6 @@
<?= Template::header('top_menu', 1) ?>
<?php
require_once 'classes/Template.php';
Template::header('top_menu') ?>
<style>
* {
margin: 0;