game/_incl_data/crons/bot_calls.php

110 lines
3.5 KiB
PHP
Raw Normal View History

2022-12-30 19:03:37 +00:00
<?php
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
*
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
*/
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>&nbsp;[$level]&nbsp;
<a target='_blank' href='inf.php?$id'>
<img src=https://img.new-combats.com/i/inf_capitalcity.gif alt='inf'>
</a>
HTML;
}
function testMonster(array $mon): bool // <20><><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>? <20><><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? <20><><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
{
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()) {
if (isset($mon['id'])) { //<2F><><EFBFBD><EFBFBD> <20><><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (303) - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>
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']) {
$str = '<span style="color: red"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!</span> ';
$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)
) {
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> (303).
Db::sql('update users set room = 303 where id = ?', [$row['id']]);
if ($mon['back_text']) {
$str = '<span style="color: red"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!</span> ';
$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);
}