Полный отказ от $u->testAction() целиком.
This commit is contained in:
+62
-67
@@ -260,9 +260,9 @@ class User
|
||||
|
||||
if ($sb - 1 > $this->info['catch'] - $this->info['frg']) {
|
||||
if ($this->info['frg'] == -1) {
|
||||
$sm = $this->testAction('`uid` = "' . $this->info['id'] . '" AND `vars` = "frg" LIMIT 1', 1);
|
||||
$sm = (bool)ActionModel::testCount(["uid = {$this->info['id']}", 'vars = frg']);
|
||||
}
|
||||
if (!isset($sm['id']) && $this->info['frg'] == -1) {
|
||||
if (!$sm && $this->info['frg'] == -1) {
|
||||
mysql_query(
|
||||
'UPDATE `users` SET `catch` = "' . round(
|
||||
$sb
|
||||
@@ -287,6 +287,7 @@ class User
|
||||
);
|
||||
}
|
||||
}
|
||||
unset($sm);
|
||||
}
|
||||
|
||||
if ($this->info['login2'] != '' && $this->info['battle'] == 0 && $this->info['zv'] == 0) {
|
||||
@@ -304,8 +305,7 @@ class User
|
||||
}
|
||||
|
||||
if (isset($_GET['homeworld']) && $this->info['zv'] == 0 && $this->info['battle'] == 0 && $this->info['dnow'] == 0) {
|
||||
$hgo = $this->testHome();
|
||||
if (!isset($hgo['id']) && $this->info['room'] != 274 && $this->info['align'] != 2 && $this->info['inTurnir'] == 0) {
|
||||
if ($this->testHome() && $this->info['room'] != 274 && $this->info['align'] != 2 && $this->info['inTurnir'] == 0) {
|
||||
$this->addAction(time(), 'go_homeworld', '');
|
||||
$rmt = mysql_fetch_array(
|
||||
mysql_query(
|
||||
@@ -340,7 +340,6 @@ class User
|
||||
} else {
|
||||
$this->error = 'Вам запрещено пользоваться кнопкой возрата';
|
||||
}
|
||||
unset($hgo);
|
||||
}
|
||||
|
||||
//Заносим текст
|
||||
@@ -506,17 +505,14 @@ class User
|
||||
*/
|
||||
|
||||
//Статистика персонажа на сегодня
|
||||
$stat = $this->testAction(
|
||||
'`uid` = "' . $this->info['id'] . '" AND `time` >= ' . strtotime(
|
||||
'now 00:00:00'
|
||||
) . ' AND `vars` = "statistic_today" LIMIT 1', 1
|
||||
);
|
||||
if (!isset($stat['id'])) {
|
||||
$stat = (bool)ActionModel::testCount(["uid = {$this->info['id']}", "time >= " . strtotime('now 00:00:00'), 'vars = statistic_today']);
|
||||
if (!$stat) {
|
||||
$this->addAction(
|
||||
time(), 'statistic_today',
|
||||
'e=' . $this->info['exp'] . '|w=' . $this->info['win'] . '|l=' . $this->info['lose'] . '|n=' . $this->info['nich']
|
||||
);
|
||||
}
|
||||
unset($stat);
|
||||
|
||||
//Одеваем боевой комплект
|
||||
if (isset($_GET['usec1']) && $this->info['battle'] == 0) {
|
||||
@@ -600,11 +596,8 @@ class User
|
||||
}
|
||||
|
||||
if (isset($_GET['obr_sel']) || isset($_GET['obraz'])) {
|
||||
$sm = $this->testAction(
|
||||
'`uid` = "' . $this->info['id'] . '" AND `time` > ' . (time() - 86400) . ' AND `vars` = "sel_obraz" LIMIT 1',
|
||||
1
|
||||
);
|
||||
if (!isset($sm['id'])) {
|
||||
$obrazTimeout = ActionModel::getOne(["uid = {$this->info['id']}", 'time > unix_timestamp() - 86400', 'vars = sel_obraz'], 'time');
|
||||
if (!$obrazTimeout) {
|
||||
if (isset($_GET['obr_sel'])) {
|
||||
$tr = true;
|
||||
$o = mysql_fetch_array(
|
||||
@@ -675,7 +668,7 @@ class User
|
||||
}
|
||||
} else {
|
||||
$this->error = 'Выбирать образ можно не чаще одного раза в сутки, следующая смена ' . date(
|
||||
'd.m.Y H:i', $sm['time'] + 86400
|
||||
'd.m.Y H:i', $obrazTimeout + 86400
|
||||
);
|
||||
unset($_GET['obr_sel']);
|
||||
$_GET['inv'] = 1;
|
||||
@@ -811,17 +804,6 @@ class User
|
||||
return Db::getRow('select * from users left join stats on users.id = stats.id where users.id = ?', [$id]);
|
||||
}
|
||||
|
||||
public function testAction($filter, $tp = 1): array
|
||||
{
|
||||
$query = 'select * from actions where ' . $filter;
|
||||
|
||||
$arr = mysql_fetch_array(mysql_query($query));
|
||||
|
||||
return !empty($arr) ? $arr : [];
|
||||
}
|
||||
|
||||
//Удаление определенного типа предметов
|
||||
|
||||
public function addAction($time, $vars, $vls, $uid = null): bool
|
||||
{
|
||||
$info = $this->info;
|
||||
@@ -832,7 +814,14 @@ class User
|
||||
return true;
|
||||
}
|
||||
|
||||
public function testHome(): array
|
||||
//Удаление определенного типа предметов
|
||||
|
||||
/**
|
||||
* Кнопка "Возврат".
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function testHome(): bool
|
||||
{
|
||||
/*----Быстрый(Особенность)----*/
|
||||
$timeforwait = 3600;
|
||||
@@ -840,25 +829,27 @@ class User
|
||||
$timeforwait = 3600 - (($st['os6'] * 5) * 60);
|
||||
}
|
||||
/*----Быстрый(Особенность)----*/
|
||||
$hgo = $this->testAction(
|
||||
'`uid` = "' . $this->info['id'] . '" AND `time` >= ' . (time() - $timeforwait) . ' AND `vars` = "go_homeworld" LIMIT 1',
|
||||
1
|
||||
);
|
||||
if ($this->info['level'] == 0 || $this->info['active'] != '' || $this->info['inTurnir'] > 0 || $this->info['inTurnirnew'] > 0 || $this->info['zv'] > 0 || $this->info['dnow'] > 0) {
|
||||
$hgo['id'] = true;
|
||||
$buttonUsed = (bool)ActionModel::testCount(["uid = {$this->info['id']}", "time >= unix_timestamp - $timeforwait", 'vars = go_homeworld']);
|
||||
|
||||
if (
|
||||
$this->info['level'] == 0 ||
|
||||
$this->info['active'] != '' ||
|
||||
$this->info['inTurnir'] > 0 ||
|
||||
$this->info['inTurnirnew'] > 0 ||
|
||||
$this->info['zv'] > 0 ||
|
||||
$this->info['dnow'] > 0 ||
|
||||
!empty($this->info['noreal'])
|
||||
) {
|
||||
$buttonUsed = true;
|
||||
}
|
||||
if (isset($this->info['noreal']) || $this->info['dnow'] > 0) {
|
||||
$hgo['id'] = true;
|
||||
}
|
||||
if (!isset($hgo['id'])) {
|
||||
$ku = mysql_fetch_array(
|
||||
mysql_query('SELECT `id` FROM `katok_zv` WHERE `uid` = ' . $this->info['id'])
|
||||
);
|
||||
if (isset($ku['id'])) {
|
||||
$hgo['id'] = true;
|
||||
|
||||
if (!$buttonUsed) {
|
||||
$onKatok = (bool)Db::getValue('select id from katok_zv where uid = ?', [$this->info['id']]);
|
||||
if ($onKatok) {
|
||||
$buttonUsed = true;
|
||||
}
|
||||
}
|
||||
return $hgo ?? [];
|
||||
return !$buttonUsed;
|
||||
}
|
||||
|
||||
public function wipe()
|
||||
@@ -939,39 +930,42 @@ class User
|
||||
|
||||
//Расчет урона от оружия
|
||||
|
||||
public function allActionsStart()
|
||||
public function allActionsStart(): void
|
||||
{
|
||||
global $magic;
|
||||
define('VAREZHKI_ITEM_ID', 998);
|
||||
|
||||
if (!isset($_GET['use_snowball'])) {
|
||||
return;
|
||||
}
|
||||
$this->stats = $this->getStats($this->info, 0);
|
||||
//Начинаем лепить снежок на ЦП
|
||||
if (!isset($this->stats['items'][$this->stats['wp13id']]['id']) || $this->stats['items'][$this->stats['wp13id']]['item_id'] != 998) {
|
||||
if (!isset($this->stats['items'][$this->stats['wp13id']]['id']) || $this->stats['items'][$this->stats['wp13id']]['item_id'] != VAREZHKI_ITEM_ID) {
|
||||
return;
|
||||
}//варежки одеты, все ок
|
||||
if ($this->room['name'] != 'Центральная площадь') {
|
||||
$this->error2 = 'Собирать снег можно только на Центральной площади';
|
||||
} else {
|
||||
$smt = $this->testAction(
|
||||
'`uid` = "' . $this->info['id'] . '" AND `time`>=' . (time() - 120) . ' AND `vars` = "create_snowball_cp" LIMIT 1',
|
||||
1
|
||||
);
|
||||
if (isset($smt['id'])) {
|
||||
$this->error2 = 'Нельзя лепить несколько снежков одновременно ;)';
|
||||
} else {
|
||||
$smt = ActionModel::testCount(["uid = {$this->info['id']}", 'vars = create_snowball_cp', 'time >= ' . strtotime('now 00:00:00')], 25);
|
||||
|
||||
if ($smt < 10) {
|
||||
$this->addAction(time(), 'create_snowball_cp', $this->info['city']);
|
||||
|
||||
$magic->addEffect($this->info['id'], 24);
|
||||
$this->error2 = 'Начинаем лепить снежок, осталось ' . (10 - $smt) . ' раз на сегодня ...';
|
||||
} else {
|
||||
$this->error2 = 'Вы уже слепили 10 снежка за сегодня ...';
|
||||
}
|
||||
}
|
||||
``
|
||||
return;
|
||||
}
|
||||
|
||||
$isMakingSnowball = (bool)ActionModel::testCount(["uid = {$this->info['id']}", "time >= unix_timestamp() - 120", 'vars = create_snowball_cp']);
|
||||
|
||||
if ($isMakingSnowball) {
|
||||
$this->error2 = 'Нельзя лепить несколько снежков одновременно ;)';
|
||||
return;
|
||||
}
|
||||
|
||||
$createdToday = ActionModel::testCount(["uid = {$this->info['id']}", 'vars = create_snowball_cp', 'time >= ' . strtotime('now 00:00:00')], 25);
|
||||
|
||||
if ($createdToday >= 10) {
|
||||
$this->error2 = 'Вы уже слепили 10 снежка за сегодня ...';
|
||||
return;
|
||||
}
|
||||
|
||||
$this->addAction(time(), 'create_snowball_cp', $this->info['city']);
|
||||
$magic->addEffect($this->info['id'], 24);
|
||||
$this->error2 = 'Начинаем лепить снежок, осталось ' . (10 - $createdToday) . ' раз на сегодня ...';
|
||||
}
|
||||
|
||||
//Расчет защиты
|
||||
@@ -4884,7 +4878,7 @@ class User
|
||||
return 0;
|
||||
}
|
||||
|
||||
$sleep = $this->testAction('`vars` = "sleep" AND `uid` = "' . $e['uid'] . '" LIMIT 1', 1);
|
||||
$sleep = ActionModel::getOne(["uid = {$e['uid']}", 'vars = sleep'], 'vars');
|
||||
|
||||
if ($e['id_eff'] == 2) {
|
||||
//Проверка
|
||||
@@ -4908,6 +4902,7 @@ class User
|
||||
if (isset($po['finish_file']) && file_exists('_incl_data/class/Magic/' . $po['finish_file'] . '.php')) {
|
||||
require_once '_incl_data/class/Magic/' . $po['finish_file'] . '.php';
|
||||
}
|
||||
|
||||
if (isset($u['id']) && ($e['type1'] < 11 || $e['type1'] > 16 && $e['type1'] < 23) && $e['noch'] == 0) {
|
||||
$text = "Закончилось действие эффекта «<strong>{$e['name']}</strong>»";
|
||||
$cmsg = new ChatMessage();
|
||||
|
||||
Reference in New Issue
Block a user