81 lines
2.0 KiB
PHP
81 lines
2.0 KiB
PHP
<?php
|
||
|
||
use Core\Db;
|
||
|
||
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'autoload.php';
|
||
|
||
/**
|
||
* Что-то для квестов.
|
||
* Вызов раз в час
|
||
*/
|
||
|
||
$data = Db::getRows('select id, battle, room from users where `real` = 1');
|
||
foreach ($data as $row) {
|
||
$bot_kill = [];
|
||
$delete = '';
|
||
|
||
$qp = Db::getColumn(
|
||
'select vars from actions where uid = ? and vars like ? and vals = ?',
|
||
[
|
||
$row['id'],
|
||
'%start_quest%',
|
||
'go',
|
||
]
|
||
);
|
||
|
||
foreach ($qp as $item) {
|
||
$qst_id = str_replace('start_quest', '', $item);
|
||
$qst = Db::getValue('select act_date from quests where id = ?', [$qst_id]);
|
||
if (!$qst) {
|
||
continue;
|
||
}
|
||
$act = explode(':|:', $qst);
|
||
foreach ($act as $item2) {
|
||
$act2 = explode(':=:', $item2);
|
||
$bots = explode(',', $act2[1]);
|
||
foreach ($bots as $item3) {
|
||
$bot = explode('=', $item3);
|
||
$bot_kill[$bot[0]] = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
$wp = Db::getRows(
|
||
'select id, vars from actions where uid = ? and (vars like ? or vars like ? or vars like ?)',
|
||
[
|
||
$row['id'],
|
||
'win_bot_%',
|
||
'lose_bot_%',
|
||
'nich_bot_%',
|
||
]
|
||
);
|
||
|
||
foreach ($wp as $item) {
|
||
$wlb = str_replace(['win_bot_', 'lose_bot_', 'nich_bot_',], '', $item);
|
||
if ($bot_kill[$wlb]) {
|
||
continue;
|
||
}
|
||
$delete .= "or id = $item";
|
||
}
|
||
|
||
$delete = ltrim($delete, 'or ');
|
||
if (!empty($delete)) {
|
||
$query = 'delete from actions where ' . $delete;
|
||
Db::sql($query);
|
||
}
|
||
|
||
if ($row['battle'] !== 0) {
|
||
continue;
|
||
}
|
||
Db::sql(
|
||
'delete from actions where uid = ? and (vars like ? or vars like ? or vars like ? and room != ?)',
|
||
[
|
||
$row['id'],
|
||
'%use_priem_%',
|
||
'%animal_use%',
|
||
'%takeit_%',
|
||
$row['room'],
|
||
]
|
||
);
|
||
}
|