diff --git a/_incl_data/class/Battle/Finish.php b/_incl_data/class/Battle/Finish.php
index ea7b96e7..5feb10da 100644
--- a/_incl_data/class/Battle/Finish.php
+++ b/_incl_data/class/Battle/Finish.php
@@ -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'
diff --git a/_incl_data/class/Helper/QueryBuilder.php b/_incl_data/class/Helper/QueryBuilder.php
index 16c27581..a27facd2 100644
--- a/_incl_data/class/Helper/QueryBuilder.php
+++ b/_incl_data/class/Helper/QueryBuilder.php
@@ -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)) {
diff --git a/_incl_data/class/Magic.php b/_incl_data/class/Magic.php
index ec88e856..dce02ff9 100644
--- a/_incl_data/class/Magic.php
+++ b/_incl_data/class/Magic.php
@@ -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} использовала "' . $itm['name'] . ' Саныча".');
- } else {
- $this->inBattleLog('{u1} использовал "' . $itm['name'] . ' Саныча".');
- }
- 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 = 'Вы успешно использовали "' . $itm['name'] . '" на ' . $usr['login'] . '';
-
- if ($u->info['sex'] == 1) {
- $this->inBattleLog(
- '{u1} использовала "' . $itm['name'] . ' Саныча" на {u2}.',
- $usr
- );
- } else {
- $this->inBattleLog(
- '{u1} использовал "' . $itm['name'] . ' Саныча" на {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;
//добавляем эффект персонажу
diff --git a/_incl_data/class/Magic/podvig.php b/_incl_data/class/Magic/podvig.php
index 00e1eb30..9b69f509 100644
--- a/_incl_data/class/Magic/podvig.php
+++ b/_incl_data/class/Magic/podvig.php
@@ -1,38 +1,39 @@
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']);
+ }
}
+
}
diff --git a/_incl_data/class/Magic/tznanie.php b/_incl_data/class/Magic/tznanie.php
index b4f7a607..e08beb0c 100644
--- a/_incl_data/class/Magic/tznanie.php
+++ b/_incl_data/class/Magic/tznanie.php
@@ -1,4 +1,8 @@
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 = 'Вы изучили "' . $itm['name'] . '".';
$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 = 'Требует изучения предыдущего тома';
diff --git a/_incl_data/class/Model/ActionModel.php b/_incl_data/class/Model/ActionModel.php
index d60abdc4..704b53a6 100644
--- a/_incl_data/class/Model/ActionModel.php
+++ b/_incl_data/class/Model/ActionModel.php
@@ -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
diff --git a/_incl_data/class/Priems.php b/_incl_data/class/Priems.php
index ea36212d..6d4b1a2d 100644
--- a/_incl_data/class/Priems.php
+++ b/_incl_data/class/Priems.php
@@ -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 .= '';
} else {
$pr .= '
';
diff --git a/_incl_data/class/User.php b/_incl_data/class/User.php
index d69569db..64ace6be 100644
--- a/_incl_data/class/User.php
+++ b/_incl_data/class/User.php
@@ -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 = "Закончилось действие эффекта «{$e['name']}»";
$cmsg = new ChatMessage();
diff --git a/_incl_data/class/User/ItemsModel.php b/_incl_data/class/User/ItemsModel.php
index b3969e96..1f2763a5 100644
--- a/_incl_data/class/User/ItemsModel.php
+++ b/_incl_data/class/User/ItemsModel.php
@@ -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]);
+ }
}
\ No newline at end of file
diff --git a/buttons.php b/buttons.php
index 4cd0b7a1..d4d514ac 100644
--- a/buttons.php
+++ b/buttons.php
@@ -1162,8 +1162,6 @@ if (!isset($_COOKIE['d1c'])) {
info['active'] != '' && $u->info['mail'] != 'No E-mail') {
- $yes = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `vars` = "user_active_good" LIMIT 1', 1);
- $yes2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `vars` = "user_active_send" LIMIT 1', 1);
Db::sql('update stats set active = default where id = ?', [$u->info['id']]);
}
?>
diff --git a/main.php b/main.php
index d061e136..2b4f03ab 100644
--- a/main.php
+++ b/main.php
@@ -4,6 +4,7 @@ if (!defined('GAME_VERSION')) {
}
use Core\{Config, Database, Db};
+use Model\ActionModel;
use User\ItemsModel;
use User\UserIp;
@@ -43,9 +44,9 @@ if ($u->info['bithday'] == '01.01.1800' && $u->info['inTurnirnew'] == 0) {
}
#--------для общаги, и позже для почты
-$sleep = $u->testAction('`vars` = "sleep" AND `uid` = "' . $u->info['id'] . '" LIMIT 1', 1);
+$sleep = ActionModel::getOne(["uid = {$u->info['id']}", 'vars = sleep'], 'id');
if ($u->room['file'] != "room_hostel" && $u->room['file'] != "an/room_hostel" && !empty($sleep)) {
- Db::sql('update actions set vars = ? where id = ?', ['unsleep', $sleep['id']]);
+ Db::sql('update actions set vars = ? where id = ?', ['unsleep', $sleep]);
}
if ($u->room['file'] == "room_hostel" || $u->room['file'] == "post") {
$trololo = 0;
@@ -255,7 +256,7 @@ if ($magic->youuse > 0) {
if ($act != -2) {
$u->stats = $u->getStats($u->info['id'], 0, 1);
$u->aves = ItemsModel::inventoryWeightAndItemQuantity();
- if (!isset($sleep['id'])) {
+ if (empty($sleep)) {
$act2 = $u->testItems($u->info['id'], $u->stats, 0);
}
if ($act2 != -2 && $act == -2) {
@@ -413,7 +414,7 @@ if (isset($btl_last['id']) && $u->info['battle'] == 0) {
$u->info['battle_lsto'] = true;
} elseif ($u->info['battle'] == 0) {
//Проверка/Снятие предметов
- if (!isset($sleep['id'])) {
+ if (empty($sleep)) {
$act2 = $u->testItems($u->info['id'], $u->stats, 0);
}
if ($act2 != -2 && $act == -2) {
diff --git a/main_bot.php b/main_bot.php
index 26c32a84..93a5c4dd 100644
--- a/main_bot.php
+++ b/main_bot.php
@@ -1,7 +1,9 @@
testAction('`vars` = "sleep" AND `uid` = "' . $u->info['id'] . '" LIMIT 1', 1);
-if ($u->room['file'] != "objaga" && $sleep['id'] > 0) {
- mysql_query('UPDATE `actions` SET `vars` = "unsleep" WHERE `id` = ' . $sleep['id']);
+$sleep = ActionModel::getOne(["uid = {$u->info['id']}", 'vars = sleep'], 'id');
+if ($u->room['file'] != "objaga" && $sleep > 0) {
+ mysql_query('UPDATE `actions` SET `vars` = "unsleep" WHERE `id` = ' . $sleep);
}
$trololo = $u->room['file'] == "objaga" || $u->room['file'] == "post" ? 0 : 1;
@@ -79,7 +81,7 @@ if ($u->info['online'] < time() - 60) {
}
if (!isset($u->info['id']) || ($u->info['joinIP'] == 1 && $u->info['ip'] != $_SERVER['HTTP_X_REAL_IP']) || $u->info['banned'] > 0) {
- die($c['exit']);
+ die(Config::get('exit'));
}
if (isset($_GET['atak_user']) && $u->info['battle'] == 0 && $_GET['atak_user'] != $u->info['id']) {
@@ -110,7 +112,6 @@ if (isset($_GET['atak_user']) && $u->info['battle'] == 0 && $_GET['atak_user'] !
$rtxt = '[img[items/pal_button8.gif]] "' . $u->info['login'] . '" совершил' . $sx . ' нападение по метке на персонажа "' . $ua['login'] . '".';
$cmsg = new ChatMessage();
- $cmsg->setCity($u->info['city']);
$cmsg->setRoom($u->info['room']);
$cmsg->setText($rtxt);
$cmsg->setType(6);
@@ -168,75 +169,9 @@ if ($ul == 1) {
$act = 1;
}
-//// Непонятно что это, потому что переменной 'repass' не существует и этот код никогда не выполняется. 15.08.2023, Инс.
-//if ($u->info['repass'] > 0 && $u->info['id'] != 5433446) {
-//
-// /*-----------------------*/
-// if ($u->info['battle'] == 0) {
-// if ($act2 != -2 && $act == -2) {
-// $act = $act2;
-// }
-//
-// if (!isset($u->tfer['id']) && $u->room['block_all'] == 0) {
-// //Одеть/снять предмет
-// if (isset($_GET['rstv']) && isset($_GET['inv'])) {
-// $act = $u->freeStatsMod($_GET['rstv'], $_GET['mf'], $u->info['id']);
-// } elseif (isset($_GET['ufs2']) && isset($_GET['inv'])) {
-// $act = $u->freeStats2Item($_GET['itmid'], $_GET['ufs2'], $u->info['id'], 1);
-// } elseif (isset($_GET['ufs2mf']) && isset($_GET['inv'])) {
-// $act = $u->freeStats2Item($_GET['itmid'], $_GET['ufs2mf'], $u->info['id'], 2);
-// } elseif (isset($_GET['ufsmst']) && isset($_GET['inv'])) {
-// $act = $u->itemsSmSave($_GET['itmid'], $_GET['ufsmst'], $u->info['id']);
-// } elseif (isset($_GET['ufsms']) && isset($_GET['inv'])) {
-// $act = $u->itemsSmSave($_GET['itmid'], $_GET['ufsms'] + 100, $u->info['id']);
-// } elseif (isset($_GET['ufs']) && isset($_GET['inv'])) {
-// $act = $u->freeStatsItem($_GET['itmid'], $_GET['ufs'], $u->info['id']);
-// } elseif (isset($_GET['sid']) && isset($_GET['inv'])) {
-// $act = $u->snatItem($_GET['sid'], $u->info['id']);
-// } elseif (isset($_GET['oid']) && isset($_GET['inv'])) {
-// $act = $u->odetItem($_GET['oid'], $u->info['id']);
-// } elseif (isset($_GET['item_rune']) && isset($_GET['inv'])) {
-// $act = $u->runeItem(null);
-// } elseif (isset($_GET['remitem'], $_GET['inv'])) {
-// $act = $u->snatItemAll($u->info['id']);
-// } elseif (isset($_GET['delete']) && isset($_GET['inv']) && $u->newAct($_GET['sd4'])) {
-// $u->deleteItem(intval($_GET['delete']), $u->info['id']);
-// } elseif (isset($_GET['stack']) && isset($_GET['inv'])) {
-// $u->stack($_GET['stack']);
-// } elseif (isset($_GET['unstack']) && isset($_GET['inv'])) {
-// $u->unstack($_GET['unstack']);
-// } elseif (isset($_GET['end_qst_now'])) {
-// $q->endq((int)$_GET['end_qst_now'], 'end');
-// }
-// //Использовать эффект
-// if (isset($_GET['use_pid'])) {
-// $magic->useItems((int)$_GET['use_pid']);
-// }
-// }
-//
-// } elseif ($u->info['battle_text'] != '') {
-// Db::sql('update stats set battle_text = ?, last_b = 0 where id = ?', ['', $u->info['id']]);
-// }
-//
-// if ($magic->youuse > 0) {
-// $act = 1;
-// }
-// //Получение статов
-// if ($act != -2) {
-// $u->stats = $u->getStats($u->info['id'], 0, 1);
-// $u->aves = \User\ItemsModel::inventoryWeightAndItemQuantity();
-// $act2 = $u->testItems($u->info['id'], $u->stats, 0);
-// if ($act2 != -2 && $act == -2) {
-// $act = $act2;
-// }
-// }
-//}
-
if (
(isset($_GET['zayvka']) && $u->info['battle'] == 0) ||
(isset($_GET['zayvka']) && ($_GET['r'] == 6 || $_GET['r'] == 7 || !isset($_GET['r'])) && $u->info['battle'] > 0) &&
!isset($u->tfer['id'])) {
include('modules_data/_zv.php');
}
-
-mysql_query('UNLOCK TABLES');
diff --git a/modules_data/_locations.php b/modules_data/_locations.php
index 7cc2121c..23a6dddc 100644
--- a/modules_data/_locations.php
+++ b/modules_data/_locations.php
@@ -1,6 +1,5 @@
testAction(
- '`vars` = "sleep" AND `uid` = "' . $u->info['id'] . '" LIMIT 1',
- 1
- );
- if (isset($sleep['id']) && $sleep['vars'] == 'sleep' && $go['name'] != 'Общ. Этаж 1' && $go['name'] != 'Общ. Этаж 2' && $go['name'] != 'Общ. Этаж 3') {
+ $sleep = (bool)ActionModel::testCount(["uid = $u->info['id']", 'vars = sleep']);
+ if ($sleep && $go['name'] != 'Общ. Этаж 1' && $go['name'] != 'Общ. Этаж 2' && $go['name'] != 'Общ. Этаж 3') {
$re = 'Вы можете перемещаться только когда бодрствуете.';
echo ' ' . $re;
} elseif ($u->info['timeGo'] >= time()) {
@@ -254,10 +250,8 @@ if (isset($_GET['loc'])) {
Db::sql('update bs_zv set finish = unix_timestamp() where uid = ? and inBot = 0 and finish = 0', [$u->info['id']]);
}
- $smt = $u->testAction(
- '`uid` = "' . $u->info['id'] . '" AND `time`>=' . (time() - 600) . ' AND `vars` = "create_snowball_cp" LIMIT 1',
- 1
- );
+ $smt = ActionModel::getOne(["uid = {$u->info['id']}", "time >= unix_timestamp() - 600", 'vars = create_snowball_cp'], 'id');
+
if (isset($smt['id'])) {
ActionModel::deleteById($smt['id']);
}
diff --git a/modules_data/_umenie.php b/modules_data/_umenie.php
index c593a32d..5a9066b3 100644
--- a/modules_data/_umenie.php
+++ b/modules_data/_umenie.php
@@ -9,6 +9,7 @@ use Core\Config;
use DarksLight2\Battle\Techniques\TechniqueCategoryEntity;
use DarksLight2\Training\TrainingManager;
use Helper\Conversion;
+use Model\ActionModel;
use Model\Constant\Stat;
if (!defined('GAME')) {
@@ -2318,12 +2319,10 @@ $tma = '';
echo '
- getInfoPers($u->info['id'],0); if($usee!=false){ echo $usee[0]; }else{ echo 'information is lost.'; } ?> - | -- |
- error!=''){ echo ''.$u->error.''; } ?>
-
+ = $rowonmax; ?> + + |
+