Полный отказ от $u->testAction() целиком.

This commit is contained in:
2024-05-15 16:42:28 +03:00
parent bc136cc030
commit 5e0dda8ed0
50 changed files with 1909 additions and 1831 deletions
+3 -5
View File
@@ -10,6 +10,7 @@ use Core\Config;
use Core\Db;
use Delo;
use ItemModel;
use Model\ActionModel;
use User;
use User\Clan;
use User\Effects;
@@ -908,11 +909,8 @@ class Finish
$this->battle->users[$i]['battle_exp'] = floor($this->battle->users[$i]['battle_exp'] / 2);
}
if ($this->battle->users[$i]['animal'] > 0) {
$ulan = $u->testAction(
'`uid` = "' . $this->battle->users[$i]['id'] . '" AND `vars` = "animal_use' . $this->battle->i->id . '" LIMIT 1',
1
);
if (isset($ulan['id']) && $this->battle->users[$i]['team'] == $this->battle->i->getTeamwin() && $this->battle->users[$i]['level'] > $ulan['vals']) {
$ulan = ActionModel::getOne(["uid = {$this->battle->users[$i]['id']}", "vars = animal_use{$this->battle->i->id}"], 'vals');
if ($ulan['id'] && $this->battle->users[$i]['team'] == $this->battle->i->getTeamwin() && $this->battle->users[$i]['level'] > $ulan) {
$a004 = mysql_fetch_array(
mysql_query(
'SELECT `max_exp`,`name` FROM `users_animal` WHERE `uid` = "' . $this->battle->users[$i]['id'] . '" AND `id` = "' . $this->battle->users[$i]['animal'] . '" AND `pet_in_cage` = "0" AND `delete` = "0" LIMIT 1'
+2 -2
View File
@@ -19,14 +19,14 @@ class QueryBuilder
public function select(array $filters = [], int $limit = 0): array
{
if (empty($filters)) {
return ['sql' => "select {$this->columns} from {$this->tableName}"];
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);
$value = explode(' ', $value, 3); //todo: а ведь может прилететь значение из нескольких слов с пробелом...
if (count($value) === 1) {
$value = $value[0];
if (is_numeric($value)) {
+1 -168
View File
@@ -1491,9 +1491,6 @@ class Magic
} else {
$u->error = 'Персонаж "' . $jl . '" не найден в этом городе (' . $u->info['city'] . ')';
}
} elseif (isset($st['useOnItem']) && $st['useOnItem'] == 1) {
//используем на предмет
} else {
//на себя
$goodUse = 1;
@@ -1502,170 +1499,7 @@ class Magic
$u->error = 'Хаосники не могут использовать данное заклятие';
}
if ($itm['magic_inci'] == 'sanich2') {
if ($u->info['battle'] == 0) {
$sz = $u->testAction(
'`uid` = "' . $u->info['id'] . '" AND `vars` = "sanich2" AND `time` > ' . (time() - 4 * 60 * 60) . ' LIMIT 1', 1
);
if (!isset($sz['id'])) {
$slech = rand(0, 4);
$goodUse = 0;
if ($slech == 1) {
//3083 Настойка на жучьей требухе
//$this->add_eff($u->info['id'],3083);
mysql_query(
'DELETE FROM `eff_users` WHERE `uid` = "' . $u->info['id'] . '" AND `id_eff` = 290 AND `delete` =0'
);
$this->addEffect($u->info['id'], 290);
$echotext = 'Настойка на жучьей требухе!';
$u->error = 'Вы получили эфект от ' . $echotext . '';
} elseif ($slech == 2) {
//5239 Амброзия подмастерья Владык
//$this->add_eff($u->info['id'],5239);
mysql_query(
'DELETE FROM `eff_users` WHERE `uid` = "' . $u->info['id'] . '" AND `id_eff` = 472 AND `delete` =0'
);
mysql_query(
'DELETE FROM `eff_users` WHERE `uid` = "' . $u->info['id'] . '" AND `id_eff` = 470 AND `delete` =0'
);
$this->addEffect($u->info['id'], 472);
$echotext = 'Амброзия подмастерья Владык!';
$u->error = 'Вы получили эфект от ' . $echotext . '';
} elseif ($slech == 3) {
//5069 Амброзия Скучающих Владык
//$this->add_eff($u->info['id'],470);
mysql_query(
'DELETE FROM `eff_users` WHERE `uid` = "' . $u->info['id'] . '" AND `id_eff` = 472 AND `delete` =0'
);
mysql_query(
'DELETE FROM `eff_users` WHERE `uid` = "' . $u->info['id'] . '" AND `id_eff` = 470 AND `delete` =0'
);
$this->addEffect($u->info['id'], 470);
$echotext = 'Амброзия Скучающих Владык!';
$u->error = 'Вы получили эфект от ' . $echotext . '';
} elseif ($slech == 4) {
//1463 Звездное Сияние
//$this->add_eff($u->info['id'],1463);
mysql_query(
'DELETE FROM `eff_users` WHERE `uid` = "' . $u->info['id'] . '" AND `id_eff` = 35 AND `delete` =0'
);
$this->addEffect($u->info['id'], 35);
$echotext = 'Звездное Сияние!';
$u->error = 'Вы получили эфект от ' . $echotext . '';
} else {
$slech = 1;
$echotext = 'Не удалось прочитать страницу!';
$u->error = ' ' . $echotext . ' ';
}
$itm['iznosNOW'] += $slech;
mysql_query(
'UPDATE `items_users` SET `iznosNOW` = "' . $itm['iznosNOW'] . '" WHERE `id` = "' . $itm['id'] . '" AND `uid` = "' . $u->info['id'] . '" LIMIT 1'
);
$u->addAction(time(), 'sanich2', $slech);
if ($u->info['sex'] == 1) {
$rtxt = '[img[items/' . $itm['img'] . ']] "' . $u->info['login'] . '" использовала "' . $itm['name'] . ' Саныча" и получила эффект ' . $echotext . ' травмы.';
} else {
$rtxt = '[img[items/' . $itm['img'] . ']] "' . $u->info['login'] . '" использовал "' . $itm['name'] . ' Саныча" и получил эффект ' . $echotext . ' травмы.';
}
} else {
$u->error = 'Задержка использования ' . Conversion::secondsToTimeout(
($sz['time'] + 4 * 60 * 60) - time()
) . '.';
}
} else {
$u->error = 'Невозможно использовать в бою';
}
} elseif ($itm['magic_inci'] == 'sanich1' && $u->info['battle'] > 0) {
$sz = $u->testAction(
'`uid` = "' . $u->info['id'] . '" AND `vars` = "sanich1" AND `time` > ' . (time() - 6 * 60) . ' LIMIT 1', 1
);
if (!isset($sz['id'])) {
$goodUse = 0;
$u->error = 'Вы успешно использовали "' . $itm['name'] . '"';
$z = 1;
while ($z <= 5) {
$u->info['tactic' . $z]++;
if ($u->info['tactic' . $z] > 25) {
$u->info['tactic' . $z] = 25;
} elseif ($u->info['tactic' . $z] < 0) {
$u->info['tactic' . $z] = 0;
}
$z++;
}
if ($u->info['sex'] == 1) {
$this->inBattleLog('{u1} использовала &quot;<b>' . $itm['name'] . ' Саныча</b>&quot;.');
} else {
$this->inBattleLog('{u1} использовал &quot;<b>' . $itm['name'] . ' Саныча</b>&quot;.');
}
mysql_query(
'UPDATE `stats` SET `tactic1` = "' . $u->info['tactic1'] . '",`tactic2` = "' . $u->info['tactic2'] . '",`tactic3` = "' . $u->info['tactic3'] . '",`tactic4` = "' . $u->info['tactic4'] . '",`tactic5` = "' . $u->info['tactic5'] . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'
);
$itm['iznosNOW']++;
mysql_query(
'UPDATE `items_users` SET `iznosNOW` = "' . $itm['iznosNOW'] . '" WHERE `id` = "' . $itm['id'] . '" AND `uid` = "' . $u->info['id'] . '" LIMIT 1'
);
$u->addAction(time(), 'sanich1', $u->info['battle']);
} else {
$u->error = 'Задержка использования ' . Conversion::secondsToTimeout(($sz['time'] + 6 * 60) - time()) . '.';
}
} elseif ($itm['magic_inci'] == 'sanich3' && $u->info['battle'] > 0) {
$sz = $u->testAction(
'`uid` = "' . $u->info['id'] . '" AND `vars` = "sanich3" AND `time` > ' . (time() - 3 * 60 * 60) . ' LIMIT 1', 1
);
if (!isset($sz['id'])) {
$usr = mysql_fetch_array(
mysql_query(
'SELECT `u`.`id`,`u`.`level`,`s`.`hpNow`,`s`.`team`,`u`.`login`,`u`.`sex` FROM `users` AS `u` LEFT JOIN `stats` AS `s` ON `s`.`id` = `u`.`id` WHERE `u`.`id` = "' . $u->info['enemy'] . '" AND `u`.`battle` = "' . $u->info['battle'] . '" LIMIT 1'
)
);
if (isset($usr['id']) && $usr['hpNow'] >= 1) {
$iznslvl = $usr['level'];
$goodUse = 0;
$u->error = 'Вы успешно использовали &quot;' . $itm['name'] . '&quot; на ' . $usr['login'] . '';
if ($u->info['sex'] == 1) {
$this->inBattleLog(
'{u1} использовала &quot;<b>' . $itm['name'] . ' Саныча</b>&quot; на {u2}.',
$usr
);
} else {
$this->inBattleLog(
'{u1} использовал &quot;<b>' . $itm['name'] . ' Саныча</b>&quot; на {u2}.', $usr
);
}
mysql_query(
'UPDATE `stats` SET `hpNow` = "' . $usr['hpNow'] . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'
);
mysql_query(
'UPDATE `stats` SET `hpNow` = "' . $u->stats['hpNow'] . '" WHERE `id` = "' . $usr['id'] . '" LIMIT 1'
);
$itm['iznosNOW'] += $iznslvl;
mysql_query(
'UPDATE `items_users` SET `iznosNOW` = "' . $itm['iznosNOW'] . '" WHERE `id` = "' . $itm['id'] . '" AND `uid` = "' . $u->info['id'] . '" LIMIT 1'
);
$u->addAction(time(), 'sanich3', $u->info['battle']);
} else {
$u->error = 'Нет подходящего противника';
}
} else {
$u->error = 'Задержка использования ' . Conversion::secondsToTimeout(
($sz['time'] + 3 * 60 * 60) - time()
) . '.';
}
} elseif ($itm['magic_inci'] == 'lech') {
if ($itm['magic_inci'] == 'lech') {
$goodUse = 0;
if ($u->info['level'] >= 2 and $u->info['level'] <= 13) {
$travm = mysql_fetch_array(
@@ -1698,7 +1532,6 @@ class Magic
if ($goodUse == 1) {
$upd1 = 1;
$upd2 = 1;
//добавляем эффект персонажу
+27 -26
View File
@@ -1,38 +1,39 @@
<?php
use Core\Db;
use Helper\Conversion;
use Model\ActionModel;
use User\ItemsModel;
if (!defined('GAME')) {
die();
}
if ($itm['magic_inci'] == 'podvig') {
$test = mysql_fetch_array(mysql_query('SELECT `id`,`time` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "podvig" AND `time` > "' . (time()) . '" LIMIT 1'));
if ($u->info['align'] != 2) {
if (isset($test['id'])) {
$u->error = 'Задержка не прошла, еще ' . Conversion::secondsToTimeout($test['time'] - time());
} else {
//
$dngcity = [
5035 => ['angelscity', 'Бездна'],
5036 => ['capitalcity', 'Пещера Тысячи Проклятий'],
5037 => ['demonscity', 'Катакомбы'],
5038 => ['abandonedplain', 'Гора Легиона'], //mooncity
5039 => ['suncity', 'Грибница'],
5040 => ['sandcity', 'Пещера Мглы'],
];
$dngcity = $dngcity[$itm['item_id']];
$hgo1 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time` > "' . (time() - 86400) . '" AND `vars` = "psh_qt_' . $dngcity[0] . '" LIMIT 1', 1);
if (!isset($hgo1['id'])) {
$u->error = 'Нет задержки для подземелья ' . $dngcity[1] . '.';
} else {
$u->addAction(time(), 'podvig', '');
$u->error = 'Успешно использован свиток Право на Подвиг (' . $dngcity[1] . ')';
mysql_query('UPDATE `actions` SET `time` = "' . (time() - 86401) . '" WHERE `id` = "' . ($hgo1['id']) . '" LIMIT 1');
mysql_query('UPDATE `items_users` SET `iznosNOW` = `iznosNOW` + 1 WHERE `id` = "' . $itm['id'] . '" LIMIT 1');
}
}
$test = Db::getRow("select id, time from actions where uid = ? and vars = 'podvig' and time > unix_timestamp() limit 1", [$u->info['id']]);
if (isset($test['id'])) {
$u->error = 'Задержка не прошла, еще ' . Conversion::secondsToTimeout($test['time'] - time());
} else {
$u->error = 'Хаосники не могут пользоваться этим свитком!';
//
$dngcity = [
5035 => ['angelscity', 'Бездна'],
5036 => ['capitalcity', 'Пещера Тысячи Проклятий'],
5037 => ['demonscity', 'Катакомбы'],
5038 => ['abandonedplain', 'Гора Легиона'], //mooncity
5039 => ['suncity', 'Грибница'],
5040 => ['sandcity', 'Пещера Мглы'],
];
$dngcity = $dngcity[$itm['item_id']];
$hgo1 = ActionModel::getOne(["uid = {$u->info['id']}", "time > unix_timestamp() - 86400", "vars = psh_qt_$dngcity[0]"], 'id');
if (!isset($hgo1)) {
$u->error = 'Нет задержки для подземелья ' . $dngcity[1] . '.';
} else {
$u->addAction(time(), 'podvig', '');
$u->error = "Успешно использован свиток Право на Подвиг ($dngcity[1])";
Db::sql('update actions set time = unix_timestamp() - 86401 where id = ?', [$hgo1]);
ItemsModel::addIznos($itm['id']);
}
}
}
+10 -5
View File
@@ -1,4 +1,8 @@
<?php
use Model\ActionModel;
use User\ItemsModel;
if (!defined('GAME')) {
die();
}
@@ -15,15 +19,16 @@ if (isset($po['finish_file']) && $po['finish_file'] == 'tznanie') {
//Уже что-то изучаем
$u->error = 'Так не пойдет, вы уже что-то изучаете';
} else {
$tst = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `vars` = "read" AND `vals` = "' . $itm['item_id'] . '" LIMIT 1', 1);
if (isset($tst['id'])) {
$tst = (bool)ActionModel::testCount(["uid = $u->info['id']", 'vars = read', "vals = {$itm['item_id']}"]);
if ($tst) {
$u->error = 'Вы уже изучили данное знание';
} else {
$fn = '';
$tom_iz = 0;
if (($itm['item_id'] >= 1045 && $itm['item_id'] <= 1047) || ($itm['item_id'] >= 4812 && $itm['item_id'] <= 4813)) {
$tst2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `vars` = "read" AND `vals` = "' . ($itm['item_id'] - 1) . '" LIMIT 1', 1);
if (!isset($tst2['id'])) {
$tst2 = (bool)ActionModel::testCount(["uid = $u->info['id']", 'vars = read', "vals = {$itm['item_id']} - 1"]);
if (!$tst2) {
$tom_iz = 1;
}
unset($tst2);
@@ -41,7 +46,7 @@ if (isset($po['finish_file']) && $po['finish_file'] == 'tznanie') {
$u->error = 'Вы изучили &quot;' . $itm['name'] . '&quot;.';
$u->addAction(time() + $st['timeRead'], 'read', $itm['item_id']);
mysql_query('UPDATE `items_users` SET `iznosNOW` = `iznosNOW` + 1 WHERE `id` = ' . $itm['id'] . ' LIMIT 1');
ItemsModel::addIznos($itm['id']);
} else {
$u->error = 'Требует изучения предыдущего тома';
+24 -19
View File
@@ -37,9 +37,25 @@ class ActionModel
);
}
public static function getAll(string $filter = ''): array
public static function get(array $filters, string $columns = '*'): array
{
return Db::getRows('select * from actions');
$query = new QueryBuilder(self::TABLE_NAME, $columns);
try {
$stmt = $query->select($filters, 1);
return Db::getRow($stmt['sql'], $stmt['binds']);
} catch (Exception $e) {
echo $e->getMessage();
trigger_error(__METHOD__ . ': ' . $e->getMessage(), E_USER_ERROR);
}
}
public static function getOne(array $filters, string $column): mixed
{
$result = self::get($filters, $column);
if (!empty($result)) {
return array_shift($result);
}
return '';
}
public static function deleteById(int $id): void
@@ -83,6 +99,11 @@ class ActionModel
public function getLastByValsAndTime(string $vals, int $time)
{
$filter = [
"uid = $this->uid",
"vals = '$vals'",
"time > unix_timestamp() - $time",
];
return Db::getRow(
'select * from actions where uid = ? and vals = ? and time > unix_timestamp() - ? order by time desc limit 1',
[$this->uid, $vals, $time]
@@ -101,23 +122,7 @@ class ActionModel
"vars = 'day_quest'",
];
return self::getAction($filter);
}
public static function getAction(array $filters, int $limit = 1): array
{
$query = new QueryBuilder(self::TABLE_NAME);
try {
$stmt = $query->select($filters, $limit);
$result = Db::getRows($stmt['sql'], $stmt['binds']);
if (count($result) === 1 || $limit === 1) {
return $result[0];
}
return $result;
} catch (Exception $e) {
echo $e->getMessage();
trigger_error(__METHOD__ . ': ' . $e->getMessage(), E_USER_ERROR);
}
return self::get($filter);
}
public function getFinishedDailyQuestTasks(int $timeout): array
+4 -20
View File
@@ -1106,12 +1106,9 @@ class Priems
return;
}
$alreadyReleased = $this->u->testAction(
'`uid` = "' . $this->u->info['id'] . '" AND `vars` = "animal_use' . $btl->i->id . '" LIMIT 1',
1
);
$alreadyReleased = ActionModel::testCount(["uid = {$this->u->info['id']}", "vars = animal_use{$btl->i->id}"]);
if (!empty($alreadyReleased['id'])) {
if (!empty($alreadyReleased)) {
echo 'Вы уже выпускали зверя в этом бою ...';
return;
}
@@ -2070,21 +2067,11 @@ class Priems
public function getTechniquesInfo(?int $id = null): array
{
# SELECT * FROM `priems` WHERE `level`<="' . $this->u->info['level'] . '" AND `activ` > "0" AND `id` = "' . $id . '" LIMIT 1
if (isset($id)) {
return Db::getRow('select * from priems where level <= ? and activ > 0 and id = ? order by img,level', [$this->u->info['level'], $id]);
// return Db::getRow(
// 'select * from techniques_categories left join priems on techniques_categories.technique_id = priems.id
// where priems.level <= ? and priems.activ > 0 and priems.id = ? order by priems.img,priems.level', [User::start()->info['level'], $id]
// );
}
return Db::getRows('select * from priems where level <= ? and activ > 0 order by img,level', [$this->u->info['level']]);
// return Db::getRows(
// 'select * from techniques_categories left join priems on techniques_categories.technique_id = priems.id
// where priems.level <= ? and priems.activ > 0 order by priems.img,priems.level', [User::start()->info['level']]
// );
}
public function seeMyPriems(): void
@@ -2291,11 +2278,8 @@ class Priems
$i++;
}
if ($this->u->info['animal'] > 0) {
$use_lst = $this->u->testAction(
'`uid` = "' . $this->u->info['id'] . '" AND `vars` = "animal_use' . $btl->i->id . '" LIMIT 1',
1
);
if (!isset($use_lst['id'])) {
$use_lst = (bool)ActionModel::testCount(["uid = {$this->u->info['id']}", "vars = animal_use{$btl->i->id}"]);
if (!$use_lst) {
$pr .= '<a onMouseOver="top.hi(this,\'<b>Выпустить зверя</b><Br>Ваш зверь вмешивается в поединок. Можно применять один раз за бой.\',event,3,0,1,1,\'width:240px\');" onMouseOut="top.hic();" onMouseDown="top.hic();" href="javascript:void(0);" onClick="usepriem(100500);"><img style="margin-top:1px; margin-left:3px;" src="//img.new-combats.tech/i/eff/pet_unleash.gif" width="40" height="25" /></a>';
} else {
$pr .= '<img onMouseOver="top.hi(this,\'<b>Выпустить зверя</b><Br>Ваш зверь вмешивается в поединок. Можно применять один раз за бой.\',event,3,0,1,1,\'width:240px\');" onMouseOut="top.hic();" onMouseDown="top.hic();" style="margin-top:1px; margin-left:2px;" class="nopriemuse" src="//img.new-combats.tech/i/eff/pet_unleash.gif" width="40" height="25" />';
+62 -67
View File
@@ -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();
+5
View File
@@ -211,4 +211,9 @@ class ItemsModel
}
return $rt;
}
public static function addIznos(int $itemId): void
{
Db::sql('update items_users set iznosNOW = iznosNOW + 1 where id = ?', [$itemId]);
}
}