81 lines
2.6 KiB
PHP
81 lines
2.6 KiB
PHP
<?php
|
|
|
|
use Core\Db;
|
|
|
|
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'autoload.php';
|
|
|
|
/**
|
|
* Ñêðèïò îòâå÷àåò çà ÷èñòêó ïåùåð êîòîðûå íå èñïîëüçóþòñÿ èãðîêîì â òå÷åíèè 3 ÷àñîâ
|
|
* ïðè ó÷åòå ÷òî ïåùåðå áîëüøå 5 ÷àñîâ îò âðåìåíè ñîçäàíèÿ.
|
|
*
|
|
* Çàïóñê ðàç â ìèíóòó.
|
|
* (3 ÷àñà îôôëàéíà íà 5 ÷àñîâ ñóùåñòâîâàíèÿ, çà÷åì òóò ïîìèíóòêà?)
|
|
*/
|
|
|
|
# Âûáèðàåì ïåùåðó (ÈÄ, ÃÎÐÎÄ), ãäå:
|
|
# Èãðîê â ïåùåðå
|
|
# Èãðîê îôôëàéí áîëåå 3õ ÷àñîâ
|
|
# Ïåùåðà çàïóùåíà áîëåå 3õ ÷àñîâ íàçàä
|
|
# Âðåìÿ ïåùåðû âûøëî (?!)
|
|
# ??? 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;
|
|
}
|
|
# [1] Âûêèäûâàåì èãðîêîâ ñ ïîäçåìåëüÿ è ïåðåìåùàåì åãî â `382` ïîäâàëüíîå ïîìåùåíèå
|
|
|
|
$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']]);
|
|
# Âûáðîñèëè èãðîêà ñ ïîäçåìåëüÿ è ïåðåìåñòèëè â ïîäâàëüíîå ïîìåùåíèå
|
|
Db::sql(
|
|
'update users set room = ? where id in (select id from stats where dnow = ? limit 10)',
|
|
[$podvalRoom, $dungeon['did']]
|
|
);
|
|
# Âûáðàñûâàåì ïåùåðíûå ïðåäìåòû ó èãðîêà
|
|
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']]
|
|
);
|
|
|
|
# [2] Óäàëÿåì îáúåêòû.
|
|
Db::sql('delete from dungeon_obj where for_dn = 0 and dn = ?', [$dungeon['did']]);
|
|
|
|
# [3] Óäàëÿåì ìîíñòðîâ.
|
|
Db::sql('delete from dungeon_bots where for_dn = 0 and dn = ?', [$dungeon['did']]);
|
|
|
|
# [4] Óäàëÿåì ïðåäìåòû.
|
|
Db::sql('delete from dungeon_items where for_dn = 0 and dn = ?', [$dungeon['did']]);
|
|
|
|
# [5] Óäàëÿåì äåéñòâèÿ (actions)
|
|
Db::sql('delete from dungeon_actions where dn = ?', [$dungeon['did']]);
|
|
|
|
# [6] Çàêðûâàåì Ïîäçåìåëüå Dungeon_Now - time_finish = time();
|
|
Db::sql('update dungeon_now set time_finish = unix_timestamp() where id = ?', [$dungeon['did']]);
|
|
}
|