2022-12-30 19:03:37 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
2023-01-10 16:29:32 +00:00
|
|
|
|
* Вызов ботов в игровые комнаты.
|
2022-12-30 19:03:37 +00:00
|
|
|
|
*
|
2023-01-10 16:29:32 +00:00
|
|
|
|
* Запуск раз в минуту.
|
2022-12-30 19:03:37 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
use Core\Db;
|
|
|
|
|
|
|
|
|
|
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'autoload.php';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function makeLogin(int $id, string $login, int $level): string
|
|
|
|
|
{
|
|
|
|
|
return <<<HTML
|
|
|
|
|
<strong>$login</strong> [$level]
|
|
|
|
|
<a target='_blank' href='inf.php?$id'>
|
2023-03-31 18:30:14 +00:00
|
|
|
|
<img src=//img.new-combats.tech/i/inf_capitalcity.gif alt='inf'>
|
2022-12-30 19:03:37 +00:00
|
|
|
|
</a>
|
|
|
|
|
HTML;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-10 16:29:32 +00:00
|
|
|
|
function testMonster(array $mon): bool // ЧТО ТЫ БЛЯТЬ ТАКОЕ? ЧТО ТЫ ПРОВЕРЯЕШЬ? КАК ТЫ РАБОТАЕШЬ?
|
2022-12-30 19:03:37 +00:00
|
|
|
|
{
|
|
|
|
|
return
|
|
|
|
|
(
|
|
|
|
|
$mon['back_day'] === -1 ||
|
|
|
|
|
(
|
|
|
|
|
$mon['back_day'] === 7 ||
|
|
|
|
|
$mon['back_day'] === idate('w')
|
|
|
|
|
) &&
|
|
|
|
|
$mon['back_day'] === 7
|
|
|
|
|
) &&
|
|
|
|
|
(
|
|
|
|
|
$mon['back_dd'] === -1 ||
|
|
|
|
|
$mon['back_dd'] === idate('j')
|
|
|
|
|
) &&
|
|
|
|
|
(
|
|
|
|
|
$mon['back_mm'] === -1 ||
|
|
|
|
|
$mon['back_mm'] === idate('n')
|
|
|
|
|
) &&
|
|
|
|
|
(
|
|
|
|
|
$mon['back_hh'] === -1 ||
|
|
|
|
|
$mon['back_hh'] === idate('H') &&
|
|
|
|
|
(
|
|
|
|
|
$mon['back_min'] === -1 ||
|
|
|
|
|
$mon['back_min'] >= idate('i')
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$rows = Db::getRows('select * from users left join stats on users.id = stats.id where no_ip = \'trupojor\' limit 100');
|
|
|
|
|
|
|
|
|
|
foreach ($rows as $row) {
|
|
|
|
|
$act = 0;
|
|
|
|
|
if ($row['online'] < time() - 60) {
|
|
|
|
|
$row['online'] = time();
|
|
|
|
|
Db::sql('update users set online = ? where id = ?', [$row['online'], $row['id']]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$mon = Db::getRow('select * from aaa_monsters where uid = ?', [$row['id']]);
|
|
|
|
|
|
|
|
|
|
if ($row['res_x'] < time()) {
|
2023-01-10 16:29:32 +00:00
|
|
|
|
if (isset($mon['id'])) { //если бот в специальном списке
|
|
|
|
|
// если бот спрятан в домике (303) - выпускаем и лечим его
|
2022-12-30 19:03:37 +00:00
|
|
|
|
if (testMonster($mon) && $row['room'] == 303) {
|
|
|
|
|
Db::sql('update users set room = ? where id = ?', [$mon['start_room'], $row['id']]);
|
|
|
|
|
Db::sql('update stats set hpNow = hpAll, mpNow = mpAll where id = ?', [$row['id']]);
|
|
|
|
|
if ($mon['start_text']) {
|
2023-01-10 16:29:32 +00:00
|
|
|
|
$str = '<span style="color: red">Внимание!</span> ';
|
2022-12-30 19:03:37 +00:00
|
|
|
|
$str .= str_replace('{b}', makeLogin($row['id'], $row['login'], $row['level']), $mon['start_text']);
|
|
|
|
|
Db::sql(
|
|
|
|
|
'insert into chat (text, city, type, new, time) values (?,?,6,1,unix_timestamp())',
|
|
|
|
|
[$str, $row['city']]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
$act = 1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//+1hour
|
|
|
|
|
Db::sql('update stats set res_x = unix_timestamp() + 3600 where id = ?', [$row['id']]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
$act == 0 &&
|
|
|
|
|
$row['room'] != 303 &&
|
|
|
|
|
$row['battle'] == 0 &&
|
|
|
|
|
isset($mon['id']) &&
|
|
|
|
|
testMonster($mon)
|
|
|
|
|
) {
|
2023-01-10 16:29:32 +00:00
|
|
|
|
// если бот не в домике, отпраляем в домик (303).
|
2022-12-30 19:03:37 +00:00
|
|
|
|
Db::sql('update users set room = 303 where id = ?', [$row['id']]);
|
|
|
|
|
if ($mon['back_text']) {
|
2023-01-10 16:29:32 +00:00
|
|
|
|
$str = '<span style="color: red">Внимание!</span> ';
|
2022-12-30 19:03:37 +00:00
|
|
|
|
$str .= str_replace('{b}', makeLogin($row['id'], $row['login'], $row['level']), $mon['back_text']);
|
|
|
|
|
Db::sql(
|
|
|
|
|
'insert into chat (text, city, type, new, time)
|
|
|
|
|
values
|
|
|
|
|
(?,?,6,1,unix_timestamp()),
|
|
|
|
|
(?,?,1,1,unix_timestamp())',
|
|
|
|
|
[$str, $row['city'], $str, $row['city']]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
$act = 2;
|
|
|
|
|
}
|
|
|
|
|
sleep(1);
|
|
|
|
|
}
|