2022-12-30 19:03:37 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use Core\Db;
|
|
|
|
|
|
|
|
|
|
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'autoload.php';
|
|
|
|
|
|
|
|
|
|
/**
|
2023-01-10 16:29:32 +00:00
|
|
|
|
* Скрипт отвечает за чистку пещер которые не используются игроком в течении 3 часов
|
|
|
|
|
* при учете что пещере больше 5 часов от времени создания.
|
2022-12-30 19:03:37 +00:00
|
|
|
|
*
|
2023-01-10 16:29:32 +00:00
|
|
|
|
* Запуск раз в минуту.
|
|
|
|
|
* (3 часа оффлайна на 5 часов существования, зачем тут поминутка?)
|
2022-12-30 19:03:37 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2023-01-10 16:29:32 +00:00
|
|
|
|
# Выбираем пещеру (ИД, ГОРОД), где:
|
|
|
|
|
# Игрок в пещере
|
|
|
|
|
# Игрок оффлайн более 3х часов
|
|
|
|
|
# Пещера запущена более 3х часов назад
|
|
|
|
|
# Время пещеры вышло (?!)
|
2022-12-30 19:03:37 +00:00
|
|
|
|
# ??? bsid
|
|
|
|
|
|
|
|
|
|
$dungeons = Db::getRows(
|
|
|
|
|
'
|
|
|
|
|
select
|
|
|
|
|
dungeon_now.city,
|
|
|
|
|
dungeon_now.id as did
|
|
|
|
|
from
|
|
|
|
|
dungeon_now
|
|
|
|
|
left join users on dungeon_now.id = users.id
|
|
|
|
|
left join stats on dungeon_now.id = stats.id
|
|
|
|
|
where
|
|
|
|
|
stats.dnow > 0 and
|
|
|
|
|
users.online < unix_timestamp() - 10800 and
|
|
|
|
|
dungeon_now.time_start < unix_timestamp() - 10800 and
|
|
|
|
|
dungeon_now.time_finish = 0 and
|
|
|
|
|
dungeon_now.bsid = 0
|
|
|
|
|
group by dungeon_now.id order by dungeon_now.id desc
|
|
|
|
|
'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
foreach ($dungeons as $dungeon) {
|
|
|
|
|
if (!$dungeon['did'] || $dungeon['did'] === 15) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2023-01-10 16:29:32 +00:00
|
|
|
|
# [1] Выкидываем игроков с подземелья и перемещаем его в `382` подвальное помещение
|
2022-12-30 19:03:37 +00:00
|
|
|
|
|
|
|
|
|
$podvalRoom = 382;
|
|
|
|
|
if ($dungeon['city'] === 'capitalcity') {
|
|
|
|
|
$podvalRoom = 321;
|
|
|
|
|
} elseif ($dungeon['city'] === 'angelscity') {
|
|
|
|
|
$podvalRoom = 242;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Db::sql('update stats set dnow = 0 where id in (select id from stats where dnow = ? limit 10)', [$dungeon['did']]);
|
2023-01-10 16:29:32 +00:00
|
|
|
|
# Выбросили игрока с подземелья и переместили в подвальное помещение
|
2022-12-30 19:03:37 +00:00
|
|
|
|
Db::sql(
|
|
|
|
|
'update users set room = ? where id in (select id from stats where dnow = ? limit 10)',
|
|
|
|
|
[$podvalRoom, $dungeon['did']]
|
|
|
|
|
);
|
2023-01-10 16:29:32 +00:00
|
|
|
|
# Выбрасываем пещерные предметы у игрока
|
2022-12-30 19:03:37 +00:00
|
|
|
|
Db::sql(
|
|
|
|
|
'update items_users set `delete` = unix_timestamp() where dn_delete = 1 and uid in (select id from stats where dnow = ? limit 10)',
|
|
|
|
|
[$dungeon['did']]
|
|
|
|
|
);
|
|
|
|
|
|
2023-01-10 16:29:32 +00:00
|
|
|
|
# [2] Удаляем объекты.
|
2022-12-30 19:03:37 +00:00
|
|
|
|
Db::sql('delete from dungeon_obj where for_dn = 0 and dn = ?', [$dungeon['did']]);
|
|
|
|
|
|
2023-01-10 16:29:32 +00:00
|
|
|
|
# [3] Удаляем монстров.
|
2022-12-30 19:03:37 +00:00
|
|
|
|
Db::sql('delete from dungeon_bots where for_dn = 0 and dn = ?', [$dungeon['did']]);
|
|
|
|
|
|
2023-01-10 16:29:32 +00:00
|
|
|
|
# [4] Удаляем предметы.
|
2022-12-30 19:03:37 +00:00
|
|
|
|
Db::sql('delete from dungeon_items where for_dn = 0 and dn = ?', [$dungeon['did']]);
|
|
|
|
|
|
2023-01-10 16:29:32 +00:00
|
|
|
|
# [5] Удаляем действия (actions)
|
2022-12-30 19:03:37 +00:00
|
|
|
|
Db::sql('delete from dungeon_actions where dn = ?', [$dungeon['did']]);
|
|
|
|
|
|
2023-01-10 16:29:32 +00:00
|
|
|
|
# [6] Закрываем Подземелье Dungeon_Now - time_finish = time();
|
2022-12-30 19:03:37 +00:00
|
|
|
|
Db::sql('update dungeon_now set time_finish = unix_timestamp() where id = ?', [$dungeon['did']]);
|
|
|
|
|
}
|