Рефакторинг, отказ от $u->testAction('',2) для разрыва зависимости с User::class. Добавлен зачаточный генератор запросов.

This commit is contained in:
Ivor Barhansky 2024-05-14 17:24:54 +03:00
parent 7b8ffdfd6a
commit bc136cc030
11 changed files with 802 additions and 742 deletions

View File

@ -1,6 +1,7 @@
<?php <?php
use Helper\Conversion; use Helper\Conversion;
use Model\ActionModel;
use Model\Constant\Stat; use Model\Constant\Stat;
class BotPriemLogic class BotPriemLogic
@ -105,7 +106,6 @@ class BotPriemLogic
private static function testpriem($pl): int private static function testpriem($pl): int
{ {
global $u;
$notr = 0; $notr = 0;
$statnames = new Stat(); $statnames = new Stat();
$statnames->getRequirement(); $statnames->getRequirement();
@ -125,8 +125,8 @@ class BotPriemLogic
} }
if ($pl['xuse'] > 0) { if ($pl['xuse'] > 0) {
$xu = $u->testAction('`vars` = "use_priem_' . BotLogic::$bot['battle'] . '_' . BotLogic::$bot['id'] . '" AND `vals` = "' . $pl['id'] . '" LIMIT ' . $pl['xuse'] . '', 2); $xu = ActionModel::testCount(['vars = ' . 'use_priem_' . BotLogic::$bot['battle'] . '_' . BotLogic::$bot['id'], "vals = {$pl['id']}",], $pl['xuse']);
if ($xu[0] >= $pl['xuse']) { if ($xu >= $pl['xuse']) {
$notr++; $notr++;
} }
} }

View File

