battles/city.php

475 lines
20 KiB
PHP
Raw Normal View History

2018-01-28 16:40:49 +00:00
<?php
2018-03-09 02:13:08 +00:00
/**
* Центральная площадь
*/
2018-01-28 16:40:49 +00:00
session_start();
if ($_SESSION['uid'] == null) {
header("Location: index.php");
}
2018-01-28 16:40:49 +00:00
include("config.php");
2018-03-09 02:13:08 +00:00
//$user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '{$_SESSION['uid']}' LIMIT 1"));
//$klan = mysql_fetch_array(mysql_query("SELECT * FROM `clans` WHERE `id` = '{$user['klan']}' LIMIT 1"));
//$digger = mysql_fetch_array(mysql_query("SELECT * FROM `digger` WHERE `id` = '{$_SESSION['uid']}' LIMIT 1"));
2018-01-28 16:40:49 +00:00
include("functions.php");
$tm = time();
if ($user['battle'] != 0) {
header('location: fbattle.php');
die();
}
if ($user['in_tower'] == 1) {
header('Location: towerin.php');
die();
}
if ($user['zayavka'] != 0) {
die();
}
2018-01-28 16:40:49 +00:00
2018-03-09 02:13:08 +00:00
/**
* Проверяем можем ли мы двигаться.
*/
function can_i_move()
2018-03-09 02:13:08 +00:00
{
2018-03-09 17:04:36 +00:00
global $user;
2018-03-09 02:13:08 +00:00
$d = db::c()->query('SELECT SUM(`massa`) AS `mass` FROM `inventory` WHERE `owner` = ?i AND `setsale` = 0', $user['id'])->fetch_assoc();
$eff = db::c()->query('SELECT `type` FROM `effects` WHERE `owner` = ?i AND (`type` = 10 OR `type` = 13 OR `type` = 14)', $user['id'])->fetch_assoc();
2018-03-09 02:13:08 +00:00
if ($d['mass'] > get_meshok()) {
err('У вас переполнен рюкзак, вы не можете передвигаться...');
$location[0] = NULL;
2018-03-09 02:13:08 +00:00
}
if ($eff['type'] == 10) {
2018-03-09 02:13:08 +00:00
err('Вы парализованы и не можете передвигаться...');
$location[0] = NULL;
2018-03-09 02:13:08 +00:00
}
if ($eff['type'] == 13 OR $eff['type'] == 14) {
2018-03-09 02:13:08 +00:00
err('У вас тяжелая травма, вы не можете передвигаться...');
$location[0] = NULL;
2018-03-09 02:13:08 +00:00
}
}
/**
* Перемещаемся по заданным параметрам в пределах страницы
* @param int $room - номер локации
* @param string $roomname - название локации
*/
2018-03-09 12:57:41 +00:00
function move_to_inside($room = 0, $roomname = 'неизвестное место')
2018-03-09 02:13:08 +00:00
{
db::c()->query('UPDATE `users`,`online` SET `users`.`room` = ?i,`online`.`room` = ?i WHERE `online`.`id` = `users`.`id` AND `online`.`id` = ?i', $room, $room, $_SESSION['uid']);
?>
<html>
<head>
<link rel="stylesheet" href="css/main.css">
<meta charset="utf-8">
</head>
<body>
<?php
die("
<script>setTimeout(function(){location.href='city.php'} , 5000);</script>
<div style='margin: auto; text-align:center;'>
<img src='i/ajax-loader.gif'><br><i>Переходим на $roomname...</i>
</div>
");
2018-03-09 02:13:08 +00:00
}
/**
* Перемещаемся по заданным параметрам за пределами страницы
* @param int $room - номер локации
* @param string $redirect - имя скрипта на который идёт редирект
*/
2018-03-09 02:13:08 +00:00
function move_to_outside($room = 0, $redirect = 'city')
{
db::c()->query('UPDATE `users`,`online` SET `users`.`room` = ?i,`online`.`room` = ?i WHERE `online`.`id` = `users`.`id` AND `online`.`id` = ?i', $room, $room, $_SESSION['uid']);
header('location: ' . $redirect);
2018-03-09 02:13:08 +00:00
}
$dig_raw = db::c()->query('SELECT `finish_dig`, `finish_guard` FROM `digger` WHERE `id` = ?i', $user['id'])->fetch_assoc();
if ($dig_raw["finish_dig"] > $tm || $dig_raw["finish_guard"] > $tm) {
header('location: wall_build.php');
die();
}
2018-01-28 16:40:49 +00:00
header("Cache-Control: no-cache");
$location = explode('/', filter_input(INPUT_SERVER, 'QUERY_STRING'));
can_i_move();
switch ($location[0]) {
case 'cp':
move_to_inside(20, 'Центральную площадь');
break;
case 'strah':
move_to_inside(21, 'Страшилкину Улицу');
break;
case 'bps':
move_to_inside(26, 'Большую Парковую улицу');
break;
case 'ps':
move_to_inside(51, 'Парковую улицу');
break;
case 'zaliv':
move_to_inside(2111, 'Ристалище');
break;
case 'zamk':
move_to_inside(2601, 'Замковую площадь');
break;
case 'abog':
move_to_inside(2655, 'Арену Богов');
break;
case 'torg':
move_to_inside(2702, 'Торговую улицу');
break;
case 'got':
if ($user['room'] == 20) {
switch ($location[1]) {
case 'level1':
header('location: main.php?setch=1');
die();
break;
case 'level7':
header('location: city.php?strah');
break;
case 'level8':
header('location: city.php?bps');
break;
case 'level13':
header('location: quest_room.php');
break;
case 'level222':
header('location: city.php?torg');
break;
case 'level17':
move_to_outside(50, 'ashop.php');
break;
case 'level2':
move_to_outside(22, 'shop.php');
break;
case 'level4':
move_to_outside(23, 'repair.php');
break;
case 'level10':
move_to_outside(35, 'krshop.php');
break;
case 'level9':
move_to_outside(24, 'elka.php');
break;
case 'level6':
move_to_outside(27, 'post.php');
break;
case 'level3':
move_to_outside(26, 'comission.php');
break;
}
} elseif ($user['room'] == 21) {
switch ($location[1]) {
case 'level4':
header('location: city.php?cp');
break;
case 'level3':
header('location: city.php?zaliv');
break;
case 'level13':
move_to_outside(34, 'fshop.php');
break;
case 'level5':
move_to_outside(29, 'bank.php');
break;
case 'level16':
move_to_outside(31, 'tower.php');
break;
case 'level14':
move_to_outside(30, 'klanedit.php');
break;
case 'level650':
move_to_outside(650, 'ul_clans.php');
break;
}
} elseif ($user['room'] == 2111) {
switch ($location[1]) {
case 'level1':
header('location: city.php?strah');
break;
case 'level2':
header('location: city.php?haos');
break;
case 'level203':
move_to_outside(1055, 'group_arena.php');
break;
case 'level1000':
move_to_outside(620, 'enter_cave.php');
break;
case 'room666':
move_to_outside(666, 'jail.php');
break;
case 'level5':
move_to_outside(203, 'church.php');
break;
}
} elseif ($user['room'] == 2601) {
switch ($location[1]) {
case 'level4':
header('location: city.php?bps');
break;
case 'level55':
header('location: city.php?abog');
break;
case 'level21':
move_to_outside(87, 'dshop.php');
break;
case 'level10':
move_to_outside(35, 'krshop.php');
break;
case 'level44':
move_to_outside(203, 'church.php');
break; /*FIXME Второй вход в церковь?*/
case 'level1':
move_to_outside(37, 'gotzamok.php');
break;
case 'level1052':
move_to_outside(1053, 'repshop.php');
break;
case 'level1051':
move_to_outside(1051, 'lab_enter.php');
break;
case 'level5':
move_to_outside(404, 'vxod.php');
break;
}
} elseif ($user['room'] == 2701) {
switch ($location[1]) {
case 'level1':
header('location: city.php?zaliv');
break;
case 'level2':
move_to_outside(402, 'lab_chaos_enter.php');
break;
}
} elseif ($user['room'] == 2702) {
switch ($location[1]) {
case 'level10':
header('location: city.php?cp');
break;
case 'level5':
move_to_outside(1054, 'fontan_luck.php');
break;
case 'level202':
move_to_outside(1054, 'fontan_luck.php');
break;
case 'level6':
move_to_outside(61, 'akadem.php');
break;
}
} elseif ($user['room'] == 2655) {
switch ($location[1]) {
case 'level10':
header('location: city.php?zamk');
break;
case 'level2055':
move_to_outside(603, 'aren_of_angels.php');
break;
}
} elseif ($user['room'] == 26) {
switch ($location[1]) {
case 'level4':
header('location: city.php?cp');
break;
case 'level3':
header('location: city.php?zamk');
break;
case 'level5':
move_to_outside(43, 'znahar.php');
break;
case 'level660':
move_to_outside(660, 'hostel.php');
break;
case 'level20':
move_to_outside(223, 'bench.php');
break;
case 'level21':
move_to_outside(222, 'bench_s.php');
break;
case 'level22':
move_to_outside(224, 'bench_m.php');
break;
case 'level7':
move_to_outside(777, 'obshaga.php');
break;
case 'level11':
move_to_outside(42, 'lotery.php');
break;
// case 'level5':
// move_to_outside(401, 'hell.php');
// break;
// case 'level6':
// move_to_outside(110, 'jackill.php');
// break;
}
}
break;
2018-03-09 02:13:08 +00:00
}
$online = db::c()->query('SELECT 1 FROM `online` WHERE `real_time` >= ?i', (time() - 60));
2018-01-28 16:40:49 +00:00
?>
<!doctype html>
2018-03-09 02:13:08 +00:00
<html>
<HEAD>
2018-03-09 02:13:08 +00:00
<link rel=stylesheet href="css/main.css">
<link rel="stylesheet" href="/locations/style.css"/>
<meta charset="utf-8">
<style>
img.building:hover {filter:drop-shadow(2px 2px 2px white) sepia(15%);}
</style>
<script type="text/javascript">
function solo(n) {
top.changeroom = n;
window.location.href = 'city.php?got/level' + n;
}
function Down() {
top.CtrlPress = window.event.ctrlKey
}
document.onmousedown = Down;
</script>
</HEAD>
2018-03-09 02:13:08 +00:00
<body>
2018-03-09 12:57:41 +00:00
<table width=100% border=0 cellspacing="0" cellpadding="0">
<TR>
<TD align=center></TD>
<TD align=right>Сейчас в игре : <?= $online->getNumRows() ?> игроков.</TD>
</TR>
<TR>
2018-03-09 02:13:08 +00:00
<TD align=center colspan=2>
<?php
function getSeason()
{
$todayMonth = date('n');
if ($todayMonth >= 3 && $todayMonth <= 5) return 'spring_';
2018-03-09 02:13:08 +00:00
elseif ($todayMonth >= 6 && $todayMonth <= 8) return 'summer_';
2018-03-09 15:19:13 +00:00
elseif ($todayMonth >= 9 && $todayMonth <= 11) return 'autumn_';
2018-03-09 02:13:08 +00:00
else return 'winter_';
}
function buildset_old($id, $img, $top, $left, $des, $noSeason = 0)
{
2018-03-09 02:13:08 +00:00
if (!$noSeason) $img = getSeason() . $img;
?>
<div style="position:absolute; left:<?= $left ?>px; top:<?= $top ?>px; z-index:90; cursor: pointer;">
<img src="i/city/sub/<?= $img ?>.png" alt="<?= $des ?>" title="<?= $des ?>" class="aFilter2"
id="<?= $id ?>"
onmouseover="this.src='i/city/sub/<?= $img ?>2.png'"
onmouseout="this.src='i/city/sub/<?= $img ?>.png'" onclick="solo(<?= $id ?>)"/>
2018-03-09 02:13:08 +00:00
</div>
<?php
}
function buildset($id, $img, $top, $left, $des, $noSeason = 0)
{
if (!$noSeason) $img = getSeason() . $img;
?>
<div style="position:absolute; left:<?= $left ?>px; top:<?= $top ?>px; z-index:90; cursor: pointer;">
<img src="i/city/sub/<?= $img ?>.png" alt="<?= $des ?>" title="<?= $des ?>" class="building"
id="<?= $id ?>" onclick="solo(<?= $id ?>)"/>
</div>
<?php
}
2018-03-09 02:13:08 +00:00
function bgset($img)
{
2018-03-09 02:13:08 +00:00
$daytime = date('H');
if ($daytime >= 6 && $daytime <= 21) $background = getSeason() . $img . '_day';
2018-03-09 02:13:08 +00:00
else $background = getSeason() . $img . '_night';
echo sprintf('<div style="position:relative; display: inline-block;" id="ione"><img src="i/city/%s.jpg">', $background);
2018-03-09 02:13:08 +00:00
/**
* Исходные строки:
* echo "<table width=1><tr><td><div style=\"position:relative; cursor: pointer;\" id=\"ione\"><img src=\"i/city/", $fon, ".jpg\" alt=\"\" border=\"0\"/>";
* echo "</div></td></tr></table>";
*/
}
if ($user['room'] == 20) {
2018-03-09 02:13:08 +00:00
bgset('cap_cp');
2018-03-09 15:37:02 +00:00
buildset(1, "cap_club", 30, 235, "Бойцовский Клуб");
buildset(2, "cap_shop", 202, 171, "Магазин");
buildset(3, "cap_kom", 205, 105, "Комиссионный магазин");
buildset(4, "cap_rem", 202, 290, "Ремонтная мастерская");;
2018-03-09 02:13:08 +00:00
buildset(13, "cap_statue", 222, 365, "Памятник Мэру Города");
2018-03-09 15:37:02 +00:00
buildset(6, "cap_po4ta", 180, 540, "Почта");
buildset(7, "cap_arr_right", 260, 710, "Страшилкина Улица", 1);
buildset(222, "cap_arr_top", 180, 650, "Торговая улица", 1);
2018-03-09 15:27:42 +00:00
buildset(8, "cap_arr_left", 258, 21, "Большая парковая улица",1);
2018-03-09 15:37:02 +00:00
buildset(17, "cap_berezka", 205, 435, "Березка");
2018-03-09 17:04:36 +00:00
buildset(11, "cap_loto", 230, 615, "Лотерея");
//buildset(9, "cap_tree2", 260, 530, "Новогодняя елка");
//buildset(14, "cap_sneg_3", 210, 390, "Снеговик");
2018-03-09 02:13:08 +00:00
echo "</div>";
} elseif ($user['room'] == 21) {
2018-03-09 02:13:08 +00:00
bgset('cap_strash');
buildset(5, "cap_bank", 180, 485, "Банк");;
buildset(14, "cap_registratura", 170, 113, "Регистратура кланов");
buildset(16, "cap_tower", 5, 315, "Башня смерти");
buildset(16555, "cap_tree", 165, 20, "Дерево");
buildset(3, "cap_arr_right", 255, 708, "Ристалище", 1);
2018-03-09 02:13:08 +00:00
buildset(13, "cap_flowershop", 220, 613, "Цветочный магазин");
buildset(4, "cap_arr_left", 258, 21, "Центральная площадь", 1);
2018-03-09 02:13:08 +00:00
echo "</div>";
} elseif ($user['room'] == 26) {
2018-03-09 02:13:08 +00:00
bgset('cap_park');
2018-03-09 17:08:08 +00:00
buildset(6, "cap_gate", 170, 340, "Городские ворота",1);
2018-03-09 02:13:08 +00:00
buildset(660, "cap_vokzal", 163, 43, "Общежитие");
buildset(5, "cap_znah", 195, 538, "Хижина Знахаря");
buildset(21, "cap_2sk", 249, 416, "Средняя скамейка");
buildset(20, "cap_3sk", 250, 630, "Большая скамейка");
buildset(22, "cap_1sk", 228, 490, "Маленькая скамейка");
buildset(3, "cap_arr_left", 259, 27, "Замковая площадь", 1);
buildset(4, "cap_arr_right", 259, 715, "Центральная площадь", 1);
2018-03-09 02:13:08 +00:00
echo "</div>";
} elseif ($user['room'] == 2601) {
2018-03-09 02:13:08 +00:00
bgset('cap_zamk');
buildset(1052, "cap_lavka", 240, 425, "Храмовая лавка");
2018-03-09 17:16:48 +00:00
buildset(10, "ava_post", 240, 300, "Сувенирный магазинчик",1);
2018-03-09 02:13:08 +00:00
buildset(1, "cap_ruins", 166, 48, "Руины Старого замка");
buildset(1051, "cap_lab", 130, 327, "Вход в Лабиринт Хаоса");
buildset(44, "cap_hram", 173, 550, "Храм Древних");
buildset(55, "cap_arr_left", 258, 21, "Арена Богов", 1);
2018-03-09 17:16:48 +00:00
buildset(4, "cap_arr_right", 260, 710, "Большая парковая улица", 1);
2018-03-09 02:13:08 +00:00
echo "</div>";
} elseif ($user['room'] == 2655) {
2018-03-09 02:13:08 +00:00
bgset('ar_e_n');
2018-03-09 15:37:02 +00:00
buildset(2055, "cap_altr_g", 230, 340, "Арена Ангелов");
buildset(2222, "cap_stop", 258, 21, "Проход закрыт", 1);
buildset(10, "arr_right_png", 260, 710, "Замковая площадь", 1);
2018-03-09 02:13:08 +00:00
echo "</div>";
} elseif ($user['room'] == 2111) {
2018-03-09 02:13:08 +00:00
bgset('rist_bg');
buildset(1, "cap_arr_uleft", 240, 30, "Страшилкина Улица", 1);
buildset(2, "cap_arr_right", 245, 708, "Секретный Лабиринт", 1);
2018-03-09 02:13:08 +00:00
buildset(14, "cap_rist_solo", 210, 160, "Вход в Одиночные сражения");
buildset(14, "cap_rist_group", 243, 340, "Вход в Сражение отрядов");
buildset(1000, "av_zamk_rud", 80, 310, "Рудник");
2018-03-09 02:13:08 +00:00
buildset(203, "cap_rist_monstr", 145, 570, "Вход в Груповые сражения");
buildset(21, "angelscastle", 131, 628, "Замок Мэра Города");
2018-03-09 12:57:41 +00:00
echo "</div>";
} elseif ($user['room'] == 2701) {
2018-03-09 12:57:41 +00:00
bgset('arena_bg1');
2018-03-09 15:37:02 +00:00
buildset(1, "cap_3strelka", 260, 30, "Берег Залива");
buildset(2, "cap_shar_dark", 234, 356, "Лабиринт Хаоса");
buildset(3, "cap_stop_png", 260, 720, "Проход закрыт");
2018-03-09 12:57:41 +00:00
echo "</div>";
} elseif ($user['room'] == 2702) {
2018-03-09 12:57:41 +00:00
bgset('cap_torg');
buildset(6, "cap_arenda", 175, 70, "Академия");
buildset(202, "cap_fontan", 210, 350, "Фонтан удачи");
2018-03-09 15:37:02 +00:00
buildset(16, "cap_t_build42", 120, 300, "Аукцион");
2018-03-09 12:57:41 +00:00
buildset(16555, "cap_prokat", 155, 480, "Прокатная лавка");
buildset(21, "cap_lombard", 150, 565, "Ломбард");
buildset(10, "cap_arr_uleft", 259, 25, "Центральная площадь", 1);
buildset(3, "cap_stop", 259, 720, "Проход закрыт", 1);
2018-03-09 12:57:41 +00:00
echo "</div>";
}
?>
</td>
</tr>
2018-01-28 16:40:49 +00:00
</table>
<script language="javascript" src="js/refreshonline.js"></script>
</body>
</html>