game/_incl_data/class/LocationResponse.php

191 lines
9.2 KiB
PHP

<?php
use Core\Config;
use Core\Db;
class LocationResponse
{
private const MSG = [
'your-position' => 'Ваше местоположение',
'move-bk' => 'Проход через <b>Бойцовский клуб</b>',
'move-zalu4' => 'Проход через <b>Зал паладинов</b>',
'move-map_halls' => 'Проход через <b>Залы</b>',
'move-to-sek4' => 'Проход через <b>Рыцарский</b> или <b>Торговый</b> зал',
'move-sek5' => 'Проход через <b>Торговый зал</b>',
'move-sek6' => 'Проход через <b>Рыцарский зал</b>',
];
private static function thisInfRm($id): array
{
$rm = Db::getRow('select id, name from room where code = ?', [$id]);
if (isset($rm['id'])) {
$rown = Db::getValue('select count(*) from users where online > unix_timestamp() - 120 and room = ?', [$rm['id']]);
return [$id, $rm['name'], $rown];
}
return ['false', 'Здание было разрушено', 0];
}
public static function init(
int $tmGo,
int $tmGol,
$roomFile,
$roomName,
): string {
$r = match ($roomFile) {
'bk' => [
'status' => 'success',
'location' => [
'bg' => 'navig',
'left' => '241',
'top' => '128',
],
'goto' => [
['id' => 'map_bk', 'params' => [false, self::MSG['your-position']]],
['id' => 'map_klub1', 'params' => self::thisInfRm('1.180.0.15')],
['id' => 'map_klub2', 'params' => self::thisInfRm('1.180.0.225')],
['id' => 'map_klub3', 'params' => self::thisInfRm('1.180.0.2')],
['id' => 'map_klub4', 'params' => self::thisInfRm('1.180.0.4')],
['id' => 'map_klub5', 'params' => self::thisInfRm('1.180.0.5')],
['id' => 'map_klub6', 'params' => self::thisInfRm('1.180.0.16')],
['id' => 'map_klub7', 'params' => self::thisInfRm('1.180.0.9')],
],
'buttons' => [
['Возврат', 'main.php?homeworld=true'],
['Карта клуба', 'main.php?clubmap=true'],
['Форум', "window.open('" . Config::get('forum') . "', 'forum', 'location=yes,menubar=yes,status=yes,resizable=yes,toolbar=yes,scrollbars=yes,scrollbars=yes')"],
['Подсказка', "window.open('/encicl/help/top1.html', 'help', 'height=300,width=500,location=no,menubar=no,status=no,toolbar=no,scrollbars=yes')"],
],
],
'zv1' => [
'status' => 'success',
'location' => [
'bg' => 'navig',
'left' => '154',
'top' => '148',
],
'goto' => [
['id' => 'map_bk', 'params' => self::thisInfRm('1.180.0.3')],
['id' => 'map_klub1', 'params' => [false, self::MSG['move-bk']]],
['id' => 'map_klub2', 'params' => [false, self::MSG['move-bk']]],
['id' => 'map_klub3', 'params' => [false, self::MSG['move-bk']]],
['id' => 'map_klub4', 'params' => [false, self::MSG['your-position']]],
['id' => 'map_klub5', 'params' => [false, self::MSG['move-bk']]],
['id' => 'map_klub6', 'params' => [false, self::MSG['move-bk']]],
['id' => 'map_klub7', 'params' => [false, self::MSG['move-bk']]],
],
],
'zv2' => [
'status' => 'success',
'location' => [
'bg' => 'navig',
'left' => '395',
'top' => '142',
],
'goto' => [
['id' => 'map_bk', 'params' => self::thisInfRm('1.180.0.3')],
['id' => 'map_klub1', 'params' => [false, self::MSG['move-bk']]],
['id' => 'map_klub2', 'params' => [false, self::MSG['move-bk']]],
['id' => 'map_klub3', 'params' => [false, self::MSG['your-position']]],
['id' => 'map_klub4', 'params' => [false, self::MSG['move-bk']]],
['id' => 'map_klub5', 'params' => [false, self::MSG['move-bk']]],
['id' => 'map_klub6', 'params' => [false, self::MSG['move-bk']]],
['id' => 'map_klub7', 'params' => [false, self::MSG['move-bk']]],
],
],
'zv3' => [
'status' => 'success',
'location' => [
'bg' => 'navig',
'left' => '337',
'top' => '79',
],
'goto' => [
['id' => 'map_bk', 'params' => self::thisInfRm('1.180.0.3')],
['id' => 'map_klub1', 'params' => [false, self::MSG['move-bk']]],
['id' => 'map_klub2', 'params' => [false, self::MSG['move-bk']]],
['id' => 'map_klub3', 'params' => [false, self::MSG['move-bk']]],
['id' => 'map_klub4', 'params' => [false, self::MSG['move-bk']]],
['id' => 'map_klub5', 'params' => [false, self::MSG['your-position']]],
['id' => 'map_klub6', 'params' => [false, self::MSG['move-bk']]],
['id' => 'map_klub7', 'params' => [false, self::MSG['move-bk']]],
],
],
'zv4' => [
'status' => 'success',
'location' => [
'bg' => 'navig',
'left' => '139',
'top' => '79',
],
'goto' => [
['id' => 'map_bk', 'params' => self::thisInfRm('1.180.0.3')],
['id' => 'map_klub1', 'params' => [false, self::MSG['move-bk']]],
['id' => 'map_klub2', 'params' => [false, self::MSG['move-bk']]],
['id' => 'map_klub3', 'params' => [false, self::MSG['move-bk']]],
['id' => 'map_klub4', 'params' => [false, self::MSG['move-bk']]],
['id' => 'map_klub5', 'params' => [false, self::MSG['move-bk']]],
['id' => 'map_klub6', 'params' => [false, self::MSG['your-position']]],
['id' => 'map_klub7', 'params' => [false, self::MSG['move-bk']]],
],
],
'zalu' => [
'status' => 'success',
'location' => [
'bg' => 'navig1',
'left' => '337',
'top' => '117',
],
'goto' => [
['id' => 'map_halls', 'params' => [false, self::MSG['your-position']]],
['id' => 'map_zalu3', 'params' => [false, self::MSG['move-zalu4']]],
['id' => 'map_zalu4', 'params' => self::thisInfRm('1.180.0.16')],
['id' => 'map_zalu6', 'params' => [false, self::MSG['move-zalu4']]],
['id' => 'map_zalu7', 'params' => self::thisInfRm('1.180.0.3')],
],
],
'zalu_pal' => [
'status' => 'success',
'location' => [
'bg' => 'navig1',
'left' => '163',
'top' => '28',
],
'goto' => [
['id' => 'map_halls', 'params' => self::thisInfRm('1.180.0.15')],
['id' => 'map_zalu3', 'params' => self::thisInfRm('1.180.0.xx')],
['id' => 'map_zalu4', 'params' => [false, self::MSG['your-position']]],
['id' => 'map_zalu6', 'params' => self::thisInfRm('1.180.0.0')],
['id' => 'map_zalu7', 'params' => [false, self::MSG['move-map_halls']]],
],
],
'bk2' => [
'status' => 'success',
'location' => [
'bg' => 'navig3',
'left' => '162',
'top' => '125',
],
'goto' => [
['id' => 'map_2stair', 'params' => [false, self::MSG['your-position']]],
['id' => 'map_sec1', 'params' => self::thisInfRm('1.180.0.3')],
['id' => 'map_sec2', 'params' => self::thisInfRm('1.180.0.xx')],
['id' => 'map_sec3', 'params' => [false, self::MSG['move-sek5']]],
['id' => 'map_sec4', 'params' => [false, self::MSG['move-to-sek4']]],
['id' => 'map_sec5', 'params' => self::thisInfRm('1.180.0.221')],
['id' => 'map_sec6', 'params' => self::thisInfRm('1.180.0.224')],
['id' => 'map_sec7', 'params' => [false, self::MSG['move-sek6']]],
],
],
default => [],
};
if (!empty($r)) {
$r['location']['name'] = $roomName;
$r['location']['tgo'] = $tmGo * 10;
$r['location']['tgo1'] = $tmGol * 10;
}
$r = json_encode($r);
return $r ?: '';
}
}