@ -2,6 +2,7 @@
use Core\Db; use Core\Db;
use Helper\Conversion; use Helper\Conversion;
use Model\ActionModel;
use User\ItemsModel; use User\ItemsModel;
use User\Stats; use User\Stats;
@ -413,7 +414,7 @@ class Dungeon
if ($usr_real['clan'] > 0) { if ($usr_real['clan'] > 0) {
$usrreal .= '<img src=//img.new-combats.tech/i/clan/' . $usr_real['clan'] . '.gif width=24 height=15 >'; $usrreal .= '<img src=//img.new-combats.tech/i/clan/' . $usr_real['clan'] . '.gif width=24 height=15 >';
} }
$usrreal .= '<b>' . $usr_real['login'] . '</b>[' . $usr_real['level'] . ']<a target=_blank href=/info/' . $usr_real['id'] . ' ><img width=12 hiehgt=11 src=//img.new-combats.tech/i/inf_capitalcity.gif ></a>'; $usrreal .= '<b>' . $usr_real['login'] . '</b>[' . $usr_real['level'] . ']<a target=_blank href=/info/' . $usr_real['id'] . ' ><img width=12 heihgt=11 src=//img.new-combats.tech/i/inf_capitalcity.gif ></a>';
} else { } else {
$mereal = '<i>Невидимка</i>[??]'; $mereal = '<i>Невидимка</i>[??]';
} }
@ -425,7 +426,7 @@ class Dungeon
if ($me_real['clan'] > 0) { if ($me_real['clan'] > 0) {
$mereal .= '<img src=//img.new-combats.tech/i/clan/' . $me_real['clan'] . '.gif width=24 height=15 >'; $mereal .= '<img src=//img.new-combats.tech/i/clan/' . $me_real['clan'] . '.gif width=24 height=15 >';
} }
$mereal .= '<b>' . $me_real['login'] . '</b>[' . $me_real['level'] . ']<a target=_blank href=/info/' . $me_real['id'] . ' ><img width=12 hiehgt=11 src=//img.new-combats.tech/i/inf_capitalcity.gif ></a>'; $mereal .= '<b>' . $me_real['login'] . '</b>[' . $me_real['level'] . ']<a target=_blank href=/info/' . $me_real['id'] . ' ><img width=12 heihgt=11 src=//img.new-combats.tech/i/inf_capitalcity.gif ></a>';
} else { } else {
$mereal = '<i>Невидимка</i>[??]'; $mereal = '<i>Невидимка</i>[??]';
} }
@ -540,7 +541,7 @@ class Dungeon
if ($usr_real['clan'] > 0) { if ($usr_real['clan'] > 0) {
$usrreal .= '<img src=//img.new-combats.tech/i/clan/' . $usr_real['clan'] . '.gif width=24 height=15 >'; $usrreal .= '<img src=//img.new-combats.tech/i/clan/' . $usr_real['clan'] . '.gif width=24 height=15 >';
} }
$usrreal .= '<b>' . $usr_real['login'] . '</b>[' . $usr_real['level'] . ']<a target=_blank href=/info/' . $usr_real['id'] . ' ><img width=12 hiehgt=11 src=//img.new-combats.tech/i/inf_capitalcity.gif ></a>'; $usrreal .= '<b>' . $usr_real['login'] . '</b>[' . $usr_real['level'] . ']<a target=_blank href=/info/' . $usr_real['id'] . ' ><img width=12 heihgt=11 src=//img.new-combats.tech/i/inf_capitalcity.gif ></a>';
} else { } else {
$mereal = '<i>Невидимка</i>[??]'; $mereal = '<i>Невидимка</i>[??]';
} }
@ -552,7 +553,7 @@ class Dungeon
if ($me_real['clan'] > 0) { if ($me_real['clan'] > 0) {
$mereal .= '<img src=//img.new-combats.tech/i/clan/' . $me_real['clan'] . '.gif width=24 height=15 >'; $mereal .= '<img src=//img.new-combats.tech/i/clan/' . $me_real['clan'] . '.gif width=24 height=15 >';
} }
$mereal .= '<b>' . $me_real['login'] . '</b>[' . $me_real['level'] . ']<a target=_blank href=/info/' . $me_real['id'] . ' ><img width=12 hiehgt=11 src=//img.new-combats.tech/i/inf_capitalcity.gif ></a>'; $mereal .= '<b>' . $me_real['login'] . '</b>[' . $me_real['level'] . ']<a target=_blank href=/info/' . $me_real['id'] . ' ><img width=12 heihgt=11 src=//img.new-combats.tech/i/inf_capitalcity.gif ></a>';
} else { } else {
$mereal = '<i>Невидимка</i>[??]'; $mereal = '<i>Невидимка</i>[??]';
} }
@ -876,7 +877,7 @@ class Dungeon
$i = count($a); $i = count($a);
} }
} elseif ($s[0] == 'repl_ptp') { } elseif ($s[0] == 'repl_ptp') {
require_once('dnaction/_dungeon_replace.php'); require_once 'dnaction/_dungeon_replace.php';
die(); die();
} elseif ($s[0] == 'add_eff') { } elseif ($s[0] == 'add_eff') {
//Кастуем эффект //Кастуем эффект
@ -884,16 +885,10 @@ class Dungeon
$j = 0; $j = 0;
while ($j < count($t)) { while ($j < count($t)) {
$itm = explode('=', $t[$j]); $itm = explode('=', $t[$j]);
$ch = $u->testAction(
'`vars` = "add_eff_' . $this->info['id'] . '_' . $obj['id'] . '" AND `uid` = "' . $this->userinfo['id'] . '" LIMIT ' . (1 + (int)$itm[2]) . '', $ch = ActionModel::testCount(["uid = {$this->userinfo['id']}", "vars = add_eff_{$this->info['id']}_{$obj['id']}"], 1 + (int)$itm[2]); //кол-во прошлых попыток
2 $ch2 = ActionModel::testCount(["vars = add_eff_{$this->info['id']}_{$obj['id']}"], 1 + (int)$itm[4]); //кол-во прошлых попыток (все юзеры)
); //кол-во прошлых попыток
$ch = $ch[0];
$ch2 = $u->testAction(
' `vars` = "add_eff_' . $this->info['id'] . '_' . $obj['id'] . '" LIMIT ' . (1 + (int)$itm[4]) . '',
2
); //кол-во прошлых попыток (все юзеры)
$ch2 = $ch2[0];
if (($ch2 < $itm[4] || $itm[4] == 0) && $ch < $itm[2]) { if (($ch2 < $itm[4] || $itm[4] == 0) && $ch < $itm[2]) {
if ($itm[1] * 100 >= rand(0, 10000)) { if ($itm[1] * 100 >= rand(0, 10000)) {
//удачно //удачно
@ -936,11 +931,8 @@ class Dungeon
$t = explode(',', $s[1]); $t = explode(',', $s[1]);
while ($j < count($t)) { while ($j < count($t)) {
$itm = explode('=', $t[$j]); $itm = explode('=', $t[$j]);
$ch = $u->testAction( $ch = ActionModel::testCount(["vars = bafit_{$this->info['id']}_{$obj['id']}"], 1 + (int)$itm[2]); //кол-во прошлых попыток
'`vars` = "bafit_' . $this->info['id'] . '_' . $obj['id'] . '" LIMIT ' . (1 + (int)$itm[2]) . '',
2
); //кол-во прошлых попыток
$ch = $ch[0];
if ($ch < $itm[3]) { if ($ch < $itm[3]) {
if ($itm[2] * 1000 >= rand(1, 100000)) { if ($itm[2] * 1000 >= rand(1, 100000)) {
if ($itm[0] == 'hpNow') { if ($itm[0] == 'hpNow') {
@ -1026,11 +1018,8 @@ class Dungeon
$t = explode(',', $s[1]); $t = explode(',', $s[1]);
while ($j < count($t)) { while ($j < count($t)) {
$itm = explode('=', $t[$j]); $itm = explode('=', $t[$j]);
$ch = $u->testAction( $ch = ActionModel::testCount(["uid = {$this->userinfo['id']}", "vars = takeit_{$this->info['id']}_{$obj['id']}"], 1 + (int)$itm[2]); //кол-во прошлых попыток
'`uid` = "' . $this->userinfo['id'] . '" AND `vars` = "takeit_' . $this->info['id'] . '_' . $obj['id'] . '" LIMIT ' . (1 + (int)$itm[2]) . '',
2
); //кол-во прошлых попыток
$ch = $ch[0];
if ($ch >= $itm[2]) { if ($ch >= $itm[2]) {
//закончились попытки //закончились попытки
$r = 'ничего не произошло...<br>'; $r = 'ничего не произошло...<br>';
@ -1050,9 +1039,8 @@ class Dungeon
); );
if (isset($it['id'])) { if (isset($it['id'])) {
$r .= 'Вы обнаружили предмет &quot;<b>' . $it['name'] . '</b>&quot;.<br>'; $r .= 'Вы обнаружили предмет &quot;<b>' . $it['name'] . '</b>&quot;.<br>';
ItemsModel::addItem( ItemsModel::addItem($it['id'], $this->userinfo['id']);
['uid' => $this->userinfo['id'], 'iid' => $it['id'], 'x' => $this->userinfo['x'], 'y' => $this->userinfo['y'], 'del' => (int)$itm[4]] //ItemsModel::addItem(['uid' => $this->userinfo['id'], 'iid' => $it['id'], 'x' => $this->userinfo['x'], 'y' => $this->userinfo['y'], 'del' => (int)$itm[4]]);
);
} }
} else { } else {
//неудачная попытка //неудачная попытка
@ -1067,16 +1055,11 @@ class Dungeon
} }
} elseif ($s[0] == 'itm1') { } elseif ($s[0] == 'itm1') {
//Добавляем предмет , только 1 предмет из всех и все юзеры могут тоже //Добавляем предмет , только 1 предмет из всех и все юзеры могут тоже
$nj = 0;
$t = explode(',', $s[1]); $t = explode(',', $s[1]);
$j = rand(0, count($t)); $j = rand(0, count($t));
if ($nj == 0) {
$itm = explode('=', $t[$j]); $itm = explode('=', $t[$j]);
$ch = $u->testAction( $ch = ActionModel::testCount(["uid = {$this->userinfo['id']}", "vars = takeit_{$this->info['id']}_{$obj['id']}"], 1 + (int)$itm[2]); //кол-во прошлых попыток
'`uid` = "' . $this->userinfo['id'] . '" AND `vars` = "takeit_' . $this->info['id'] . '_' . $obj['id'] . '" LIMIT ' . (1 + (int)$itm[2]) . '',
2
); //кол-во прошлых попыток
$ch = $ch[0];
if ($ch >= $itm[2]) { if ($ch >= $itm[2]) {
//закончились попытки //закончились попытки
$r .= 'Странно, но ничего не произошло... <br>'; $r .= 'Странно, но ничего не произошло... <br>';
@ -1099,10 +1082,8 @@ class Dungeon
$u->addAction( $u->addAction(
time(), 'takeit_' . $this->info['id'] . '_' . $obj['id'], $this->userinfo['city'] time(), 'takeit_' . $this->info['id'] . '_' . $obj['id'], $this->userinfo['city']
); );
ItemsModel::addItem( ItemsModel::addItem($it['id'], $this->userinfo['id']);
['uid' => $this->userinfo['id'], 'iid' => $it['id'], 'x' => $this->userinfo['x'], 'y' => $this->userinfo['y'], 'del' => (int)$itm[4]] //ItemsModel::addItem(['uid' => $this->userinfo['id'], 'iid' => $it['id'], 'x' => $this->userinfo['x'], 'y' => $this->userinfo['y'], 'del' => (int)$itm[4]]);
);
$nj++;
} }
} else { } else {
//неудачная попытка //неудачная попытка
@ -1112,19 +1093,15 @@ class Dungeon
$r .= 'Вы ничего не нашли ... <br>'; $r .= 'Вы ничего не нашли ... <br>';
} }
} }
}
} elseif ($s[0] == 'itm2') { } elseif ($s[0] == 'itm2') {
//Добавляем предмет , только 1 предмет из всех и только 1 юзер может поднять //Добавляем предмет , только 1 предмет из всех и только 1 юзер может поднять
$nj = 0;
$t = explode(',', $s[1]); $t = explode(',', $s[1]);
$j = rand(0, count($t) - 1); $j = rand(0, count($t) - 1);
if ($nj == 0) {
$itm = explode('=', $t[$j]); $itm = explode('=', $t[$j]);
$ch = $u->testAction( $ch = ActionModel::testCount(["vars = takeit_{$this->info['id']}_{$obj['id']}"], 1 + (int)$itm[2]); //кол-во прошлых попыток
'`vars` = "takeit_' . $this->info['id'] . '_' . $obj['id'] . '" LIMIT ' . (1 + (int)$itm[2]) . '',
2
); //кол-во прошлых попыток
$ch = $ch[0];
if ($ch >= $itm[2]) { if ($ch >= $itm[2]) {
//закончились попытки //закончились попытки
$r .= 'Ничего не произошло... <br>'; $r .= 'Ничего не произошло... <br>';
@ -1147,10 +1124,8 @@ class Dungeon
$u->addAction( $u->addAction(
time(), 'takeit_' . $this->info['id'] . '_' . $obj['id'], $this->userinfo['city'] time(), 'takeit_' . $this->info['id'] . '_' . $obj['id'], $this->userinfo['city']
); );
ItemsModel::addItem( ItemsModel::addItem($it['id'], $this->userinfo['id']);
['uid' => $this->userinfo['id'], 'iid' => $it['id'], 'x' => $this->userinfo['x'], 'y' => $this->userinfo['y'], 'del' => (int)$itm[4]] //ItemsModel::addItem(['uid' => $this->userinfo['id'], 'iid' => $it['id'], 'x' => $this->userinfo['x'], 'y' => $this->userinfo['y'], 'del' => (int)$itm[4]]);
);
$nj++;
} }
} else { } else {
//неудачная попытка //неудачная попытка
@ -1160,13 +1135,12 @@ class Dungeon
$r .= 'Вы ничего не нашли ... <br>'; $r .= 'Вы ничего не нашли ... <br>';
} }
} }
}
} elseif ($s[0] == 'fileact') { } elseif ($s[0] == 'fileact') {
require('dnaction/' . $s[1] . '.php'); require('dnaction/' . $s[1] . '.php');
} }
$i++; $i++;
} }
$r = rtrim($r, '\<br\>'); $r = rtrim($r, '\<br>');
if ($r == '') { if ($r == '') {
$r = 'В этот раз не удалось найти что-либо еще'; $r = 'В этот раз не удалось найти что-либо еще';
} }
@ -1690,7 +1664,7 @@ class Dungeon
} }
$sp = mysql_query('SELECT * FROM `dungeon_now` WHERE `time_finish` = "0" LIMIT 50'); $sp = mysql_query('select * from dungeon_now where time_finish = 0 limit 50');
while ($pl = mysql_fetch_assoc($sp)) { while ($pl = mysql_fetch_assoc($sp)) {
$cn = mysql_fetch_assoc( $cn = mysql_fetch_assoc(
mysql_query('SELECT `id` FROM `stats` WHERE `dnow` = "' . $pl['id'] . '" LIMIT 1') mysql_query('SELECT `id` FROM `stats` WHERE `dnow` = "' . $pl['id'] . '" LIMIT 1')

View File

@ -0,0 +1,68 @@
<?php
namespace Helper;
use Exception;
class QueryBuilder
{
public function __construct(private readonly string $tableName, private string $columns = '*') {}
public function setColumns(string $columns): void
{
$this->columns = $columns;
}
/**
* @throws Exception
*/
public function select(array $filters = [], int $limit = 0): array
{
if (empty($filters)) {
return ['sql' => "select {$this->columns} from {$this->tableName}"];
}
$where = [];
$params = [];
foreach ($filters as $filter) {
[$name, $operation, $value] = explode(' ', $filter, 3);
$placeholder = ":$name";
$value = explode(' ', $value, 3);
if (count($value) === 1) {
$value = $value[0];
if (is_numeric($value)) {
$value = (int)$value;
}
} else {
array_walk_recursive($value, function (&$var) {
if (is_numeric($var)) {
$var = (int)$var;
}
});
if (is_numeric($value[0]) && is_numeric($value[2])) {
$value = match ($value[1]) {
'+' => $value[0] + $value[2],
'-' => $value[0] - $value[2],
'*' => $value[0] * $value[2],
'/' => ($value[2] != 0) ? $value[0] / $value[2] : throw new Exception('Деление на ноль недопустимо.'),
default => throw new Exception('Недопустимый оператор. Допустимы: +, -, *, /.'),
};
} elseif (is_string($value[0])) {
$placeholder = "$value[0] $value[1] :$name";
$value = $value[2];
} elseif (is_string($value[2])) {
$placeholder = "$value[2] $value[1] :$name";
$value = $value[0];
}
}
//todo: но есть ещё форменное скотство, когда в запрос кидают сложные формулы...
$where[] = "$name $operation $placeholder";
$params[$name] = $value;
}
return [
'sql' => "select $this->columns from $this->tableName where " . implode(" and ", $where) . ($limit > 0 ? " limit $limit" : ""),
'binds' => $params,
];
}
}

View File

@ -3,10 +3,13 @@
namespace Model; namespace Model;
use Core\Db; use Core\Db;
use Exception;
use Helper\QueryBuilder;
use User\UserIp; use User\UserIp;
class ActionModel class ActionModel
{ {
private const TABLE_NAME = 'actions';
private int $uid; private int $uid;
public function __construct(int $uid) public function __construct(int $uid)
@ -39,6 +42,32 @@ class ActionModel
return Db::getRows('select * from actions'); return Db::getRows('select * from actions');
} }
public static function deleteById(int $id): void
{
Db::sql('delete from actions where id = ?', [$id]);
}
public static function testCount(array $filters, int $limit = 0): int
{
$query = new QueryBuilder(self::TABLE_NAME, 'count(id)');
try {
$stmt = $query->select($filters, $limit);
return Db::getValue($stmt['sql'], $stmt['binds']);
} catch (Exception $e) {
echo $e->getMessage();
trigger_error(__METHOD__ . ': ' . $e->getMessage(), E_USER_ERROR);
}
}
public static function testCountCustom(string $filter, array $binds, int $limit = 0): int
{
$sql = "select count(id) from actions where $filter";
if ($limit > 0) {
$sql .= ' limit ' . $limit;
}
return (int)Db::getValue($sql, $binds);
}
public function getByVals(string $vals) public function getByVals(string $vals)
{ {
return Db::getRow('select * from actions where uid = ? and vals = ?', [$this->uid, $vals]); return Db::getRow('select * from actions where uid = ? and vals = ?', [$this->uid, $vals]);
@ -65,28 +94,30 @@ class ActionModel
Db::sql('delete from actions where uid = ? and vals = ?', [$this->uid, $vals]); Db::sql('delete from actions where uid = ? and vals = ?', [$this->uid, $vals]);
} }
public static function deleteById(int $id): void public function getDailyQuest(): array
{ {
Db::sql('delete from actions where id = ?', [$id]); $filter = [
"uid = $this->uid",
"vars = 'day_quest'",
];
return self::getAction($filter);
} }
/*protected function testAction($filter, $tp): array public static function getAction(array $filters, int $limit = 1): array
{ {
if ($tp == 1) { $query = new QueryBuilder(self::TABLE_NAME);
$query = 'select * from actions where ' . $filter; try {
} elseif ($tp == 2) { $stmt = $query->select($filters, $limit);
$query = 'select count(*) from actions where ' . $filter; $result = Db::getRows($stmt['sql'], $stmt['binds']);
} else { if (count($result) === 1 || $limit === 1) {
return []; return $result[0];
}
return $result;
} catch (Exception $e) {
echo $e->getMessage();
trigger_error(__METHOD__ . ': ' . $e->getMessage(), E_USER_ERROR);
} }
$arr = mysql_fetch_array(mysql_query($query));
return !empty($arr) ? $arr : [];
}*/
public function getDailyQuest(): array|false
{
return Db::getRow("select * from actions where uid = ? and vars = 'day_quest' limit 1", [$this->uid]);
} }
public function getFinishedDailyQuestTasks(int $timeout): array public function getFinishedDailyQuestTasks(int $timeout): array

View File

@ -5,6 +5,7 @@ use Core\Db;
use DarksLight2\Training\TrainingManager; use DarksLight2\Training\TrainingManager;
use Helper\Conversion; use Helper\Conversion;
use Helper\Math; use Helper\Math;
use Model\ActionModel;
use Model\Constant\Stat; use Model\Constant\Stat;
use User\Effects; use User\Effects;
@ -1088,28 +1089,46 @@ class Priems
return $rr; return $rr;
} }
public function pruse($id) public function pruse($id): void
{ {
global $btl; global $btl;
$u = $this->u; // Для присоедиянемых файлов.
if ($id == 100500 && $this->u->info['animal'] > 0) { if ($id == 100500 && $this->u->info['animal'] > 0) {
$use_lst = $this->u->testAction( $this->processAnimal($btl);
} else {
$this->processPriem($id, $btl);
}
}
private function processAnimal(Battle $btl): void
{
if ($this->u->stats['hpNow'] < 1) {
echo 'Вы не можете выпустить зверя, вы потеряли все НР';
return;
}
$alreadyReleased = $this->u->testAction(
'`uid` = "' . $this->u->info['id'] . '" AND `vars` = "animal_use' . $btl->i->id . '" LIMIT 1', '`uid` = "' . $this->u->info['id'] . '" AND `vars` = "animal_use' . $btl->i->id . '" LIMIT 1',
1 1
); );
if (!isset($use_lst['id'])) {
$a = mysql_fetch_assoc( if (!empty($alreadyReleased['id'])) {
mysql_query( echo 'Вы уже выпускали зверя в этом бою ...';
'SELECT * FROM `users_animal` WHERE `uid` = "' . $this->u->info['id'] . '" AND `id` = "' . $this->u->info['animal'] . '" AND `pet_in_cage` = "0" AND `delete` = "0" LIMIT 1' return;
) }
);
if ($this->u->stats['hpNow'] < 1) { $animal = Db::getRow('select * from users_animal where uid = ? and id = ? and pet_in_cage = 0', [$this->u->info['id'], $this->u->info['animal']]);
echo 'Вы не можете выпустить зверя, вы потеряли все НР';
} elseif (isset($a['id']) && $a['eda'] < 1) { if (!isset($animal['id'])) {
echo 'Вы не накормили зверя...'; echo 'У вас нет зверя.';
} elseif (isset($a['id'])) { return;
//Добавляем зверя в бой }
$tp = [
if ($animal['eda'] < 1) {
echo 'Вы не накормили зверя.';
return;
}
$animalTypes = [
1 => 'Кот', 1 => 'Кот',
2 => 'Сова', 2 => 'Сова',
3 => 'Светляк', 3 => 'Светляк',
@ -1118,246 +1137,200 @@ class Priems
6 => 'Свин', 6 => 'Свин',
7 => 'Дракон', 7 => 'Дракон',
]; ];
$id = mysql_fetch_assoc(
mysql_query( $botLogin = $animalTypes[$animal['type']] . ' [' . $animal['level'] . ']';
'SELECT `id` FROM `test_bot` WHERE `login` = "' . $tp[$a['type']] . ' [' . $a['level'] . ']" LIMIT 1' $botId = Db::getValue('select id from test_bot where login = ?', [$botLogin]);
)
); if (!$botId) {
if (isset($id['id']) && $btl->i->type != 500) { echo 'Системная ошибка: Неизвестный зверь!';
$b = $this->u->addNewbot($id['id'], null, null); return;
if ($b > 0 && $b) {
$a['eda'] -= 4;
if ($a['eda'] < 0) {
$a['eda'] = 0;
} }
$vLog = 'time1=' . time() . '||s1=' . $this->u->info['sex'] . '||t1=' . $this->u->info['team'] . '||login1=' . $this->u->info['login'] . ''; $b = $this->u->addNewbot($botId);
$mas1 = [
if (!$b) {
echo 'Не удалось призвать зверя.';
return;
}
if ($b > 0) {
$animal['eda'] -= 4;
if ($animal['eda'] < 0) {
$animal['eda'] = 0;
}
$logData = [
'time' => time(), 'time' => time(),
'battle' => $btl->i->id, 'battle' => $btl->i->id,
'id_hod' => $btl->hodID, 'id_hod' => $btl->hodID,
'vars' => $vLog, 'vars' => 'time1=' . time() . '||s1=' . $this->u->info['sex'] . '||t1=' . $this->u->info['team'] . '||login1=' . $this->u->info['login'],
'zona1' => '', 'zona1' => '',
'zonb1' => '', 'zonb1' => '',
'zona2' => '', 'zona2' => '',
'zonb2' => '', 'zonb2' => '',
'type' => '1', 'type' => '1',
'text' => '{tm1} {u1} выпустил' . ($this->u->info['sex'] === 1 ? 'a' : '') . " зверя «{$animal['name']}».",
]; ];
Log::add($logData);
$sex = $this->u->info['sex'] === 1 ? 'a' : ''; Db::sql('update users set login = ?, obraz = ?, battle = ? where id = ?', [$animal['name'], $animal['obraz'] . '.gif', $btl->i->id, $b['id']]);
$mas1['text'] = "{tm1} {u1} выпустил$sex зверя &quot;<b>" . $a['name'] . '&quot;</b>'; Db::sql('update stats set team = ? where id = ?', [$this->u->info['team'], $b['id']]);
Log::add($mas1); Db::sql('update users_animal set eda = ? where id = ?', [$animal['eda'], $animal['id']]);
$this->u->addAction(time(), 'animal_use' . $btl->i->id, $animal['level']);
}
}
mysql_query( private function processPriem(int $id, Battle $btl): void
'UPDATE `users` SET `login` = "' . $a['name'] . ' (зверь ' . $this->u->info['login'] . ')",`obraz` = "' . $a['obraz'] . '.gif",`battle` = "' . $btl->i->id . '" WHERE `id` = "' . $b['id'] . '" LIMIT 1' {
); $target = '';
mysql_query( $targetNotEmpty = false;
'UPDATE `stats` SET `team` = "' . $this->u->info['team'] . '" WHERE `id` = "' . $b['id'] . '" LIMIT 1' if ($_SERVER['REQUEST_METHOD'] === 'POST') {
); $target = (string)filter_input(INPUT_POST, 'useon');
mysql_query( $targetNotEmpty = $target && $target !== 'none';
'UPDATE `users_animal` SET `eda` = "' . $a['eda'] . '" WHERE `id` = "' . $a['id'] . '" LIMIT 1'
);
$this->u->addAction(time(), 'animal_use' . $btl->i->id, $a['level']);
} else {
echo 'Не удалось выпустить зверя...';
} }
} else { $cup = false;
//Бот не найден $priemsOnPlayer = explode('|', $this->u->info['priems']);
echo '<br>Не удалось выпустить зверя - он боится...';
}
} else {
//зверь не найден
echo 'У Вас нет зверя ...';
}
} else {
//зверь уже выпущен
echo 'Вы уже выпускали зверя в этом бою ...';
}
} else {
$p = explode('|', $this->u->info['priems']);
$pz = explode('|', $this->u->info['priems_z']); $pz = explode('|', $this->u->info['priems_z']);
if ($p[(int)$id] > 0 && $pz[(int)$id] <= 0 && $this->u->info['hpNow'] >= 1) { if ($priemsOnPlayer[$id] <= 0 || $pz[$id] > 0 || $this->u->info['hpNow'] < 1) {
$pl = mysql_fetch_assoc( return;
mysql_query( }
'SELECT * FROM `priems` WHERE `level`<=' . $this->u->info['level'] . ' AND `id` = ' . $p[(int)$id]
) $priem = Db::getRow('select * from priems where level <= ? and id = ?', [$this->u->info['level'], $priemsOnPlayer['id']]);
);
if (isset($pl['id']) && $pl['activ'] != 1) { if (isset($priem['id']) && $priem['activ'] != 1) {
if ($pl['activ'] == 0) { if ($priem['activ'] == 0) {
unset($pl); unset($priem);
} elseif ($pl['activ'] > 1) { } elseif ($priem['activ'] > 1) {
//Книжный прием //Книжный прием
if ($this->testActiv($pl['activ']) == 0) { if ($this->testActiv($priem['activ']) == 0) {
unset($pl); unset($priem);
} }
} }
} }
if (isset($pl['id'])) {
if (!isset($priem['id'])) {
return;
}
$notr = 0; $notr = 0;
$pl['useon_user'] = $this->u->info['enemy']; $priem['useon_user'] = $this->u->info['enemy'];
if (isset($_POST['useon']) && $_POST['useon'] != '' && $_POST['useon'] != 'none') { if ($targetNotEmpty) {
$this->ue = mysql_fetch_assoc( $this->ue = Db::getRow('select
mysql_query( users.id, login, login2, online, admin, city, cityreg, align, clan, level, money, money3, money4, battle, sex, obraz, win, win_t, lose, lose_t, nich,
'SELECT timeMain, invis, bot_id, animal, type_pers, notrhod, bot_room, inUser, inTurnir, inTurnirnew, stopexp, `real`, stats.*
from users inner join stats on users.id = stats.id where (login = ? or login2 = ?) and (inUser > 0 or (battle = ? and hpNow > 0))
order by users.id desc limit 1', [$target, $target, $btl->i->id]);
`u`.`id`,`u`.`login`,`u`.`login2`,`u`.`online`,`u`.`admin`,`u`.`city`,`u`.`cityreg`,`u`.`align`,`u`.`clan`,
`u`.`level`,`u`.`money`,`u`.`money3`,`u`.`money4`,`u`.`battle`,`u`.`sex`,`u`.`obraz`,`u`.`win`,`u`.`win_t`,
`u`.`lose`,`u`.`lose_t`,`u`.`nich`,`u`.`timeMain`,`u`.`invis`,`u`.`bot_id`,`u`.`animal`,`u`.`type_pers`,
`u`.`notrhod`,`u`.`bot_room`,`u`.`inUser`,`u`.`inTurnir`,`u`.`inTurnirnew`,`u`.`stopexp`,`u`.`real`,
`st`.*
FROM `users` AS `u`
LEFT JOIN `stats` AS `st` ON (`u`.`id`=`st`.`id`)
WHERE (
`u`.`login`="' . mysql_real_escape_string($_POST['useon']) . '" OR
(
`u`.`login2` = "' . mysql_real_escape_string($_POST['useon']) . '" AND
`u`.`login2` != "")
) AND
(
`u`.`inUser` > 0 OR
(
`u`.`battle`="' . $btl->i->id . '" AND
`st`.`hpNow` > 0
)
) ORDER BY `u`.`id` DESC LIMIT 1'
)
);
if (isset($this->ue['id']) && $this->ue['inUser'] > 0) { if (isset($this->ue['id']) && $this->ue['inUser'] > 0) {
$this->ue = mysql_fetch_assoc( $this->ue = Db::getRow('select
mysql_query( users.id, login, login2, online, admin, city, cityreg, align, clan, level, money, money3, money4, battle, sex, obraz, win, win_t, lose, lose_t, nich,
'SELECT timeMain, invis, bot_id, animal, type_pers, notrhod, bot_room, inUser, inTurnir, inTurnirnew, stopexp, `real`, stats.*
from users inner join stats on users.id = stats.id where battle = ? and hpNow > 0 and users.id = ?
`u`.`id`,`u`.`login`,`u`.`login2`,`u`.`online`,`u`.`admin`,`u`.`city`,`u`.`cityreg`,`u`.`align`,`u`.`clan`, order by users.id limit 1', [$btl->i->id, $this->ue['inUser']]);
`u`.`level`,`u`.`money`,`u`.`money3`,`u`.`money4`,`u`.`battle`,`u`.`sex`,`u`.`obraz`,`u`.`win`,`u`.`win_t`,
`u`.`lose`,`u`.`lose_t`,`u`.`nich`,`u`.`timeMain`,`u`.`invis`,`u`.`bot_id`,`u`.`animal`,`u`.`type_pers`,
`u`.`notrhod`,`u`.`bot_room`,`u`.`inUser`,`u`.`inTurnir`,`u`.`inTurnirnew`,`u`.`stopexp`,`u`.`real`,
`st`.*
FROM `users` AS `u`
LEFT JOIN `stats` AS `st` ON (`u`.`id`=`st`.`id`)
WHERE
`u`.`battle`="' . $btl->i->id . '" AND
`st`.`hpNow` > 0) AND
`u`.`id` = "' . $this->ue['inUser'] . '" ORDER BY `u`.`id` ASC LIMIT 1'
)
);
} }
if (!isset($this->ue['id']) && $pl['trUser'] > 0) {
if (!isset($this->ue['id']) && $priem['trUser'] > 0) {
$notr++; $notr++;
} }
if ($pl['team'] == 1) { if ($priem['team'] == 1) {
//свои //свои
if ($this->u->info['team'] != $this->ue['team']) { if ($this->u->info['team'] != $this->ue['team']) {
$notr++; $notr++;
} }
} elseif ($pl['team'] == 2) { } elseif ($priem['team'] == 2) {
//противники //противники
if ($this->u->info['team'] == $this->ue['team']) { if ($this->u->info['team'] == $this->ue['team']) {
$notr++; $notr++;
} }
} }
} else { } else {
$ga = mysql_fetch_assoc( $check = Db::getValue('select count(id) from battle_act where battle = ? and uid1 = ? and uid2 = ?', [$btl->i->id, $this->u->info['id'], $this->u->info['enemy']]) > 0;
mysql_query(
'SELECT * FROM `battle_act` WHERE `battle` = "' . $btl->i->id . '" AND `uid1` = "' . $this->u->info['id'] . '" AND `uid2` = "' . $this->u->info['enemy'] . '" LIMIT 1' if (($this->u->info['enemy'] == 0 || $check) && ($priem['tr_hod'] > 0 || $priem['trUser'] > 0)) {
)
);
if (($this->u->info['enemy'] == 0 || isset($ga['id'])) && ($pl['tr_hod'] > 0 || $pl['trUser'] > 0)) {
$notr++; $notr++;
} }
} }
$notr += $this->testpriem($pl, 1, $this->ue['id']); $notr += $this->testpriem($priem, 1, $this->ue['id']);
if ($this->ue['id'] > 0) { if ($this->ue['id'] > 0) {
$notr += $this->testRazmenOldUser($this->ue['id'], $this->u->info['enemy'], $pl['id']); $notr += $this->testRazmenOldUser($this->ue['id'], $this->u->info['enemy'], $priem['id']);
} }
if ($notr == 0) { if ($notr != 0) {
mysql_query( return;
'UPDATE `stats` SET `last_pr` = "' . $pl['id'] . '" WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1' }
);
Db::sql('update stats set last_pr = ? where id = ?', [$priem['id'], $this->u->info['id']]);
//Приемы на персонажах //Приемы на персонажах
$markuids = [];
if ($this->ue['id'] > 0) { if ($this->ue['id'] > 0) {
$btl->priemsRazmen([$this->u->info['id'], $this->ue['id']], 'fast'); $btl->priemsRazmen([$this->u->info['id'], $this->ue['id']], 'fast');
mysql_query( $markuids[] = $this->ue['id'];
'UPDATE `eff_users` SET `mark` = 1 WHERE `uid` = "' . $this->ue['id'] . '" AND `delete` = 0'
);
} else { } else {
$btl->priemsRazmen([$this->u->info['id'], $this->u->info['enemy']], 'fast'); $btl->priemsRazmen([$this->u->info['id'], $this->u->info['enemy']], 'fast');
mysql_query( $markuids[] = $this->u->info['enemy'];
'UPDATE `eff_users` SET `mark` = 1 WHERE `uid` = "' . $this->u->info['enemy'] . '" AND `delete` = 0'
);
} }
mysql_query( $markuids[] = $this->u->info['id'];
'UPDATE `eff_users` SET `mark` = 1 WHERE `uid` = "' . $this->u->info['id'] . '" AND `delete` = 0'
);
if (file_exists('../../_incl_data/class/Priem/' . $pl['id'] . '.php')) { Db::sql('update eff_users set mark = 1 where uid in (?)', [implode(',', $markuids)]);
require('../../_incl_data/class/Priem/' . $pl['id'] . '.php');
if (file_exists('../../_incl_data/class/Priem/' . $priem['id'] . '.php')) {
$u = $this->u; // Для присоедиянемых файлов.
require_once '../../_incl_data/class/Priem/' . $priem['id'] . '.php';
$this->testDie($this->ue['id']); $this->testDie($this->ue['id']);
} else { } else {
echo 'useSkill' . $pl['id']; echo 'useSkill' . $priem['id'];
} }
if (!isset($cup)) { if ($cup) { // Из подключаемых файлов.
$this->uppz($pl, $id); return;
}
$this->uppz($priem, $id);
//Отнимаем тактики //Отнимаем тактики
//$this->mintr($pl); //$this->mintr($pl);
if ($pl['tr_hod'] > 0) { if ($priem['tr_hod'] > 0) {
$this->trhod($pl); $this->trhod($priem);
} }
if ($pl['id'] != 258) {
if ($pl['cancel_eff'] == '') { if ($priem['id'] != 258) {
$pl['cancel_eff'] = '258'; if ($priem['cancel_eff'] == '') {
$priem['cancel_eff'] = '258';
} else { } else {
$pl['cancel_eff'] .= ',258'; $priem['cancel_eff'] .= ',258';
} }
} }
if ($pl['cancel_eff'] != '') {
if ($priem['cancel_eff'] == '') {
return;
}
$i = 0; $i = 0;
$e = explode(',', $pl['cancel_eff']); $e = explode(',', $priem['cancel_eff']);
while ($i < count($e)) { while ($i < count($e)) {
if ($e[$i] > 0) { if ($e[$i] <= 0) {
if ($e[$i] == 258) { $i++;
$nem = mysql_fetch_assoc( continue;
mysql_query(
'SELECT * FROM `eff_users` WHERE `uid` = "' . $this->u->info['id'] . '" AND `v1` = "priem" AND `v2` = "' . $e[$i] . '" AND `delete` = "0" AND `mark` = 1 LIMIT 1'
)
);
} else {
$nem = mysql_fetch_assoc(
mysql_query(
'SELECT * FROM `eff_users` WHERE `uid` = "' . $this->ue['id'] . '" AND `v1` = "priem" AND `v2` = "' . $e[$i] . '" AND `delete` = "0" AND `mark` = 1 LIMIT 1'
)
);
} }
if ($e[$i] == 258) {
$uid = $this->u->info['id'];
} else {
$uid = $this->ue['id'];
}
$nem = Db::getRow('select * from eff_users where uid = ? and v1 = \'priem\' and v2 = ? and mark = 1 limit 1', [$uid, $e[$i]]);
if (isset($nem['id'])) { if (isset($nem['id'])) {
$nem['priem'] = mysql_fetch_assoc( $nem['priem'] = Db::getRow('select * from priems where id = ?', [$e['id']]);
mysql_query(
'SELECT * FROM `priems` WHERE `id` = "' . $e[$i] . '" LIMIT 1'
)
);
if (isset($nem['id'])) {
$btl->delPriem($nem, $btl->users[$btl->uids[$this->ue['id']]], 500); $btl->delPriem($nem, $btl->users[$btl->uids[$this->ue['id']]], 500);
} }
}
}
$i++; $i++;
} }
} }
}
}
}
}
}
}
//для папки priems
private function testActiv($id) private function testActiv($id)
{ {
@ -1368,11 +1341,8 @@ class Priems
$this->u->info['id'] > 0) { $this->u->info['id'] > 0) {
$r = 1; $r = 1;
} else { } else {
$tst = $this->u->testAction( $test = (bool)Db::getValue("select count(id) from actions where uid = ? and time < unix_timestamp() and vars = 'read' and vals = ?", [$this->u->info['id'], $id]);
'`uid` = "' . $this->u->info['id'] . '" AND `time` < ' . time() . ' AND `vars` = "read" AND `vals` = "' . $id . '" LIMIT 1', if ($test) {
1
);
if (isset($tst['id'])) {
$r = 1; $r = 1;
} }
} }
@ -1428,11 +1398,8 @@ class Priems
if ($pl['xuse'] > 0) { if ($pl['xuse'] > 0) {
$xu = $this->u->testAction( $xu = ActionModel::testCount(["vars = use_priem_{$btl->i->id}_{$this->u->info['id']}", "vals = {$pl['id']}"], $pl['xuse']);
'`vars` = "use_priem_' . $btl->i->id . '_' . $this->u->info['id'] . '" AND `vals` = "' . $pl['id'] . '" LIMIT ' . $pl['xuse'], if ($xu >= $pl['xuse']) {
2
);
if ($xu[0] >= $pl['xuse']) {
$notr++; $notr++;
} }
} }
@ -2046,6 +2013,8 @@ class Priems
} }
} }
//выводим приемы $id - 1 (вне боя), 2 - в бою
/** Одеть приём в слот? /** Одеть приём в слот?
* @param $id * @param $id
* @return void * @return void
@ -2099,8 +2068,6 @@ class Priems
} }
} }
//выводим приемы $id - 1 (вне боя), 2 - в бою
public function getTechniquesInfo(?int $id = null): array public function getTechniquesInfo(?int $id = null): array
{ {
# SELECT * FROM `priems` WHERE `level`<="' . $this->u->info['level'] . '" AND `activ` > "0" AND `id` = "' . $id . '" LIMIT 1 # SELECT * FROM `priems` WHERE `level`<="' . $this->u->info['level'] . '" AND `activ` > "0" AND `id` = "' . $id . '" LIMIT 1
@ -2120,7 +2087,6 @@ class Priems
// ); // );
} }
public function seeMyPriems(): void public function seeMyPriems(): void
{ {
$i = 0; $i = 0;
@ -2243,6 +2209,8 @@ class Priems
return [0 => $lvar, 1 => $pz]; return [0 => $lvar, 1 => $pz];
} }
//Мощность / подавление / сопротивление и т.д.
/** /**
* Генерирует html строку для вставки в JS $("#priems").html(" сюда "); * Генерирует html строку для вставки в JS $("#priems").html(" сюда ");
* @return string * @return string
@ -2337,8 +2305,6 @@ class Priems
return str_replace('"', '\\"', $pr); return str_replace('"', '\\"', $pr);
} }
//Мощность / подавление / сопротивление и т.д.
public function getByCategory(?int $category_id = null) public function getByCategory(?int $category_id = null)
{ {
@ -2437,10 +2403,16 @@ class Priems
); );
} }
/**
* Что-то для подключаемых файлов приёмов.
*
* @param $uid
* @param $mg
* @return bool|mysqli_result|resource
*/
private function rezadEff($uid, $mg) private function rezadEff($uid, $mg)
{ {
global $btl; global $btl;
//$this->rezadEff($this->u->info['id'],'wis_fire_');
$md = ''; $md = '';
$md2 = ''; $md2 = '';
$ex = explode('|', $btl->users[$btl->uids[$uid]]['priems']); $ex = explode('|', $btl->users[$btl->uids[$uid]]['priems']);

View File

@ -2,6 +2,7 @@
use Core\Db; use Core\Db;
use Helper\Conversion; use Helper\Conversion;
use Model\ActionModel;
use User\ItemsModel; use User\ItemsModel;
class Quests class Quests
@ -67,16 +68,18 @@ class Quests
} }
//Сколько раз можно пройти квест //Сколько раз можно пройти квест
if (isset($d['tr_raz'])) { if (isset($d['tr_raz'])) {
$qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" LIMIT ' . $d['tr_raz'], 2); $qlst = ActionModel::testCount(["uid = {$u->info['id']}", "vars = start_quest{$pl['id']}"], $d['tr_raz']);
if ($d['tr_raz'] > 0 && $d['tr_raz'] - $qlst[0] <= 0) { //$qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" LIMIT ' . $d['tr_raz'], 2);
if ($d['tr_raz'] > 0 && $d['tr_raz'] - $qlst <= 0) {
$r = 0; $r = 0;
} }
unset($qlst); unset($qlst);
} }
//Попыток пройти квест //Попыток пройти квест
if (isset($d['tr_raz2'])) { if (isset($d['tr_raz2'])) {
$qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` != "go" AND `vals` != "win" LIMIT ' . $d['tr_raz2'], 2); $qlst = ActionModel::testCount(["uid = {$u->info['id']}", "vars = start_quest{$pl['id']}", "vals != go", "vals != win"], $d['tr_raz2']);
if ($d['tr_raz2'] - $qlst[0] <= 0) { //$qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` != "go" AND `vals` != "win" LIMIT ' . $d['tr_raz2'], 2);
if ($d['tr_raz2'] - $qlst <= 0) {
$r = 0; $r = 0;
} }
unset($qlst); unset($qlst);
@ -212,8 +215,7 @@ class Quests
$bot2 = mysql_fetch_array(mysql_query('SELECT * FROM `test_bot` WHERE `id` = "' . $ex2[0] . '" LIMIT 1')); $bot2 = mysql_fetch_array(mysql_query('SELECT * FROM `test_bot` WHERE `id` = "' . $ex2[0] . '" LIMIT 1'));
if (isset($bot2['id'])) { if (isset($bot2['id'])) {
if (isset($qst['id'])) { if (isset($qst['id'])) {
$x2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time` > ' . $qst['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $ex2[1], 2); $x2 = ActionModel::testCount(["uid = {$u->info['id']}", "vars = win_bot_$ex2[0]", "time > {$qst['time']}"], $ex2[1]);
$x2 = 0 + $x2[0];
} }
if (isset($d['all_kill']) && $d['all_kill'] > 0) { if (isset($d['all_kill']) && $d['all_kill'] > 0) {
$r = $d['all_kill']; $r = $d['all_kill'];
@ -393,15 +395,17 @@ class Quests
if ($d['tr_raz'] == -1) { if ($d['tr_raz'] == -1) {
$t .= 'Сколько еще раз можно выполнить задание: <b><small>бесконечно</small></b><br>'; $t .= 'Сколько еще раз можно выполнить задание: <b><small>бесконечно</small></b><br>';
} else { } else {
$qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" LIMIT ' . $d['tr_raz'], 2); $qlst = ActionModel::testCount(["uid = {$u->info['id']}", "vars = start_quest{$pl['id']}"], $d['tr_raz']);
$t .= 'Сколько раз можно выполнить задание: ' . ($d['tr_raz'] - $qlst[0]) . '<br>'; //$qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" LIMIT ' . $d['tr_raz'], 2);
$t .= 'Сколько раз можно выполнить задание: ' . ($d['tr_raz'] - $qlst) . '<br>';
} }
unset($qlst); unset($qlst);
} }
//Попыток пройти квест //Попыток пройти квест
if (isset($d['tr_raz2'])) { if (isset($d['tr_raz2'])) {
$qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` != "go" AND `vals` != "win" LIMIT ' . $d['tr_raz2'], 2); $qlst = ActionModel::testCount(["uid = {$u->info['id']}", "vars = start_quest{$pl['id']}", "vals != go", "vals != win"], $d['tr_raz2']);
$t .= 'Осталось попыток выполнить задание: ' . ($d['tr_raz2'] - $qlst[0]) . '<br>'; //$qlst = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` != "go" AND `vals` != "win" LIMIT ' . $d['tr_raz2'], 2);
$t .= 'Осталось попыток выполнить задание: ' . ($d['tr_raz2'] - $qlst) . '<br>';
unset($qlst); unset($qlst);
} }
@ -479,28 +483,32 @@ class Quests
//Убить ботов //Убить ботов
if (isset($d['kill_bot'])) { if (isset($d['kill_bot'])) {
$ex = explode(',', $d['kill_bot']);
if (isset($d['all_kill']) && (int)$d['all_kill'] > 0) { if (isset($d['all_kill']) && (int)$d['all_kill'] > 0) {
$x = ''; $x = '';
$ex = explode(',', $d['kill_bot']);
$i = 0; # Количество циклов для каждого типа бота. $i = 0; # Количество циклов для каждого типа бота.
$q = ''; $botid = 0;
$sqlWhere = [];
$sqlParams = [];
while ($i < count($ex)) { while ($i < count($ex)) {
$ex2 = explode('=', $ex[$i]); $ex2 = explode('=', $ex[$i]);
if ($q != '') { $botid = $ex2[0];
$q .= ' OR '; $sqlWhere[] = "(uid = :uid$i and time > :time$i and vars = :vars$i)";
} $sqlParams["uid$i"] = $u->info['id'];
$q .= ' (`uid` = "' . $u->info['id'] . '" AND `time` > ' . $qst['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" )'; $sqlParams["time$i"] = $qst['time'];
$sqlParams["vars$i"] = "win_bot_$ex2[0]";
$i++; $i++;
} }
$x2 = $u->testAction($q, 2); $sqlWhere = implode(' or ', $sqlWhere);
$x2 = $x2[0]; $x2 = ActionModel::testCountCustom($sqlWhere, $sqlParams);
if ($d['all_kill'] < $x2) { if ($d['all_kill'] < $x2) {
$x2 = $d['all_kill']; $x2 = $d['all_kill'];
} }
$bot2 = mysql_fetch_array(mysql_query('SELECT * FROM `test_bot` WHERE `id` = "' . $ex2[0] . '" LIMIT 1'));
if (isset($bot2['id'])) { $botlogin = Db::getValue('select login from test_bot where id = ?', [$botid]);
$x .= '&nbsp; &nbsp; &bull; <b>' . $bot2['login'] . '</b> [' . $x2 . '/' . $d['all_kill'] . ']<br>'; if (isset($botlogin)) {
$x .= '&nbsp; &nbsp; &bull; <b>' . $botlogin . '</b> [' . $x2 . '/' . $d['all_kill'] . ']<br>';
} else { } else {
$x .= '&nbsp; &nbsp; &bull; <b>' . $pl['name'] . '</b> [' . $x2 . '/' . $d['all_kill'] . ']<br>'; $x .= '&nbsp; &nbsp; &bull; <b>' . $pl['name'] . '</b> [' . $x2 . '/' . $d['all_kill'] . ']<br>';
} }
@ -509,13 +517,12 @@ class Quests
while ($i < count($ex)) { while ($i < count($ex)) {
$x2 = 0; $x2 = 0;
$ex2 = explode('=', $ex[$i]); $ex2 = explode('=', $ex[$i]);
$bot2 = mysql_fetch_array(mysql_query('SELECT * FROM `test_bot` WHERE `id` = "' . $ex2[0] . '" LIMIT 1')); $botlogin = Db::getValue('select login from test_bot where id = ?', [$ex2[0]]);
if (isset($bot2['id'])) { if (isset($botlogin)) {
if (isset($qst['id'])) { if (isset($qst['id'])) {
$x2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time` > ' . $qst['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $ex2[1], 2); $x2 = ActionModel::testCount(["uid = {$u->info['id']}", "vars = win_bot_$ex2[0]", "time > {$qst['time']}"], $ex2[1]);
$x2 = 0 + $x2[0];
} }
$x .= '&nbsp; &nbsp; &bull; <b>' . $bot2['login'] . '</b> [' . $x2 . '/' . $ex2[1] . ']<br>'; $x .= '&nbsp; &nbsp; &bull; <b>' . $botlogin . '</b> [' . $x2 . '/' . $ex2[1] . ']<br>';
} }
$i++; $i++;
} }
@ -525,7 +532,7 @@ class Quests
$x = trim($x, ', '); $x = trim($x, ', ');
$t .= 'Убить ботов: <br>' . $x; $t .= 'Убить ботов: <br>' . $x;
} }
unset($x, $ex, $x2, $bot2, $ex2); unset($x, $ex, $x2, $ex2, $botlogin);
} }
//Собрать ресурсы //Собрать ресурсы
@ -585,7 +592,10 @@ class Quests
public function testquest(): void public function testquest(): void
{ {
global $u; global $u;
if ($u->info['battle'] == 0 && $u->room['name'] != 'Башня Смерти') { if ($u->info['battle'] != 0 || $u->room['name'] === 'Башня Смерти') {
return;
}
$sp = mysql_query('SELECT * FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` LIKE "%start_quest%" AND `vals` = "go" LIMIT 100'); $sp = mysql_query('SELECT * FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` LIKE "%start_quest%" AND `vals` = "go" LIMIT 100');
while ($pl2 = mysql_fetch_array($sp)) { while ($pl2 = mysql_fetch_array($sp)) {
@ -614,27 +624,30 @@ class Quests
if (isset($d['kill_bot'])) { if (isset($d['kill_bot'])) {
$ex = explode(',', $d['kill_bot']); $ex = explode(',', $d['kill_bot']);
$ii = 0; // Количество циклов для каждого типа бота. $ii = 0; // Количество циклов для каждого типа бота.
$q = ''; $smth2 = 0; // неизвестное.
$sqlFilter = [];
$sqlParams = [];
while ($ii < count($ex)) { while ($ii < count($ex)) {
$ex2 = explode('=', $ex[$ii]); $ex2 = explode('=', $ex[$ii]);
if ($q != '') { $smth2 = $ex2[1];
$q .= ' OR '; $sqlFilter[] = "(uid = :uid$ii and time > :time$ii and vars = :vars$ii)";
} $sqlParams["uid$ii"] = $u->info['id'];
$q .= ' (`uid` = "' . $u->info['id'] . '" AND `time` > ' . $pl2['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" )'; $sqlParams["time$ii"] = $pl2['time'];
$sqlFilter["vars$ii"] = "win_bot_$ex2[0]";
$ii++; $ii++;
} }
$sqlFilter = implode(' or ', $sqlFilter);
if (isset($d['all_kill']) && $d['all_kill'] > 0) { if (isset($d['all_kill']) && $d['all_kill'] > 0) {
$x2 = $u->testAction($q . ' LIMIT ' . $d['all_kill'], 2); $x2 = ActionModel::testCountCustom($sqlFilter, $sqlParams, $d['all_kill']);
if ($x2[0] < $d['all_kill']) { if ($x2 < $d['all_kill']) {
$g = 0; $g = 0;
} }
} else { } else {
$x2 = $u->testAction($q . ' LIMIT ' . $ex2[1], 2); $x2 = ActionModel::testCountCustom($sqlFilter, $sqlParams, $smth2);
if (!isset($d['all_kill']) && $x2[0] < $ex2[1]) { if (!isset($d['all_kill']) && $x2 < $smth2) {
$g = 0; $g = 0;
} }
} }
unset($x, $ex, $x2, $x3, $bot2, $ex2);
} }
//Собрать ресурсы //Собрать ресурсы
@ -648,9 +661,17 @@ class Quests
if ($g == 1) { if ($g == 1) {
$pl['time'] = $pl2['time']; $pl['time'] = $pl2['time'];
$this->endq($pl['id'], 'win'); $this->endq($pl['id'], 'win');
$this->winQuest($pl); $status = $this->winQuest($u->info['id'], $pl, $pl2['time']);
echo $pl['name']; //Отправляем сообщение в чат
if ($status) {
$chatDto = new ChatMessage();
$chatDto->setRoom($u->info['room']);
$chatDto->setTo($u->info['login']);
$chatDto->setText($status);
$chatDto->setType(5);
(new Chat())->sendMsg($chatDto);
} }
echo $pl['name'];
} }
} }
} }
@ -688,11 +709,14 @@ class Quests
# Функция отвечает за ПРОВЕРКУ на ЗАВЕРШЕНИЕ квестов для ПОДЗЕМОК # Функция отвечает за ПРОВЕРКУ на ЗАВЕРШЕНИЕ квестов для ПОДЗЕМОК
private function winQuest($pl) private function winQuest($uid, $pl, $time): string
{ {
global $u, $c, $magic; global $magic;
if (!isset($pl['id'])) {
return '';
}
if (isset($pl['id'])) {
$d = $this->expl($pl['act_date']); $d = $this->expl($pl['act_date']);
$d = array_merge($d, $this->expl($pl['win_date'])); $d = array_merge($d, $this->expl($pl['win_date']));
@ -710,8 +734,7 @@ class Quests
$i = 0; $i = 0;
while ($i < count($ex)) { while ($i < count($ex)) {
$ex2 = explode('=', $ex[$i]); $ex2 = explode('=', $ex[$i]);
$ex2 = explode('=', $ex[$i]); $x2 = ActionModel::testCount(["uid = $uid", "vars = win_bot_$ex[2]", "time > $time"], $ex2[1]);
$x2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time` > ' . $pl2['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $ex2[1], 2);
ItemsModel::deleteItemsById($ex2[0], $ex2[1]); ItemsModel::deleteItemsById($ex2[0], $ex2[1]);
$i++; $i++;
} }
@ -722,8 +745,7 @@ class Quests
$i = 0; $i = 0;
while ($i < count($ex)) { while ($i < count($ex)) {
$ex2 = explode('=', $ex[$i]); $ex2 = explode('=', $ex[$i]);
$ex2 = explode('=', $ex[$i]); $x2 = ActionModel::testCount(["uid = $uid", "vars = win_bot_$ex[2]", "time > $time"], $ex2[1]);
$x2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time` > ' . $pl2['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $ex2[1], 2);
ItemsModel::deleteItemsById($ex2[0], $ex2[1]); ItemsModel::deleteItemsById($ex2[0], $ex2[1]);
$i++; $i++;
} }
@ -739,9 +761,8 @@ class Quests
$i = 0; $i = 0;
$ex2 = explode('=', $ex[$i]); $ex2 = explode('=', $ex[$i]);
while ($i < $d['all_kill']) { while ($i < $d['all_kill']) {
$x2 = 0; $d['add_rep'] = $d['add_rep'] + (int)$ex2[1];
$d['add_rep'] = $d['add_rep'] + $ex2[1]; $x2 = ActionModel::testCount(["uid = $uid", "vars = win_bot_$ex[2]", "time > $time"], $d['all_kill']);
$x2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time` > ' . $pl2['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $d['all_kill'], 2);
$i++; $i++;
} }
$ii++; $ii++;
@ -750,7 +771,7 @@ class Quests
unset($x, $i, $ii, $ex, $x2, $bot2, $ex2); unset($x, $i, $ii, $ex, $x2, $bot2, $ex2);
if ($pl['city'] != '') { if ($pl['city'] != '') {
$t .= '' . $d['add_rep'] . ' ед. репутации ' . $pl['city'] . ', '; $t .= '' . $d['add_rep'] . ' ед. репутации ' . $pl['city'] . ', ';
$rep = mysql_fetch_array(mysql_query('SELECT * FROM `rep` WHERE `id` = "' . $u->info['id'] . '" LIMIT 1')); $rep = mysql_fetch_array(mysql_query('SELECT * FROM `rep` WHERE `id` = "' . $uid . '" LIMIT 1'));
if ($rep['rep' . $pl['city']] < 24999 && $rep['rep' . $pl['city']] + $d['add_rep'] >= 24999 && $pl['kin'] != 2) { if ($rep['rep' . $pl['city']] < 24999 && $rep['rep' . $pl['city']] + $d['add_rep'] >= 24999 && $pl['kin'] != 2) {
$rep['rep' . $pl['city']] = 24999; $rep['rep' . $pl['city']] = 24999;
@ -763,7 +784,7 @@ class Quests
if (isset($d['add_repizlom'])) { if (isset($d['add_repizlom'])) {
$t .= '' . $d['add_repizlom'] . ' ед. репутации Излома Хаоса, '; $t .= '' . $d['add_repizlom'] . ' ед. репутации Излома Хаоса, ';
$rep = mysql_fetch_array(mysql_query('SELECT * FROM `rep` WHERE `id` = "' . $u->info['id'] . '" LIMIT 1')); $rep = mysql_fetch_array(mysql_query('SELECT * FROM `rep` WHERE `id` = "' . $uid . '" LIMIT 1'));
$rep['repizlom'] += $d['add_repizlom']; $rep['repizlom'] += $d['add_repizlom'];
if ($rep['repizlom'] > 24999) { if ($rep['repizlom'] > 24999) {
$rep['repizlom'] = 24999; $rep['repizlom'] = 24999;
@ -776,7 +797,7 @@ class Quests
$j = explode('=', $d['add_eff']); $j = explode('=', $d['add_eff']);
while ($i < count($j)) { while ($i < count($j)) {
if ($j[$i] > 0) { if ($j[$i] > 0) {
$magic->addEffect($u->info['id'], $j[$i], 1); $magic->addEffect($uid, $j[$i], 1);
} }
$i++; $i++;
} }
@ -784,7 +805,7 @@ class Quests
if (isset($d['add_cr'])) { if (isset($d['add_cr'])) {
$t .= '' . $d['add_cr'] . ' кр., '; $t .= '' . $d['add_cr'] . ' кр., ';
mysql_query('UPDATE `users` SET `money` = `money`+' . $d['add_cr'] . ' WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'); mysql_query('UPDATE `users` SET `money` = `money`+' . $d['add_cr'] . ' WHERE `id` = "' . $uid . '" LIMIT 1');
} }
if ($t != '') { if ($t != '') {
@ -794,19 +815,11 @@ class Quests
} else { } else {
$r = 'Задание <b>' . $pl['name'] . '</b> было успешно выполнено!'; $r = 'Задание <b>' . $pl['name'] . '</b> было успешно выполнено!';
} }
$r = '<small>' . $r . '</small>';
//Отправляем сообщение в чат return "<small>$r</small>";
$chatDto = new ChatMessage();
$chatDto->setCity($u->info['city']);
$chatDto->setRoom($u->info['room']);
$chatDto->setTo($u->info['login']);
$chatDto->setText($r);
$chatDto->setType(5);
(new Chat())->sendMsg($chatDto);
}
} }
public function questCheckEnd($pl) public function questCheckEnd($pl): int
{ {
global $u; global $u;
$quest = mysql_fetch_array(mysql_query('SELECT * FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" ORDER BY `time` DESC LIMIT 1')); $quest = mysql_fetch_array(mysql_query('SELECT * FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" ORDER BY `time` DESC LIMIT 1'));
@ -836,29 +849,31 @@ class Quests
if (isset($d['kill_bot'])) { if (isset($d['kill_bot'])) {
$ex = explode(',', $d['kill_bot']); $ex = explode(',', $d['kill_bot']);
$i = 0; # Количество циклов для каждого типа бота. $i = 0; # Количество циклов для каждого типа бота.
$q = ''; $smth1 = 0; // неизвестно что.
$sqlFilter = [];
$sqlParams = [];
while ($i < count($ex)) { while ($i < count($ex)) {
$ex2 = explode('=', $ex[$i]); $ex2 = explode('=', $ex[$i]);
if ($q != '') { $smth1 = $ex2[1];
$q .= ' OR '; $sqlFilter[] = "(uid = :uid$i and time > :time$i and vars = :vars$i)";
} $sqlParams[":uid$i"] = $u->info['id'];
$q .= ' (`uid` = "' . $u->info['id'] . '" AND `time` > ' . $quest['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" )'; $sqlParams[":time$i"] = $quest['time'];
$sqlParams[":vars$i"] = "win_bot_$ex2[0]";
$i++; $i++;
} }
$sqlFilter = implode(' or ', $sqlFilter);
if (isset($d['all_kill']) && (int)$d['all_kill'] > 0) { if (isset($d['all_kill']) && (int)$d['all_kill'] > 0) {
$x2 = $u->testAction($q, 2); $x2 = ActionModel::testCountCustom($sqlFilter, $sqlParams);
if ((int)$d['all_kill'] <= $x2[0]) { if ((int)$d['all_kill'] <= $x2) {
$x2 = (int)$d['all_kill']; $x2 = (int)$d['all_kill'];
} else {
$x2 = $x2[0];
} }
if ($x2 < (int)$d['all_kill']) { if ($x2 < (int)$d['all_kill']) {
$g = 0; $g = 0;
} }
} else { } else {
$x2 = $u->testAction($q . ' LIMIT ' . $ex2[1], 2); $x2 = ActionModel::testCountCustom($sqlFilter, $sqlParams, $smth1);
$x2 = min($ex2[1], $x2[0]); $x2 = min($smth1, $x2);
if ($x2 < $ex2[1]) { if ($x2 < $smth1) {
$g = 0; $g = 0;
} }
} }
@ -886,10 +901,10 @@ class Quests
$x2 = Db::getValue('select count(*) from items_users where maidin = ? and item_id = ? and uid = ? and `delete` in (0,1000) and inTransfer = 0 and inShop = 0', $x2 = Db::getValue('select count(*) from items_users where maidin = ? and item_id = ? and uid = ? and `delete` in (0,1000) and inTransfer = 0 and inShop = 0',
[$pl['city'], (int)$ex2[0], $u->info['id']]); [$pl['city'], (int)$ex2[0], $u->info['id']]);
if ($x2 >= $ex2[1]) { if ($x2 >= $ex2[1]) {
if ($x2 <= ($ex2[1] + round($ex2[1] * 0.15))) { if ($x2 <= ((int)$ex2[1] + round($ex2[1] * 0.15))) {
$ex2[1] = $x2; $ex2[1] = $x2;
} else { } else {
$ex2[1] = ($ex2[1] + round($ex2[1] * 0.15)); $ex2[1] = ((int)$ex2[1] + round($ex2[1] * 0.15));
} }
} }
if ($x2 < $ex2[1]) { if ($x2 < $ex2[1]) {
@ -928,10 +943,10 @@ class Quests
$x2 = Db::getValue('select count(*) from items_users where maidin = ? and item_id = ? and uid = ? and `delete` in (0,1000) and inTransfer = 0 and inShop = 0', $x2 = Db::getValue('select count(*) from items_users where maidin = ? and item_id = ? and uid = ? and `delete` in (0,1000) and inTransfer = 0 and inShop = 0',
[$quest['city'], (int)$ex2[0], $u->info['id']]); [$quest['city'], (int)$ex2[0], $u->info['id']]);
if ($x2 >= $ex2[1]) { if ($x2 >= $ex2[1]) {
if ($x2 <= ($ex2[1] + round($ex2[1] * 0.15))) { if ($x2 <= ((int)$ex2[1] + round($ex2[1] * 0.15))) {
$ex2[1] = $x2; $ex2[1] = $x2;
} else { } else {
$ex2[1] = ($ex2[1] + round($ex2[1] * 0.15)); $ex2[1] = ((int)$ex2[1] + round($ex2[1] * 0.15));
} }
} }
$d['add_rep'] = (int)$d['add_rep'] * (int)$ex2[1]; $d['add_rep'] = (int)$d['add_rep'] * (int)$ex2[1];
@ -953,9 +968,8 @@ class Quests
$i = 0; $i = 0;
$ex2 = explode('=', $ex[$i]); $ex2 = explode('=', $ex[$i]);
while ($i < $d['all_kill']) { while ($i < $d['all_kill']) {
$x2 = 0; $d['add_rep'] = $d['add_rep'] + (int)$ex2[1];
$d['add_rep'] = $d['add_rep'] + $ex2[1]; $x2 = ActionModel::testCount(["uid = {$u->info['id']}", "vars = win_bot_$ex2[0]", "time > {$action['time']}"], $d['all_kill']);
$x2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time` > ' . $action['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $d['all_kill'], 2);
$i++; $i++;
} }
$ii++; $ii++;

View File

@ -811,15 +811,10 @@ class User
return Db::getRow('select * from users left join stats on users.id = stats.id where users.id = ?', [$id]); return Db::getRow('select * from users left join stats on users.id = stats.id where users.id = ?', [$id]);
} }
public function testAction($filter, $tp): array public function testAction($filter, $tp = 1): array
{ {
if ($tp == 1) {
$query = 'select * from actions where ' . $filter; $query = 'select * from actions where ' . $filter;
} elseif ($tp == 2) {
$query = 'select count(*) from actions where ' . $filter;
} else {
return [];
}
$arr = mysql_fetch_array(mysql_query($query)); $arr = mysql_fetch_array(mysql_query($query));
return !empty($arr) ? $arr : []; return !empty($arr) ? $arr : [];
@ -965,13 +960,8 @@ class User
if (isset($smt['id'])) { if (isset($smt['id'])) {
$this->error2 = 'Нельзя лепить несколько снежков одновременно ;)'; $this->error2 = 'Нельзя лепить несколько снежков одновременно ;)';
} else { } else {
$smt = $this->testAction( $smt = ActionModel::testCount(["uid = {$this->info['id']}", 'vars = create_snowball_cp', 'time >= ' . strtotime('now 00:00:00')], 25);
'`uid` = "' . $this->info['id'] . '" AND `time`>=' . strtotime(
'now 00:00:00'
) . ' AND `vars` = "create_snowball_cp" LIMIT 25',
2
);
$smt = $smt[0];
if ($smt < 10) { if ($smt < 10) {
$this->addAction(time(), 'create_snowball_cp', $this->info['city']); $this->addAction(time(), 'create_snowball_cp', $this->info['city']);

View File

@ -113,7 +113,7 @@ class InfoBox
$lvar = $this->getInfoItemInfo($pl, $td); $lvar = $this->getInfoItemInfo($pl, $td);
if (isset($sn['items_img'][$tp_img[$pl['inOdet']]])) { if (isset($tp_img[$pl['inOdet']], $sn['items_img'][$tp_img[$pl['inOdet']]])) {
$uimg = 'rimg/r' . $sn['items_img'][$tp_img[$pl['inOdet']]]; $uimg = 'rimg/r' . $sn['items_img'][$tp_img[$pl['inOdet']]];
} else { } else {
$uimg = 'i/items/' . $pl['img']; $uimg = 'i/items/' . $pl['img'];
@ -469,7 +469,7 @@ class InfoBox
if ($u['banned'] > 0) { if ($u['banned'] > 0) {
$pb .= '<div style="margin:0 2px 0 2px; color: red; background-color: #fae0e0;"><strong>Персонаж заблокирован</strong></div>'; $pb .= '<div style="margin:0 2px 0 2px; color: red; background-color: #fae0e0;"><strong>Персонаж заблокирован</strong></div>';
} }
if ($u['allLock'] > time()) { if (isset($u['allLock']) && $u['allLock'] > time()) {
$pb .= '<div style="margin:0 2px 0 2px; color: red; background-color: #fae0e0;"><strong>Временный запрет передач!</strong></div>'; $pb .= '<div style="margin:0 2px 0 2px; color: red; background-color: #fae0e0;"><strong>Временный запрет передач!</strong></div>';
} }

View File

@ -253,6 +253,7 @@ class Stats
$noeffectbattle = false; $noeffectbattle = false;
if ($u['battle'] > 0) { if ($u['battle'] > 0) {
$noeffectbattle = (bool)Db::getValue("select 1 from battle_actions where uid = ? and vars = 'noeffectbattle1' and btl = ? limit 1", [$u['id'], $u['battle']]); $noeffectbattle = (bool)Db::getValue("select 1 from battle_actions where uid = ? and vars = 'noeffectbattle1' and btl = ? limit 1", [$u['id'], $u['battle']]);
$st['team'] = $u['team'];
} }
//Характеристики от эффектов //Характеристики от эффектов

View File

@ -1,4 +1,9 @@
<?php <?php
use Core\Config;
use Model\ActionModel;
use User\ItemsModel;
echo " echo "
<script language='JavaScript'> <script language='JavaScript'>
var elem = document.getElementById('se-pre-con'); var elem = document.getElementById('se-pre-con');
@ -191,29 +196,28 @@ $vi = [
$vix = 0; $vix = 0;
if ($ability[$account][$i][4] == 0) { if ($ability[$account][$i][4] == 0) {
//за сегодня //за сегодня
$vix = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time`>=' . strtotime('now 00:00:00') . ' AND `vars` = "vitm_' . $itm['id'] . '"', 2); $time = strtotime('now 00:00:00');
$vix = $vix[0];
} else { } else {
//всего за действие премиума //всего за действие премиума
$vix = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time`>=' . $vt['timeUse'] . ' AND `vars` = "vitm_' . $itm['id'] . '" ', 2); $time = $vt['timeUse'];
$vix = $vix[0];
} }
$vix = ActionModel::testCount(["uid = {$u->info['id']}", "vars = vitm_{$itm['id']}", "time >= $time"]);
unset($time);
if ($ability[$account][$i][1] - $vix > 0 && isset($_GET['take_item_vip']) && $_GET['take_item_vip'] == $itm['id']) { if ($ability[$account][$i][1] - $vix > 0 && isset($_GET['take_item_vip']) && $_GET['take_item_vip'] == $itm['id']) {
$nitm = \User\ItemsModel::addItem($itm['id'], $u->info['id'], $ability[$account][$i][5]); $nitm = ItemsModel::addItem($itm['id'], $u->info['id'], $ability[$account][$i][5]);
$u->addAction(time(), 'vitm_' . $itm['id'], ''); $u->addAction(time(), 'vitm_' . $itm['id'], '');
echo '<font color="red">Предмет &quot;<b>' . $itm['name'] . '</b>&quot; перемещен к Вам в инвентарь!</font><br><br>'; echo 'Предмет &quot;<b>' . $itm['name'] . '</b>&quot; перемещен к Вам в инвентарь!<br><br>';
} }
$seet0 = ''; $seet0 = '';
//Вывод предметов вип //Вывод предметов вип
$seet0 .= '<img ' . $vix . ' title="' . $itm['name'] . ' $seet0 .= '<img ' . $vix . ' title="' . $itm['name'] . '
(Осталось ' . $vnr[$ability[$account][$i][4]] . ': ' . ($ability[$account][$i][1] - $vix) . ' шт.)" src="https://' . $c['img'] . '/i/items/' . $itm['img'] . '"> '; (Осталось ' . $vnr[$ability[$account][$i][4]] . ': ' . ($ability[$account][$i][1] - $vix) . ' шт.)" src="' . Config::img() . '/i/items/' . $itm['img'] . '"> ';
if ($ability[$account][$i][1] - $vix > 0) { if ($ability[$account][$i][1] - $vix > 0) {
$seet0 = '<a href="main.php?vip=1&take_item_vip=' . $itm['id'] . '">' . $seet0 . '</a>'; $seet0 = '<a href="main.php?vip=1&take_item_vip=' . $itm['id'] . '">' . $seet0 . '</a>';
} else { } else {
$seet0 = '<span style="filter: alpha(opacity=20); -moz-opacity: 0.20; -khtml-opacity: 0.20; opacity: 0.20;">' . $seet0 . '</span>'; $seet0 = '<span style="filter: alpha(opacity=20); -moz-opacity: 0.20; opacity: 0.20;">' . $seet0 . '</span>';
} }
$seet .= $seet0; $seet .= $seet0;
} }

View File

@ -1,55 +1,61 @@
<?php <?php
if(!defined('GAME') || $u->stats['silver']<1)
{ use Model\ActionModel;
use User\ItemsModel;
if (!defined('GAME') || $u->stats['silver'] < 1) {
die(); die();
} }
if($u->error!='') if ($u->error != '') {
{
echo '<font color="red"><b>' . $u->error . '</b></font><br>'; echo '<font color="red"><b>' . $u->error . '</b></font><br>';
} }
$vt = mysql_fetch_array(mysql_query('SELECT * FROM `eff_users` WHERE `uid` = "' . $u->info['id'] . '" AND `delete` = "0" AND `data` LIKE "%add_silver=%" LIMIT 1')); $vt = mysql_fetch_array(mysql_query('SELECT * FROM `eff_users` WHERE `uid` = "' . $u->info['id'] . '" AND `delete` = "0" AND `data` LIKE "%add_silver=%" LIMIT 1'));
$vu = array(0,0,0,0,0,0,0); $vu = [0, 0, 0, 0, 0, 0, 0];
$vi = array( $vi = [
//лечение травм //лечение травм
array(4412,array( 0 , 5 , 5 , 5 , 10 , 10 ),0,0,1,'useOnLogin=1|musor=1|noremont=1|sudba='.$u->info['login'].'|srok=600',1), [4412, [0, 5, 5, 5, 10, 10], 0, 0, 1, 'useOnLogin=1|musor=1|noremont=1|sudba=' . $u->info['login'] . '|srok=600', 1],
array(4413,array( 0 , 5 , 5 , 5 , 10 , 10 ),0,0,1,'useOnLogin=1|musor=1|noremont=1|sudba='.$u->info['login'].'|srok=600',1), [4413, [0, 5, 5, 5, 10, 10], 0, 0, 1, 'useOnLogin=1|musor=1|noremont=1|sudba=' . $u->info['login'] . '|srok=600', 1],
array(4414,array( 0 , 5 , 5 , 5 , 10 , 10 ),0,0,1,'useOnLogin=1|musor=1|noremont=1|sudba='.$u->info['login'].'|srok=600',1), [4414, [0, 5, 5, 5, 10, 10], 0, 0, 1, 'useOnLogin=1|musor=1|noremont=1|sudba=' . $u->info['login'] . '|srok=600', 1],
//нападалки //нападалки
array(865, array( 0 , 0 , 0 , 0 , 0 , 0 ),0,0,1,'useOnLogin=1|musor=1|noremont=1|sudba='.$u->info['login'].'|srok=43200',1), [865, [0, 0, 0, 0, 0, 0], 0, 0, 1, 'useOnLogin=1|musor=1|noremont=1|sudba=' . $u->info['login'] . '|srok=43200', 1],
array(2391,array( 0 , 0 , 0 , 0 , 10 , 20 ),0,0,1,'useOnLogin=1|musor=1|noremont=1|sudba='.$u->info['login'].'|srok=43200',2), [2391, [0, 0, 0, 0, 10, 20], 0, 0, 1, 'useOnLogin=1|musor=1|noremont=1|sudba=' . $u->info['login'] . '|srok=43200', 2],
//хилки //хилки
array(2543,array( 0 , 0 , 0 , 0 , 0 , 0 ),0,0,1,'useOnLogin=1|musor=1|noremont=1|sudba='.$u->info['login'].'|srok=21600|magic_hpNow=45',2), [2543, [0, 0, 0, 0, 0, 0], 0, 0, 1, 'useOnLogin=1|musor=1|noremont=1|sudba=' . $u->info['login'] . '|srok=21600|magic_hpNow=45', 2],
array(2544,array( 0 , 0 , 0 , 0 , 0 , 0 ),0,0,1,'useOnLogin=1|musor=1|noremont=1|sudba='.$u->info['login'].'|srok=21600|magic_hpNow=60',2), [2544, [0, 0, 0, 0, 0, 0], 0, 0, 1, 'useOnLogin=1|musor=1|noremont=1|sudba=' . $u->info['login'] . '|srok=21600|magic_hpNow=60', 2],
array(2545,array( 0 , 0 , 0 , 0 , 0 , 0 ),0,0,1,'useOnLogin=1|musor=1|noremont=1|sudba='.$u->info['login'].'|srok=21600|magic_hpNow=600',2), [2545, [0, 0, 0, 0, 0, 0], 0, 0, 1, 'useOnLogin=1|musor=1|noremont=1|sudba=' . $u->info['login'] . '|srok=21600|magic_hpNow=600', 2],
//обкасты //обкасты
array(994, array( 0 , 0 , 0 , 0 , 5 , 10 ),0,0,1,'musor=1|noremont=1|onlyOne=1|oneType=6|sudba='.$u->info['login'].'|srok=600',1), [994, [0, 0, 0, 0, 5, 10], 0, 0, 1, 'musor=1|noremont=1|onlyOne=1|oneType=6|sudba=' . $u->info['login'] . '|srok=600', 1],
array(1001,array( 0 , 0 , 0 , 0 , 5 , 10 ),0,0,1,'musor=1|noremont=1|onlyOne=1|oneType=7|sudba='.$u->info['login'].'|srok=600',1), [1001, [0, 0, 0, 0, 5, 10], 0, 0, 1, 'musor=1|noremont=1|onlyOne=1|oneType=7|sudba=' . $u->info['login'] . '|srok=600', 1],
array(1460,array( 0 , 0 , 0 , 0 , 5 , 10 ),0,0,1,'musor=1|noremont=1|onlyOne=1|oneType=25|sudba='.$u->info['login'].'|srok=600',1), [1460, [0, 0, 0, 0, 5, 10], 0, 0, 1, 'musor=1|noremont=1|onlyOne=1|oneType=25|sudba=' . $u->info['login'] . '|srok=600', 1],
array(3102,array( 0 , 0 , 0 , 0 , 5 , 10 ),0,0,1,'musor=1|noremont=1|onlyOne=1|oneType=33|sudba='.$u->info['login'].'|srok=600',1), [3102, [0, 0, 0, 0, 5, 10], 0, 0, 1, 'musor=1|noremont=1|onlyOne=1|oneType=33|sudba=' . $u->info['login'] . '|srok=600', 1],
array(4371,array( 5 , 5 , 5 , 5 , 5 , 5 ),0,0,1,'musor=1|noremont=1|onlyOne=1|oneType=36|sudba='.$u->info['login'].'|srok=600',1), [4371, [5, 5, 5, 5, 5, 5], 0, 0, 1, 'musor=1|noremont=1|onlyOne=1|oneType=36|sudba=' . $u->info['login'] . '|srok=600', 1],
//Сундуки //Сундуки
array(2144,array( 0 , 0 , 0 , 0 , 0 , 3 ),0,0,1,'nohaos=1|onlyOne=1|oneType=12|musor=2|noremont=1|srok=600',1), [2144, [0, 0, 0, 0, 0, 3], 0, 0, 1, 'nohaos=1|onlyOne=1|oneType=12|musor=2|noremont=1|srok=600', 1],
array(2143,array( 0 , 0 , 0 , 0 , 0 , 3 ),0,0,1,'nohaos=1|onlyOne=1|oneType=7|musor=2|noremont=1|srok=600',1), [2143, [0, 0, 0, 0, 0, 3], 0, 0, 1, 'nohaos=1|onlyOne=1|oneType=7|musor=2|noremont=1|srok=600', 1],
//array(3101,array( 0 , 0 , 0 , 0 , 0 , 0 ),0,0,1,'onlyOne=1|oneType=33|noremont=1|musor=1|srok=600',1), //array(3101,array( 0 , 0 , 0 , 0 , 0 , 0 ),0,0,1,'onlyOne=1|oneType=33|noremont=1|musor=1|srok=600',1),
//Екр. //Екр.
array(1461,array( 0 , 0 , 0 , 0 , 0 , 0 ),0,0,1,'musor=1|noremont=1|onlyOne=1|oneType=24|sudba='.$u->info['login'].'|srok=600',1), [1461, [0, 0, 0, 0, 0, 0], 0, 0, 1, 'musor=1|noremont=1|onlyOne=1|oneType=24|sudba=' . $u->info['login'] . '|srok=600', 1],
array(1462,array( 0 , 0 , 0 , 0 , 0 , 0 ),0,0,1,'musor=1|noremont=1|onlyOne=1|oneType=24|sudba='.$u->info['login'].'|srok=600',1), [1462, [0, 0, 0, 0, 0, 0], 0, 0, 1, 'musor=1|noremont=1|onlyOne=1|oneType=24|sudba=' . $u->info['login'] . '|srok=600', 1],
array(1463,array( 0 , 0 , 0 , 0 , 0 , 0 ),0,0,1,'musor=1|noremont=1|onlyOne=1|oneType=24|sudba='.$u->info['login'].'|srok=600',1) [1463, [0, 0, 0, 0, 0, 0], 0, 0, 1, 'musor=1|noremont=1|onlyOne=1|oneType=24|sudba=' . $u->info['login'] . '|srok=600', 1],
//array(2143,1,2,10,1,'musor=1|noremont=1|onlyOne=1|oneType=3|sudba='.$u->info['login'].'|srok=600',1), //array(2143,1,2,10,1,'musor=1|noremont=1|onlyOne=1|oneType=3|sudba='.$u->info['login'].'|srok=600',1),
//array(2144,1,2,10,1,'musor=1|noremont=1|onlyOne=1|oneType=3|sudba='.$u->info['login'].'|srok=600',1)*/ //array(2144,1,2,10,1,'musor=1|noremont=1|onlyOne=1|oneType=3|sudba='.$u->info['login'].'|srok=600',1)*/
); ];
?> ?>
<table width="100%"> <table width="100%">
<tr> <tr>
<td align="center"><h3>Добро пожаловать, <?=$u->info['login']?>!</h3><center>У вас действует <img width="15" height="15" style="display:inline-block; vertical-align:text-bottom;" src="//img.new-combats.tech/blago/<?=$u->stats['silver']?>.png" /><b>Благословления Ангелов</b> <?=$u->stats['silver']?> уровня.</center></td> <td align="center"><h3>Добро пожаловать, <?= $u->info['login'] ?>!</h3>
<center>У вас действует <img width="15" height="15" style="display:inline-block; vertical-align:text-bottom;" src="//img.new-combats.tech/blago/<?= $u->stats['silver'] ?>.png"/><b>Благословления
Ангелов</b> <?= $u->stats['silver'] ?> уровня.
</center>
</td>
<td width="150" align="right"><input type="button" value="обновить" onclick="location='main.php?vip=1';"/> <input type="button" value="Вернуться" onclick="location='main.php';"/></td> <td width="150" align="right"><input type="button" value="обновить" onclick="location='main.php?vip=1';"/> <input type="button" value="Вернуться" onclick="location='main.php';"/></td>
</tr> </tr>
<tr> <tr>
@ -58,8 +64,9 @@ $vi = array(
<small>(Чтобы забрать предмет просто нажмите на его изображение)</small></p> <small>(Чтобы забрать предмет просто нажмите на его изображение)</small></p>
<p> <p>
<?php <?php
$i = 0; $seet = ''; $i = 0;
$vnr = array(0 => 'на сегодня',1 => ' всего'); $seet = '';
$vnr = [0 => 'на сегодня', 1 => ' всего'];
while ($i < count($vi)) { while ($i < count($vi)) {
if ($vi[$i][1][$u->stats['silver']] > 0) { if ($vi[$i][1][$u->stats['silver']] > 0) {
$itm = mysql_fetch_array(mysql_query('SELECT * FROM `items_main` WHERE `id` = "' . $vi[$i][0] . '" LIMIT 1')); $itm = mysql_fetch_array(mysql_query('SELECT * FROM `items_main` WHERE `id` = "' . $vi[$i][0] . '" LIMIT 1'));
@ -67,23 +74,22 @@ $vi = array(
$vix = 0; $vix = 0;
if ($vi[$i][4] == 0) { if ($vi[$i][4] == 0) {
//за сегодня //за сегодня
$vix = $u->testAction('`uid` = "'.$u->info['id'].'" AND `time`>='.strtotime('now 00:00:00').' AND `vars` = "vitm_'.$itm['id'].'" LIMIT '.$vi[$i][1][$u->stats['silver']],2); $time = strtotime('now 00:00:00');
$vix = $vix[0];
} else { } else {
//всего за действие премиума //всего за действие премиума
$vix = $u->testAction('`uid` = "'.$u->info['id'].'" AND `time`>='.$vt['timeUse'].' AND `vars` = "vitm_'.$itm['id'].'" LIMIT '.$vi[$i][1][$u->stats['silver']],2); $time = $vt['timeUse'];
$vix = $vix[0];
} }
$vix = ActionModel::testCount(["uid = {$u->info['id']}", "vars = vitm_{$itm['id']}", "time >= $time"], $vi[$i][1][$u->stats['silver']]);
if ($vi[$i][1][$u->stats['silver']] - $vix > 0) { if ($vi[$i][1][$u->stats['silver']] - $vix > 0) {
if (isset($_GET['take_item_vip']) && $_GET['take_item_vip'] == $itm['id']) { if (isset($_GET['take_item_vip']) && $_GET['take_item_vip'] == $itm['id']) {
$vix++; $vix++;
$nitm = \User\ItemsModel::addItem($itm['id'],$u->info['id'],$vi[$i][5]); $nitm = ItemsModel::addItem($itm['id'], $u->info['id'], $vi[$i][5]);
if ($vi[$i][6] > 0) { if ($vi[$i][6] > 0) {
mysql_query('UPDATE `items_users` SET `data`="' . $vi[$i][5] . '",`iznosMAX` = "' . $vi[$i][6] . '",`1price` = "0.01" WHERE `id` = "' . $nitm . '" AND `uid` = "' . $u->info['id'] . '" LIMIT 1'); mysql_query('UPDATE `items_users` SET `data`="' . $vi[$i][5] . '",`iznosMAX` = "' . $vi[$i][6] . '",`1price` = "0.01" WHERE `id` = "' . $nitm . '" AND `uid` = "' . $u->info['id'] . '" LIMIT 1');
} }
$u->addAction(time(), 'vitm_' . $itm['id'], ''); $u->addAction(time(), 'vitm_' . $itm['id'], '');
echo '<font color="red">Предмет &quot;<b>'.$itm['name'].'</b>&quot; перемещен к Вам в инвентарь (Осталось '.$vnr[$vi[$i][4]].': '.($vi[$i][1][$u->stats['silver']]-$vix).' шт.).</font><br><br>'; echo 'Предмет &quot;<b>' . $itm['name'] . '</b>&quot; перемещен к Вам в инвентарь (Осталось ' . $vnr[$vi[$i][4]] . ': ' . ($vi[$i][1][$u->stats['silver']] - $vix) . ' шт.).<br><br>';
} }
} }