From d41147da45570583d701b4bbd6f6faee98144ccd Mon Sep 17 00:00:00 2001 From: Ivor Barhansky Date: Tue, 10 Dec 2024 13:09:03 +0200 Subject: [PATCH] WIP: new battle --- _incl_data/class/Battle/BattleHTML.php | 62 ++ _incl_data/class/Battle/Fighter.php | 69 +- _incl_data/class/Clan/ItemStorage.php | 211 ++--- _incl_data/class/ComissionShop.php | 236 ++--- _incl_data/class/Magic.php | 2 +- _incl_data/class/Model/ActionModel.php | 17 +- _incl_data/class/User.php | 1082 +++++++++------------- _incl_data/class/User/ItemsModel.php | 26 +- _incl_data/crons/cshop_returnToOwner.php | 3 +- jx/battle/refresh.php | 3 +- jx/battle/refresh1.php | 4 +- jx/battle/refresh2.php | 24 +- main.php | 2 +- modules_data/_clan.php | 114 +-- modules_data/location/commision2.php | 4 +- modules_data/stats_loc.php | 252 +++-- register.php | 5 +- transfer.php | 5 +- 18 files changed, 1010 insertions(+), 1111 deletions(-) create mode 100644 _incl_data/class/Battle/BattleHTML.php diff --git a/_incl_data/class/Battle/BattleHTML.php b/_incl_data/class/Battle/BattleHTML.php new file mode 100644 index 00000000..79e58ac2 --- /dev/null +++ b/_incl_data/class/Battle/BattleHTML.php @@ -0,0 +1,62 @@ +'); + + foreach (User::start()->stats['items'] as $stat) { + if (!in_array($stat['inslot'], [40, 51])) { + continue; + } + if (empty($stat['useInBattle']) || $stat['btl_zd'] > 0 || $stat['iznosNOW'] >= $stat['iznosMAX'] || empty($stat['magic_inci'])) { + $vl = 'class="nopriemuse"'; + } else { + $po = Conversion::dataStringToArray($stat['data']); + if ($po['useOnLogin'] == 1) { + $jsvars = "'{$stat['name']}','{$stat['id']}','{$stat['img']}',1,1,'','{$stat['useInBattle']}'"; + } else { + $jsvars = "'{$stat['name']}','{$stat['id']}','{$stat['img']}',1,2"; + } + $vl = 'style="cursor:pointer" onclick="top.useMagicBattle(' . $jsvars . ')"'; + } + $iznos = "Долговечность: {$stat['iznosNOW']} / {$stat['iznosMAX']}"; + $img = Config::img() . '/i/items/' . $stat['img']; + + $sv[$stat['inOdet'] - 39] = ''; + } + + return << + + $sv[1] + $sv[2] + $sv[3] + $sv[4] + $sv[5] + $sv[6] + $sv[7] + $sv[8] + $sv[9] + $sv[10] + $sv[11] + $sv[12] + + + HTML; + + //Если сломается, применить str_replace('"', '\"', $r); + } +} \ No newline at end of file diff --git a/_incl_data/class/Battle/Fighter.php b/_incl_data/class/Battle/Fighter.php index f1dbe9e9..70bed3ca 100644 --- a/_incl_data/class/Battle/Fighter.php +++ b/_incl_data/class/Battle/Fighter.php @@ -32,8 +32,11 @@ class Fighter private int $firedefence; private int $earthdefence; private int $armor; - public function __construct(private readonly int $id, private readonly int $team) { - $u = User::start($id); + private int $team; + + public function __construct(private readonly int $id) + { + $u = User::start($id, true); $this->obraz = $u->info['sex'] . DIRECTORY_SEPARATOR . $u->info['obraz']; $this->login = $u->info['login']; $this->level = $u->info['level']; @@ -41,8 +44,8 @@ class Fighter $this->mana = $u->stats['mpNow']; $this->maxlife = $u->stats['hpAll']; $this->maxmana = $u->stats['mpAll']; - $this->damage = 100500; - $this->armor = 35; + $this->damage = mt_rand(0, 100); + $this->armor = mt_rand(0, 5); $this->damageMultiplier = $u->stats['m10']; $this->critChance = $u->stats['m1']; $this->critMultiplier = $u->stats['m3']; @@ -58,37 +61,49 @@ class Fighter $this->waterdefence = $u->stats['zm3']; $this->firedefence = $u->stats['zm1']; $this->earthdefence = $u->stats['zm4']; + $this->team = $u->info['team']; unset($u); } + public function get(): object + { + return (object)[ + 'damage' => $this->damage, + 'armor' => $this->armor + $this->defence, + 'health' => $this->life, + 'name' => $this->login, + 'crit' => $this->critChance, + 'evade' => $this->evadeChance, + ]; + } + public function __toString(): string { $dmg = Math::addPercent($this->damage, $this->damageMultiplier); return <<login [$this->level] id:$this->id
-Здоровье: $this->life / $this->maxlife
-Мана: $this->mana / $this->maxmana
-
-Урон: $this->damage + $this->damageMultiplier% = $dmg
-Броня: $this->armor
-Крит: $this->critChance%
-Антикрит $this->anticritChance%
-Мощность крита $this->critMultiplier%
-Уровот $this->evadeChance%
-Антиуворот $this->antievadeChance%
-Контрудар $this->counterstrikeChance%
-Парирование $this->parryChance%
-Блок щитом $this->shieldblockChance%
-Игнор брони $this->ignoreArmorChance%
-Защита от урона $this->defence
-Зашита от огня $this->firedefence
-Защита от воды $this->waterdefence
-Защита от воздуха $this->airdefence
-Защита от земли $this->earthdefence

-Сражается за команду: $this->team -RETURN; - + $this->login [$this->level] id:$this->id
+ Здоровье: $this->life / $this->maxlife
+ Мана: $this->mana / $this->maxmana

+ + Урон: $this->damage + $this->damageMultiplier% = $dmg
+ Броня: $this->armor

+ Крит: $this->critChance%
+ Антикрит $this->anticritChance%
+ Мощность крита $this->critMultiplier%
+ Уровот $this->evadeChance%
+ Антиуворот $this->antievadeChance%
+ Контрудар $this->counterstrikeChance%
+ + + + Защита от урона $this->defence
+ Зашита от огня $this->firedefence
+ Защита от воды $this->waterdefence
+ Защита от воздуха $this->airdefence
+ Защита от земли $this->earthdefence

+ Сражается за команду: $this->team + RETURN; } } diff --git a/_incl_data/class/Clan/ItemStorage.php b/_incl_data/class/Clan/ItemStorage.php index 4e0ba0aa..2cacf46a 100644 --- a/_incl_data/class/Clan/ItemStorage.php +++ b/_incl_data/class/Clan/ItemStorage.php @@ -10,29 +10,103 @@ use User\ItemsModel; class ItemStorage { - private string $error = ''; - public function put(int $itemId, int $clanId): string + private string $error = ''; + private int $clanId; + private int $userId; + private string $userLogin; + + public function __construct() { - $user = User::start()->info; - $item = ItemsModel::getOwnedItemById($itemId, $user['id']); - $clanName = Db::getValue('select name from clan where id = ?', [$clanId]) ?? ''; + $userinfo = User::start()->info; + $this->userId = $userinfo['id']; + $this->clanId = $userinfo['clan']; + $this->userLogin = $userinfo['login']; + } + + public function take(int $itemId): string + { + $item = Db::getRows('select items_users.id, name, data from items_users inner join items_main on item_id = items_main.id where uid = ? and items_users.id = ?', ["-21$this->clanId", $itemId]); + + if (!isset($item['id'])) { + return 'Предмет не найден.
' . $itemId; + } + + $data = Conversion::dataStringToArray($item['data']); + $cls = isset($data['toclan']) ? explode('#', $data['toclan'])[1] : 0; + $col = ItemsModel::itemsX($itemId); + + Db::sql('update items_users set lastUPD = unix_timestamp(), uid = ? where id = ?', [$this->userId, $itemId]); + Db::sql('insert into clan_operations (clan, type, text, time, val, uid) values (?,5,?,unix_timestamp(),?,?)', [$this->clanId, $this->userLogin, "{$item['name']} (x$col) Id:$itemId Хозяин: $cls", $this->userId]); + + return "Вы успешно взяли предмет «{$item['name']}» из хранилища."; + } + + public function remove(int $type): void + { + $storedItems = Db::getRows('select items_users.id, uid, name, data, inOdet from items_users inner join items_main on item_id = items_main.id where uid = ? or data like ?', ["-21$this->clanId", "%toclan=$this->clanId#%"]); + + foreach ($storedItems as $storedItem) { + $data = Conversion::dataStringToArray($storedItem['data']); + $cls = isset($data['toclan']) ? explode('#', $data['toclan'])[1] : 0; + $col = ItemsModel::itemsX($storedItem['id']); + + if ($cls == $this->userId) { + if ($storedItem['uid'] != $this->userId && $storedItem['inOdet'] != 0) { + Db::sql('update items_users set inOdet = 0 where id = ?', [$storedItem['id']]); + } + unset($data['toclan']); + $storedItem['data'] = Conversion::arrayToDataString($data); + Db::sql('update items_users set lastUPD = unix_timestamp(), uid = ?, data = ? where id = ?', [$this->userId, $storedItem['data'], $storedItem['id']]); + Db::sql('insert into clan_operations (clan, type, text, time, val, uid) values (?,?,?,unix_timestamp(),?,?)', [$this->clanId, $type, $this->userLogin, "{$storedItem['name']} (x$col) Id:{$storedItem['id']}", $this->userId]); + } elseif ($storedItem['uid'] == $this->userId) { + Db::sql('update items_users set lastUPD = unix_timestamp(), uid = ? where id = ?', ["-21$this->clanId", $storedItem['id']]); + Db::sql('insert into clan_operations (clan, type, text, time, val, uid) values (?,9,?,unix_timestamp(),?,?)', [$this->clanId, $this->userLogin, "{$storedItem['name']} (x$col) Id:{$storedItem['id']}", $this->userId]); + } + } + } + + public function backToOwner(int $itemId): string + { + $item = ItemsModel::getOwnedItemById($itemId, $this->userId, true); + if (empty($item)) { + return 'Предмет не найден.'; + } + + $ownerIsNotReal = !Db::getValue('select count(id) from stats where id = ? and (bot = 0 or clone = 0)', [$item['uid']]); + if ($ownerIsNotReal) { + return 'Вы не можете изьять данный предмет, он не принадлежит клану.'; + } + + $iw = $item['inOdet'] > 0 ? 'inOdet = 0' : ''; + $col = ItemsModel::itemsX($itemId); + + Db::sql('insert into clan_operations (clan, type, text, time, val, uid) values (?,6,?,unix_timestamp(),?,?)', [$this->clanId, $this->userLogin, "{$item['name']} (x$col) Id:$itemId У персонажа: {$item['uid']}", $this->userId]); + Db::sql("update items_users set lastUPD = unix_timestamp(), $iw, uid = ? where id = ?", ["-21$this->clanId", $itemId]); + + return "Вы успешно изъяли предмет «{$item['name']}»"; + } + + public function put(int $itemId): string + { + $item = ItemsModel::getOwnedItemById($itemId, $this->userId); + $clanName = Db::getValue('select name from clan where id = ?', [$this->clanId]) ?? ''; if (empty($clanName)) { return 'Клан не найден.'; } - if (!$this->isGoodForStorage($item, $user['clan'])) { + if (!$this->isGoodForStorage($item)) { return $this->error; } - $col = User::start()->itemsX(($itemId)); + $col = ItemsModel::itemsX($itemId); $idata = Conversion::dataStringToArray($item['data']); if (!isset($idata['toclan'])) { - $idata['toclan'] = $user['clan'] . '#' . $user['id']; + $idata['toclan'] = $this->clanId . '#' . $this->userId; $item['data'] = Conversion::arrayToDataString($idata); Delo::add( 2, 'System.transfer.clan', - $user['id'], - '"System.transfer.MONEY": Предмет "' . $item['name'] . '" (#id : "' . $itemId . '") (x' . $col . ') был пожертвован клану "' . $clanName . '" (' . $clanId . ').', + $this->userId, + '"System.transfer.MONEY": Предмет "' . $item['name'] . '" (#id : "' . $itemId . '") (x' . $col . ') был пожертвован клану "' . $clanName . '" (' . $this->clanId . ').', ); $sendType = 4; } else { @@ -40,17 +114,17 @@ class ItemStorage } Db::sql( 'insert into clan_operations (clan, time, type, text, val, uid) values (?,unix_timestamp(),?,?,?,?)', - [$clanId, $sendType, $user['login'], $item['name'] . ("x$col Ид: [$itemId]"), $user['id']] + [$this->clanId, $sendType, $this->userLogin, $item['name'] . ("x$col Ид: [$itemId]"), $this->userId] ); Db::sql( 'update items_users set lastUPD = unix_timestamp(), uid = ?, data = ? where id = ?', - ['-21' . $user['clan'], $item['data'], $itemId] + ['-21' . $this->clanId, $item['data'], $itemId] ); return 'Вы передали предмет "' . $item['name'] . '" клану.'; } - private function isGoodForStorage(array $item, $userClanId): bool + private function isGoodForStorage(array $item): bool { if (empty($item['inslot']) || !empty($item['gift'])) { $this->error = 'Предмет не найден.'; @@ -64,118 +138,9 @@ class ItemStorage ) { $this->error = 'Предмет не подходит.'; } - if (!empty($idata['toclan']) && explode('#', $idata['toclan'])[0] == $userClanId) { + if (!empty($idata['toclan']) && explode('#', $idata['toclan'])[0] == $this->clanId) { $this->error = 'Предмет уже принадлежит клану.'; } return empty($this->error); } - - public function ungive_itm_cl($id, $user, $cl): string - { - $itm_ = mysql_fetch_array( - mysql_query( - 'SELECT `iu`.*, `im`.* FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON `iu`.`item_id` = `im`.`id` WHERE `iu`.`uid` >= 0 AND `iu`.`delete` = 0 AND `iu`.`id` = "' . $id . '" LIMIT 1' - ) - ); - $res = mysql_fetch_array(mysql_query('SELECT * FROM `clan` WHERE `id` = "' . $cl . '" LIMIT 1')); - $user_itm = mysql_fetch_array( - mysql_query('SELECT `id`,`bot`,`clone` FROM `stats` WHERE `id` = "' . $itm_['uid'] . '" LIMIT 1') - ); - if ($user_itm['bot'] > 0 || $user_itm['clone'] > 0 || !isset($user_itm['id'])) { - $r = 'Вы не можете изьять данный предмет, он не принадлежит клану
'; - } elseif (isset($itm_['id'])) { - - if ($itm_['inOdet'] != 0) { - $o = ', `inOdet` = 0'; - } else { - $o = ''; - } - $r = 'Вы успешно изъяли предмет "' . $itm_['name'] . '"
'; - $col = $this->itemsX(((int)$id)); - mysql_query( - 'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "6", "' . $user['login'] . '", "' . $itm_['name'] . ' (x' . $col . ') Ид : [' . $id . '] | У персонажа : [' . $itm_['uid'] . ']", "' . $user['id'] . '")' - ); - mysql_query( - 'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "-21' . $res['id'] . '" ' . $o . ' WHERE `id` = "' . $id . '" LIMIT 1' - ); - - } else { - $r = 'Предмет не найден.
'; - } - return $r; - } - - public function take_itm_cl($id, $user, $cl): string - { - $itm_ = mysql_fetch_array( - mysql_query( - 'SELECT `iu`.*, `im`.* FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON `iu`.`item_id` = `im`.`id` WHERE `iu`.`uid` = "-21' . $user['clan'] . '" AND `iu`.`delete` = 0 AND `iu`.`id` = "' . $id . '" LIMIT 1' - ) - ); - $res = mysql_fetch_array(mysql_query('SELECT * FROM `clan` WHERE `id` = "' . $cl . '" LIMIT 1')); - if (isset($itm_['id'])) { - $po = Conversion::dataStringToArray($itm_['data']); - if (isset($po['toclan'])) { - $cls = explode('#', $po['toclan']); - $cls = $cls[1]; - } - - $col = $this->itemsX(((int)$id)); - mysql_query( - 'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "5", "' . $user['login'] . '", "' . $itm_['name'] . ' (x' . $col . ') Ид : [' . $id . '] Хозяин : [' . $cls . ']", "' . $user['id'] . '")' - ); - mysql_query( - 'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "' . $user['id'] . '" WHERE `id` = "' . $id . '" LIMIT 1' - ); - $r = 'Вы успешно взяли предмет "' . $itm_['name'] . '" из хранилища
'; - - } else { - $r = 'Предмет не найден.
' . $id; - } - return $r; - } - - public function rem_itm_cl($user, $cl, $type) - { - $itms = mysql_query( - 'SELECT * FROM `items_users` WHERE (`uid` = "-21' . $user['clan'] . '" OR `data` LIKE "%toclan=' . $user['clan'] . '#%")' - ); - while ($pl = mysql_fetch_array($itms)) { - $po = Conversion::dataStringToArray($pl['data']); - if (isset($po['toclan'])) { - $cls = explode('#', $po['toclan']); - $cls = $cls[1]; - } - if ($cls == $user['id']) { - if ($pl['uid'] != $user['id']) { - if ($pl['inOdet'] != 0) { - mysql_query('UPDATE `items_users` SET `inOdet` = 0 WHERE `id` = "' . $pl['id'] . '"'); - } - } - unset($po['toclan']); - $pl['data'] = Conversion::arrayToDataString($po); - $col = $this->itemsX(((int)$pl['id'])); - $it_n = mysql_fetch_array( - mysql_query('SELECT `name` FROM `items_main` WHERE `id` = "' . $pl['item_id'] . '"') - ); - mysql_query( - 'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "' . $user['id'] . '", `data` = "' . $pl['data'] . '" WHERE `id` = "' . $pl['id'] . '"' - ); - mysql_query( - 'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "' . $type . '", "' . $user['login'] . '", "' . $it_n['name'] . ' (x' . $col . ') Ид : [' . $pl['id'] . ']", "' . $user['id'] . '")' - ); - } elseif ($pl['uid'] == $user['id']) { - $col = $this->itemsX(((int)$pl['id'])); - $it_n = mysql_fetch_array( - mysql_query('SELECT `name` FROM `items_main` WHERE `id` = "' . $pl['item_id'] . '"') - ); - mysql_query( - 'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "-21' . $user['clan'] . '" WHERE `id` = "' . $pl['id'] . '"' - ); - mysql_query( - 'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "9", "' . $user['login'] . '", "' . $it_n['name'] . ' (x' . $col . ') Ид : [' . $pl['id'] . ']", "' . $user['id'] . '")' - ); - } - } - } } diff --git a/_incl_data/class/ComissionShop.php b/_incl_data/class/ComissionShop.php index 1499787c..9b36e7c4 100644 --- a/_incl_data/class/ComissionShop.php +++ b/_incl_data/class/ComissionShop.php @@ -2,10 +2,35 @@ use Core\Db; use Helper\Conversion; +use Model\Constant\Stat; +use User\ItemsModel; class ComissionShop { - public function commisionShop($preview = 'full') + private array $info; + private array $stats; + private array $is; + private array $rep; + /** + * @var array|string[] + */ + private array $align_nm; + private array $items; + + public function __construct() + { + $this->info = User::start()->info; + $this->rep = User::start()->rep; + $this->stats = User::start()->stats; + $this->is = User::start()->is; + $this->align_nm = User::start()->align_nm; + $itemStatNames = new Stat(); + $itemStatNames->getBonus(); + $itemStatNames->getRequirement(); + $this->items['tr'] = $itemStatNames->sysRequirementNames; + } + + public function commisionShop($preview = 'full'): void { global $code; $typeOtdel = match ((int)$_GET['otdel']) { @@ -43,8 +68,8 @@ UNION ALL SELECT `items_users`.`id`,`items_users`.`item_id`,`items_users`.`1pric FROM `items_users` LEFT JOIN `items_main` ON (`items_main`.`id` = `items_users`.`item_id`) WHERE (( `items_users`.time_create + `items_main`.srok) > unix_timestamp() OR `items_main`.srok = "0") AND `items_users`.`delete`="0" AND `items_users`.`inOdet`="0" AND `items_users`.`inShop`="30" and `items_main`.`type` = "' . mysql_real_escape_string( $typeOtdel - ) . '" and `items_users`.`item_id` = "' . (int)$_GET['itemid'] . '" GROUP BY `items_users`.`uid`, `items_users`.`1price` HAVING `items_users`.inGroup = 0 -ORDER BY `1price`ASC , inGroupCount DESC' + ) . '" and `items_users`.`item_id` = "' . (int)$_GET['itemid'] . '" GROUP BY `items_users`.`uid`, `items_users`.`1price` HAVING `items_users`.inGroup = 0 +ORDER BY `1price`, inGroupCount DESC' ); } else { $cl = mysql_query( @@ -56,7 +81,7 @@ ORDER BY `1price`ASC , inGroupCount DESC' } else { if ($preview == "full") { $cl = mysql_query( - 'SELECT + 'SELECT `items_users`.`id` as id, `items_users`.`id` AS `idu`,`items_users`.`item_id` as item_id,`items_users`.`1price`,`items_users`.`2price`,`items_users`.`uid`,`items_users`.`use_text`, `items_users`.`data`,`items_users`.`inOdet`,`items_users`.`inShop`,`items_users`.`delete`,`items_users`.`iznosNOW`,`items_users`.`iznosMAX`, `items_users`.`gift`,`items_users`.`gtxt1`,`items_users`.`gtxt2`,`items_users`.`kolvo`,`items_users`.`geniration`,`items_users`.`magic_inc`,`items_users`.`maidin`, @@ -67,11 +92,11 @@ ORDER BY `1price`ASC , inGroupCount DESC' `items_main`.`group`,`items_main`.`group_max`,`items_main`.`geni`,`items_main`.`ts`,`items_main`.`srok`,`items_main`.`class`,`items_main`.`class_point`,`items_main`.`anti_class`, `items_main`.`anti_class_point`,`items_main`.`max_text`,`items_main`.`useInBattle`,`items_main`.`lbtl`,`items_main`.`lvl_itm`,`items_main`.`lvl_exp`, `items_main`.`lvl_aexp` , count(`items_users`.`id`) as inGroupCount -FROM `items_users` LEFT JOIN `items_main` ON (`items_main`.`id` = `items_users`.`item_id`) +FROM `items_users` LEFT JOIN `items_main` ON (`items_main`.`id` = `items_users`.`item_id`) WHERE (( `items_users`.time_create + `items_main`.srok) > unix_timestamp() OR `items_main`.srok = "0") AND `items_users`.`delete`="0" AND `items_users`.`item_id` = "' . (int)$_GET['itemid'] . '" -AND `items_users`.`inOdet`="0" AND `items_users`.`inShop`="30" and `items_main`.`type` != "18" AND `items_main`.`type` != "19" AND `items_main`.`type` != "20" AND `items_main`.`type` != "21" AND `items_main`.`type` != "22" AND `items_main`.`type` != "15" AND `items_main`.`type` != "12" AND `items_main`.`type` != "4" AND `items_main`.`type` != "5" AND `items_main`.`type` != "6" AND `items_main`.`type` != "1" AND `items_main`.`type` != "3" AND `items_main`.`type` != "8" AND `items_main`.`type` != "14" AND `items_main`.`type` != "13" AND `items_main`.`type` != "9" AND `items_main`.`type` != "10" AND `items_main`.`type` != "11" AND `items_main`.`type` != "29" AND `items_main`.`type` != "30" +AND `items_users`.`inOdet`="0" AND `items_users`.`inShop`="30" and `items_main`.`type` != "18" AND `items_main`.`type` != "19" AND `items_main`.`type` != "20" AND `items_main`.`type` != "21" AND `items_main`.`type` != "22" AND `items_main`.`type` != "15" AND `items_main`.`type` != "12" AND `items_main`.`type` != "4" AND `items_main`.`type` != "5" AND `items_main`.`type` != "6" AND `items_main`.`type` != "1" AND `items_main`.`type` != "3" AND `items_main`.`type` != "8" AND `items_main`.`type` != "14" AND `items_main`.`type` != "13" AND `items_main`.`type` != "9" AND `items_main`.`type` != "10" AND `items_main`.`type` != "11" AND `items_main`.`type` != "29" AND `items_main`.`type` != "30" GROUP BY `items_users`.`inGroup`, `items_users`.`uid`,`items_users`.`1price` HAVING `items_users`.inGroup > 0 -UNION ALL +UNION ALL SELECT `items_users`.`id` as id, `items_users`.`id` AS `idu`,`items_users`.`item_id` as item_id,`items_users`.`1price`,`items_users`.`2price`,`items_users`.`uid`,`items_users`.`use_text`, `items_users`.`data`,`items_users`.`inOdet`,`items_users`.`inShop`,`items_users`.`delete`,`items_users`.`iznosNOW`,`items_users`.`iznosMAX`, `items_users`.`gift`,`items_users`.`gtxt1`,`items_users`.`gtxt2`,`items_users`.`kolvo`,`items_users`.`geniration`,`items_users`.`magic_inc`,`items_users`.`maidin`, @@ -82,15 +107,15 @@ SELECT `items_users`.`id` as id, `items_users`.`id` AS `idu`,`items_users`.`item `items_main`.`group`,`items_main`.`group_max`,`items_main`.`geni`,`items_main`.`ts`,`items_main`.`srok`,`items_main`.`class`,`items_main`.`class_point`,`items_main`.`anti_class`, `items_main`.`anti_class_point`,`items_main`.`max_text`,`items_main`.`useInBattle`,`items_main`.`lbtl`,`items_main`.`lvl_itm`,`items_main`.`lvl_exp`, `items_main`.`lvl_aexp`, count(`items_users`.`id`) as inGroupCount -FROM `items_users` LEFT JOIN `items_main` ON (`items_main`.`id` = `items_users`.`item_id`) +FROM `items_users` LEFT JOIN `items_main` ON (`items_main`.`id` = `items_users`.`item_id`) WHERE (( `items_users`.time_create + `items_main`.srok) > unix_timestamp() OR `items_main`.srok = "0") AND `items_users`.`delete`="0" AND `items_users`.`item_id` = "' . (int)$_GET['itemid'] . '" -AND `items_users`.`inOdet`="0" AND `items_users`.`inShop`="30" and `items_main`.`type` != "18" AND `items_main`.`type` != "19" AND `items_main`.`type` != "20" AND `items_main`.`type` != "21" AND `items_main`.`type` != "22" AND `items_main`.`type` != "15" AND `items_main`.`type` != "12" AND `items_main`.`type` != "4" AND `items_main`.`type` != "5" AND `items_main`.`type` != "6" AND `items_main`.`type` != "1" AND `items_main`.`type` != "3" AND `items_main`.`type` != "8" AND `items_main`.`type` != "14" AND `items_main`.`type` != "13" AND `items_main`.`type` != "9" AND `items_main`.`type` != "10" AND `items_main`.`type` != "11" AND `items_main`.`type` != "29" AND `items_main`.`type` != "30" +AND `items_users`.`inOdet`="0" AND `items_users`.`inShop`="30" and `items_main`.`type` != "18" AND `items_main`.`type` != "19" AND `items_main`.`type` != "20" AND `items_main`.`type` != "21" AND `items_main`.`type` != "22" AND `items_main`.`type` != "15" AND `items_main`.`type` != "12" AND `items_main`.`type` != "4" AND `items_main`.`type` != "5" AND `items_main`.`type` != "6" AND `items_main`.`type` != "1" AND `items_main`.`type` != "3" AND `items_main`.`type` != "8" AND `items_main`.`type` != "14" AND `items_main`.`type` != "13" AND `items_main`.`type` != "9" AND `items_main`.`type` != "10" AND `items_main`.`type` != "11" AND `items_main`.`type` != "29" AND `items_main`.`type` != "30" GROUP BY `items_users`.`uid`,`items_users`.`1price` HAVING `items_users`.inGroup = 0 -ORDER BY `1price`ASC , inGroupCount DESC' +ORDER BY `1price`, inGroupCount DESC' ); } else { $cl = mysql_query( - 'SELECT `items_users`.`id`, `items_users`.`id` AS `idu`,`items_users`.`item_id`,`items_users`.`1price`,`items_users`.`2price`,`items_users`.`uid`,`items_users`.`use_text`,`items_users`.`data`,`items_users`.`inOdet`,`items_users`.`inShop`,`items_users`.`delete`,`items_users`.`iznosNOW`,`items_users`.`iznosMAX`,`items_users`.`gift`,`items_users`.`gtxt1`,`items_users`.`gtxt2`,`items_users`.`kolvo`,`items_users`.`geniration`,`items_users`.`magic_inc`,`items_users`.`maidin`,`items_users`.`lastUPD`,`items_users`.`timeOver`,`items_users`.`overType`,`items_users`.`secret_id`,`items_users`.`time_create`,`items_users`.`inGroup`,`items_users`.`dn_delete`,`items_users`.`inTransfer`,`items_users`.`post_delivery`,`items_users`.`lbtl_`,`items_users`.`bexp`,`items_users`.`so`,`items_users`.`blvl`,`items_main`.`id`,`items_main`.`name`,`items_main`.`img`,`items_main`.`type`,`items_main`.`inslot`,`items_main`.`2h`,`items_main`.`2too`,`items_main`.`iznosMAXi`,`items_main`.`inRazdel`,`items_main`.`price1`,`items_main`.`price2`,`items_main`.`magic_chance`,`items_main`.`info`,`items_main`.`massa`,`items_main`.`level`,`items_main`.`magic_inci`,`items_main`.`overTypei`,`items_main`.`group`,`items_main`.`group_max`,`items_main`.`geni`,`items_main`.`ts`,`items_main`.`srok`,`items_main`.`class`,`items_main`.`class_point`,`items_main`.`anti_class`,`items_main`.`anti_class_point`,`items_main`.`max_text`,`items_main`.`useInBattle`,`items_main`.`lbtl`,`items_main`.`lvl_itm`,`items_main`.`lvl_exp`,`items_main`.`lvl_aexp` FROM `items_users` LEFT JOIN `items_main` ON (`items_main`.`id` = `items_users`.`item_id`) WHERE (( `items_users`.time_create + `items_main`.srok) > unix_timestamp() OR `items_main`.srok = "0") AND `items_users`.`delete`="0" AND `items_users`.`inOdet`="0" AND `items_users`.`inShop`="30" and `items_main`.`type` != "18" AND `items_main`.`type` != "19" AND `items_main`.`type` != "20" AND `items_main`.`type` != "21" AND `items_main`.`type` != "22" AND `items_main`.`type` != "15" AND `items_main`.`type` != "12" AND `items_main`.`type` != "4" AND `items_main`.`type` != "5" AND `items_main`.`type` != "6" AND `items_main`.`type` != "1" AND `items_main`.`type` != "3" AND `items_main`.`type` != "8" AND `items_main`.`type` != "14" AND `items_main`.`type` != "13" AND `items_main`.`type` != "9" AND `items_main`.`type` != "10" AND `items_main`.`type` != "11" AND `items_main`.`type` != "29" AND `items_main`.`type` != "30" GROUP BY `items_users`.`item_id` ORDER BY `items_main`.`id` DESC' + 'select items_users.id, items_users.id as idu,items_users.item_id,items_users.`1price`,items_users.`2price`,items_users.uid,items_users.use_text,items_users.data,items_users.inOdet,items_users.inShop,items_users.`delete`,items_users.iznosNOW,items_users.iznosMAX,items_users.gift,items_users.gtxt1,items_users.gtxt2,items_users.kolvo,items_users.geniration,items_users.magic_inc,items_users.maidin,items_users.lastUPD,items_users.timeOver,items_users.overType,items_users.secret_id,items_users.time_create,items_users.inGroup,items_users.dn_delete,items_users.inTransfer,items_users.post_delivery,items_users.lbtl_,items_users.bexp,items_users.so,items_users.blvl,items_main.id,items_main.name,items_main.img,items_main.type,items_main.inslot,items_main.`2h`,items_main.`2too`,items_main.iznosMAXi,items_main.inRazdel,items_main.price1,items_main.price2,items_main.magic_chance,items_main.info,items_main.massa,items_main.level,items_main.magic_inci,items_main.overTypei,items_main.`group`,items_main.group_max,items_main.geni,items_main.ts,items_main.srok,items_main.class,items_main.class_point,items_main.anti_class,items_main.anti_class_point,items_main.max_text,items_main.useInBattle,items_main.lbtl,items_main.lvl_itm,items_main.lvl_exp,items_main.lvl_aexp from items_users left join items_main on (items_main.id = items_users.item_id) where (( items_users.time_create + items_main.srok) > unix_timestamp() or items_main.srok = "0") and items_users.`delete`="0" and items_users.inOdet="0" and items_users.inShop="30" and items_main.type != "18" and items_main.type != "19" and items_main.type != "20" and items_main.type != "21" and items_main.type != "22" and items_main.type != "15" and items_main.type != "12" and items_main.type != "4" and items_main.type != "5" and items_main.type != "6" and items_main.type != "1" and items_main.type != "3" and items_main.type != "8" and items_main.type != "14" and items_main.type != "13" and items_main.type != "9" and items_main.type != "10" and items_main.type != "11" and items_main.type != "29" and items_main.type != "30" group by items_users.item_id order by items_main.id desc' ); } } @@ -121,11 +146,9 @@ ORDER BY `1price`ASC , inGroupCount DESC' } else { $po = Helper\Conversion::dataStringToArray($pl['data']); } - if (($pl['type'] >= 18 && $pl['type'] <= 24) || $pl['type'] == 26 || $pl['type'] == 27) { + if ((($pl['type'] >= 18 && $pl['type'] <= 24) || $pl['type'] == 26 || $pl['type'] == 27) && $pl['inOdet'] != 14) { //Зоны блока + - if ($pl['inOdet'] != 14) { - $po['zonb']++; - } + $po['zonb']++; } $is2 = ''; $is1 = '
'; @@ -136,7 +159,7 @@ ORDER BY `1price`ASC , inGroupCount DESC' } //название - $col = $this->itemsX($pl[0]); + $col = ItemsModel::itemsX($pl[0]); if ($col > 1 && $pl['inGroup'] != 0 && $pl['inGroupCount'] > 1) { $pl['kolvo'] = $col; $pl['name'] .= ' (x' . $col . ')'; @@ -145,7 +168,6 @@ ORDER BY `1price`ASC , inGroupCount DESC' if ($pl['massa'] > 0 && $preview == "full") { $is2 .= '(Масса: ' . round($pl['massa'], 2) . ')'; if ($pl['gift'] != '') { - $ttl = ''; if ($pl['gift'] == 1) { $ttl = 'Вы не можете передать этот предмет кому-либо'; } else { @@ -154,16 +176,14 @@ ORDER BY `1price`ASC , inGroupCount DESC' $is2 .= ' '; } if (isset($po['art'])) { - $is2 .= ' '; + $is2 .= ' Артефакт'; } if (isset($po['sudba'])) { - if ($po['sudba'] == '0') { - $is2 .= ' '; - } elseif ($po['sudba'] == '1') { - $is2 .= ' '; - } else { - $is2 .= ' '; - } + $is2 .= match ($po['sudba']) { + '0' => ' ', + '1' => ' ', + default => ' ', + }; } } //цена @@ -178,41 +198,38 @@ ORDER BY `1price`ASC , inGroupCount DESC' } //долговечность - if ($pl['iznosMAX'] > 0) { - $izcol = ''; - if (floor($pl['iznosNOW']) >= (floor($pl['iznosMAX']) - ceil($pl['iznosMAX']) / 100 * 20)) { - $izcol = 'brown'; - } - } + $is2 .= '
Долговечность: '; if ($preview == "preview") { - $is2 .= '
Долговечность: ' . floor($steck[1]) . '/' . ceil( - $steck[2] - ) . ''; + $durability = floor($steck[1]) . '/' . ceil($steck[2]); } else { if ($pl['iznosMAXi'] == 999999999) { - $is2 .= '
Долговечность: неразрушимо'; + $durability = 'неразрушимо'; } else { - $is2 .= '
Долговечность: ' . floor( - $pl['iznosNOW'] - ) . '/' . ceil($pl['iznosMAX']) . ''; + $durability = floor($pl['iznosNOW']) . '/' . ceil($pl['iznosMAX']); } } + + if ($pl['iznosMAX'] > 0 && floor($pl['iznosNOW']) >= (floor($pl['iznosMAX']) - ceil($pl['iznosMAX']) / 100 * 20)) { + $durability = "$durability"; + } + $is2 .= $durability; + //Срок годности предмета if ($po['srok'] > 0) { $pl['srok'] = $po['srok']; + $is2 .= '
Срок годности: '; } - if ($pl['srok'] > 0 and $preview != "preview") { + if ($pl['srok'] > 0 && $preview != "preview") { if ($pl['time_create'] + $pl['srok'] < time()) { - $is2 .= '
Срок годности: ' . $this->timeOut($pl['srok']) . ' (испорчен)'; + $is2 .= $this->timeOut($pl['srok']) . ' (испорчен)'; } else { - $is2 .= '
Срок годности: ' . $this->timeOut($pl['srok']) . ' (до ' . date( - 'd.m.Y H:i', $pl['time_create'] + $pl['srok'] - ) . ')'; + $is2 .= $this->timeOut($pl['srok']) . ' (до ' . date('d.m.Y H:i', $pl['time_create'] + $pl['srok']) . ')'; } } elseif ($pl['srok'] > 0) { - $is2 .= '
Срок годности: ' . $this->timeOut($pl['srok']); + $is2 .= $this->timeOut($pl['srok']); } + if ($pl['magic_chance'] > 0) { $is2 .= '
Вероятность срабатывания: ' . min([$pl['magic_chance'], 100]) . '%'; } @@ -269,10 +286,8 @@ ORDER BY `1price`ASC , inGroupCount DESC' } else { $tr .= $this->is[$n] . ': ' . $this->align_nm[$po['tr_' . $n]]; } - if ($po['tr_' . $n] > $this->stats[$n]) { - if ($n != 'align' || floor($this->info['align']) != $po['tr_' . $n]) { - $tr .= ''; - } + if ($po['tr_' . $n] > $this->stats[$n] && ($n != 'align' || floor($this->info['align']) != $po['tr_' . $n])) { + $tr .= ''; } } $x++; @@ -292,7 +307,7 @@ ORDER BY `1price`ASC , inGroupCount DESC' if ($po['add_' . $n] < 0) { $z = ''; } - $tr .= '
• ' . $this->is[$n] . ': ' . $z . '' . $po['add_' . $n]; + $tr .= '
• ' . $this->is[$n] . ': ' . $z . $po['add_' . $n]; } $x++; } @@ -306,7 +321,7 @@ ORDER BY `1price`ASC , inGroupCount DESC' if ($po['add_mab' . $i] < 0) { $z = ''; } - $tr .= '
• Броня ' . $bn[$i] . ': ' . $z . '' . $po['add_mab' . $i]; + $tr .= '
• Броня ' . $bn[$i] . ': ' . $z . $po['add_mab' . $i]; } else { $tr .= '
• Броня ' . $bn[$i] . ': ' . $po['add_mib' . $i] . '-' . $po['add_mab' . $i] . ' (' . $this->bronFx( [$po['add_mib' . $i], $po['add_mab' . $i]] @@ -332,7 +347,7 @@ ORDER BY `1price`ASC , inGroupCount DESC' if ($po['sv_' . $n] < 0) { $z = ''; } - $tr .= '
• ' . $this->is[$n] . ': ' . $z . '' . $po['sv_' . $n]; + $tr .= '
• ' . $this->is[$n] . ': ' . $z . $po['sv_' . $n]; } $x++; } @@ -390,7 +405,7 @@ ORDER BY `1price`ASC , inGroupCount DESC' } if (isset($po['free_stats']) && $po['free_stats'] > 0) { $is2 .= '
Распределение статов:'; - $is2 .= '• Возможных распределений: ' . $po['free_stats'] . ''; + $is2 .= '• Возможных распределений: ' . $po['free_stats']; } if (floor($pl['iznosNOW']) >= ceil($pl['iznosMAX'])) { $d[0] = 0; @@ -403,7 +418,7 @@ ORDER BY `1price`ASC , inGroupCount DESC' //не отображается $com1 = ['name' => 'Неизвестный Комплект', 'x' => 0, 'text' => '']; $spc = mysql_query( - 'SELECT `id`,`com`,`name`,`x`,`data` FROM `complects` WHERE `com` = "' . $po['complect'] . '" ORDER BY `x` ASC LIMIT 20' + 'SELECT `id`,`com`,`name`,`x`,`data` FROM `complects` WHERE `com` = "' . $po['complect'] . '" ORDER BY `x` LIMIT 20' ); while ($plc = mysql_fetch_array($spc)) { $com1['name'] = $plc['name']; @@ -512,13 +527,11 @@ ORDER BY `1price`ASC , inGroupCount DESC' if ($pl['dn_delete'] > 0) { $is2 .= '
Предмет будет удален при выходе из подземелья
'; } - if (isset($po['zazuby']) && $po['zazuby'] > 0) { - $is2 .= '
Предмет куплен за зубы
'; - } + $is2 .= ''; } if ($preview == "preview") { - $kolvoprint = "Количество: $steck[0] шт."; + $kolvoprint = "Количество: $steck[0] шт."; } echo '' . $is1 . '' . $kolvoprint . $is2 . ''; $i++; @@ -529,6 +542,28 @@ ORDER BY `1price`ASC , inGroupCount DESC' } } + private function timeOut(int|string $seconds): string + { + return Conversion::secondsToTimeout($seconds); + } + + private function bronFx($br): string + { + $r = ''; + if ($br[0] > 0) { + $r .= $br[0] - 1; + } else { + $r .= 0; + } + $r .= 'd'; + if ($br[0] > 0) { + $r .= $br[1] - $br[0]; + } else { + $r .= 0; + } + return $r; + } + public function buyItem(int $iid, User $u): string { $irow = Db::getRow('select items_users.id, uid, 1price, inGroup, inShop, data, item_id, login, items_main.name, price1 @@ -547,7 +582,7 @@ ORDER BY `1price`ASC , inGroupCount DESC' $u->addKr(-$price); $u->addKr($price, $irow['uid']); - $col = $u->itemsX($iid); + $col = ItemsModel::itemsX($iid); if ($col > 1) { Db::sql('update items_users set uid = ?, inGroup = inGroup + 1000, 1price = ?, lastUPD = unix_timestamp(), inShop = 0 where inShop = 30 and inOdet = 0 and item_id = ? and uid = ? and inGroup = ? limit ?', @@ -568,56 +603,45 @@ ORDER BY `1price`ASC , inGroupCount DESC' return '
' . $r . '
'; } - public function rent($action, int $iid, int $price, User $u) + public function rent($action, int $iid, int $price): void { if ($action == "Сдать в магазин" && $price > 0) { - $ChImtem = mysql_fetch_array( - mysql_query( - 'SELECT `id`, `item_id`, `data`, `inGroup`, `uid` FROM `items_users` WHERE `id` = ' . $iid . ' LIMIT 1' - ) - ); - $ChSudba = Conversion::dataStringToArray($ChImtem['data']); - if (!isset($ChSudba['sudba']) && $ChSudba['sudba'] == 0 && $ChSudba['sudba'] != 1 && !isset($ChSudba['toclan'])) { - if (isset($ChImtem['inGroup']) && $ChImtem['inGroup'] > 0) { - $col = $u->itemsX($ChImtem['id']); - if ($col > 1) { - mysql_query( - 'UPDATE `items_users` SET `inShop` = 30, `1price` = ' . $price . ' WHERE `item_id`="' . $ChImtem['item_id'] . '" AND `uid`="' . $ChImtem['uid'] . '" AND `inGroup` = "' . $ChImtem['inGroup'] . '" LIMIT ' . $col . '' - ); - } else { - mysql_query( - 'UPDATE `items_users` SET `inShop` = 30, `1price` = ' . $price . ' WHERE `uid` = "' . $u->info['id'] . '" AND `id` = "' . $iid . '" AND `inOdet` = "0" AND `delete` = "0" ' - ); - } - } else { - mysql_query( - 'UPDATE `items_users` set `inShop` = 30, `1price` = ' . $price . ' where `uid` = "' . $u->info['id'] . '" AND `id` = "' . $iid . '" AND `inOdet` = "0" AND `delete` = "0" ' - ); - } - } + $this->rentPut($iid, $price); } elseif ($action == "Забрать") { - $i = mysql_fetch_array( - mysql_query( - 'SELECT `im`.`price1`, -`iu`.* FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON (`im`.`id` = `iu`.`item_id`) WHERE `iu`.`id` = "' . $iid . '" AND `iu`.`inShop` = "30" AND `iu`.`delete` = "0" LIMIT 1' - ) - ); - if (isset($i['inGroup']) and $i['inGroup'] > 0) { - $col = $u->itemsX($i['id']); - if ($col > 1) { - mysql_query( - 'UPDATE `items_users` SET `inShop` = 0, `1price` = ' . $i['price1'] . ' WHERE `item_id`="' . $i['item_id'] . '" AND `inShop` = "30" AND `uid`="' . $i['uid'] . '" AND `inGroup` = "' . $i['inGroup'] . '" LIMIT ' . $col . '' - ); - } else { - mysql_query( - 'UPDATE `items_users` SET `inShop` = 0, `1price` = ' . $i['price1'] . ' WHERE `uid` = "' . $u->info['id'] . '" AND `id` = "' . $iid . '" AND `inOdet` = "0" AND `delete` = "0" ' - ); - } - } else { - mysql_query( - 'UPDATE `items_users` SET `inShop` = 0, `1price` = "' . $i['price1'] . '" WHERE `id` = "' . $iid . '" and `inShop` = "30" LIMIT 1' - ); - } + $this->rentTake($iid); } } -} \ No newline at end of file + + private function rentPut(int $id, int $price): void + { + $item = Db::getRow('select id, item_id, data, ingroup, uid from items_users where id = ?', [$id]); + $data = Conversion::dataStringToArray($item['data']); + $col = ItemsModel::itemsX($item['id']); + + if (isset($data['sudba']) || $data['sudba'] != 0 || isset($data['toclan'])) { + return; + } + if (!isset($item['ingroup']) || $item['ingroup'] <= 0 || $col < 2) { + Db::sql('update items_users set inShop = 30, 1price = ? where id = ? and uid = ? and inOdet = 0', [$price, $id, $item['uid']]); + return; + } + + Db::sql('update items_users set inShop = 30, 1price = ? where item_id = ? and uid = ? and inGroup = ? limit ?', [$price, $item['id'], $item['uid'], $item['ingroup'], (int)$col]); + } + + private function rentTake(int $id): void + { + $item = Db::getRow('select items_users.*, price1, inGroup from items_users inner join items_main on items_main.id = item_id where items_users.id = ? and inShop = 30 limit 1', [$id]); + if (!isset($item['inGroup']) || $item['inGroup'] <= 0) { + Db::sql('update items_users set inShop = 0, 1price = ? where id = ? and inShop = 30', [$item['price1'], $id]); + return; + } + $col = ItemsModel::itemsX($item['id']); + if ($col > 1) { + Db::sql('update items_users set inShop = 0, 1price = ? where item_id = ? and uid = ? and inGroup = ? and inShop = 30 limit ?', + [$item['price1'], $item['item_id'], $item['uid'], $item['ingroup'], (int)$col]); + } else { + Db::sql('update items_users set inShop = 0, 1price = ? where id = ? and uid = ? and inOdet = 0', [$item['price1'], $id, $item['uid']]); + } + } +} diff --git a/_incl_data/class/Magic.php b/_incl_data/class/Magic.php index dce02ff9..eb9310c2 100644 --- a/_incl_data/class/Magic.php +++ b/_incl_data/class/Magic.php @@ -40,7 +40,7 @@ class Magic if (isset($itm['id'])) { //Группа предметов - if ($itm['group'] == 1 && $u->itemsX($itm['id']) > 1) { + if ($itm['group'] == 1 && ItemsModel::itemsX($itm['id']) > 1) { //вытаскиваем предмет из группы $u->unstack($itm['id'], 1); } diff --git a/_incl_data/class/Model/ActionModel.php b/_incl_data/class/Model/ActionModel.php index 704b53a6..63cf6918 100644 --- a/_incl_data/class/Model/ActionModel.php +++ b/_incl_data/class/Model/ActionModel.php @@ -27,7 +27,7 @@ class ActionModel [ $user['id'], $time, - $user['city'], + '', $user['room'], $vars, UserIp::get(), @@ -84,11 +84,6 @@ class ActionModel return (int)Db::getValue($sql, $binds); } - public function getByVals(string $vals) - { - return Db::getRow('select * from actions where uid = ? and vals = ?', [$this->uid, $vals]); - } - public function getLastByVals(string $vals) { return Db::getRow( @@ -115,16 +110,6 @@ class ActionModel Db::sql('delete from actions where uid = ? and vals = ?', [$this->uid, $vals]); } - public function getDailyQuest(): array - { - $filter = [ - "uid = $this->uid", - "vars = 'day_quest'", - ]; - - return self::get($filter); - } - public function getFinishedDailyQuestTasks(int $timeout): array { $arr = []; diff --git a/_incl_data/class/User.php b/_incl_data/class/User.php index 4a25f7ed..e6944df8 100644 --- a/_incl_data/class/User.php +++ b/_incl_data/class/User.php @@ -978,10 +978,14 @@ class User /** Singletone. * @param int $uid + * @param bool $createInstance * @return User */ - public static function start(int $uid = 0): User + public static function start(int $uid = 0, bool $createInstance = false): User { + if ($createInstance) { + return new self($uid); + } if (!isset(self::$flag_one)) { self::$flag_one = new self($uid); } @@ -1034,9 +1038,9 @@ class User '8' => 'Поучаствовать в Башне Смерти', ]; if (!isset($test['id'])) { - $n = "Получить задание"; + $n = "Получить задание"; } else { - $n = "Сдать задание"; + $n = "Сдать задание"; $n = $n . "
" . $q[$test['vals']] . ""; } return $n; @@ -1760,28 +1764,6 @@ class User Db::sql('update users set money = money + ? where id = ?', [$amount, $uid]); } - public function bronFx($br): string - { - $r = ''; - if ($br[0] > 0) { - $r .= $br[0] - 1; - } else { - $r .= 0; - } - $r .= 'd'; - if ($br[0] > 0) { - $r .= $br[1] - $br[0]; - } else { - $r .= 0; - } - return $r; - } - - /* - * $iid Уникальный id прдемета и одновремено флаг что - * покупка из комка. - */ - public function price($vl): string { if ($vl == round($vl)) { @@ -1941,23 +1923,13 @@ class User $this->error = 'Предмет не найден в рюкзаке'; return; } - if ($itm['inGroup'] > 0 && $this->itemsX($id) > 1) { + if ($itm['inGroup'] > 0 && ItemsModel::itemsX($id) > 1) { Db::sql('update items_users set inshop = 1 where inshop != 30 and uid = ? and item_id = ? and ingroup = ?', [$this->info['id'], $itm['item_id'], $itm['inGroup']]); } else { Db::sql('update items_users set inshop = 1 where inshop != 30 and uid = ? and id = ? and inodet = 0', [$this->info['id'], $id]); } } - public function itemsX(int $id, $uid = null, $item_id = null): bool|int - { - //fixme какая-то дичь тут. - $item = Db::getRow('select uid, item_id, ingroup, inshop from items_users where id = ?', [$id]); - return Db::getValue( - 'select count(id) from items_users where inshop = ? and item_id = ? and uid = ? and ingroup = ?', - [$item['inShop'], $item['item_id'], $item['uid'], $item['ingroup']] - ); - } - public function obj_takeItem($id): void { $itm = Db::getRow('select id, ingroup from items_users where id = ? and uid = ? and inodet = 0 and inshop = 0'); @@ -1968,7 +1940,7 @@ class User $this->error = 'Предмет не найден в сундуке'; return; } - if ($itm['inGroup'] > 0 && $this->itemsX($id) > 1) { + if ($itm['inGroup'] > 0 && ItemsModel::itemsX($id) > 1) { Db::sql('update items_users set inshop = 0 where inshop != 30 and uid = ? and (id = ? or ingroup = ?) and inodet = 0', [$this->info['id'], $id, $itm['inGroup']]); } else { Db::sql('update items_users set inshop = 0 where inshop != 30 and uid = ? and id = ? and inodet = 0', [$this->info['id'], $id]); @@ -2026,37 +1998,37 @@ class User //Сверяем требования предмета для его использования - public function runeItem($id, $name = 0, $ruid = 0): void + public function runeItem(): void { - if ($id == null) { - if ($ruid < 1 && isset($_GET['use_rune'])) { - $ruid = $_GET['use_rune']; - echo " + $name = 0; + $ruid = 0; + if ($ruid < 1 && isset($_GET['use_rune'])) { + $ruid = $_GET['use_rune']; + echo " "; - } - $rune = mysql_fetch_array( - mysql_query( - 'SELECT + } + $rune = mysql_fetch_array( + mysql_query( + 'SELECT `i`.`id`,`i`.`item_id`,`i`.`1price`,`i`.`2price`,`i`.`uid`,`i`.`use_text`,`i`.`data`,`i`.`inOdet`,`i`.`inShop`,`i`.`delete`,`i`.`iznosNOW`,`i`.`iznosMAX`,`i`.`gift`,`i`.`gtxt1`,`i`.`gtxt2`,`i`.`kolvo`,`i`.`geniration`,`i`.`magic_inc`,`i`.`maidin`,`i`.`lastUPD`,`i`.`timeOver`,`i`.`overType`,`i`.`secret_id`,`i`.`time_create`,`i`.`inGroup`,`i`.`dn_delete`,`i`.`inTransfer`,`i`.`post_delivery`,`i`.`lbtl_`,`i`.`bexp`,`i`.`so`,`i`.`blvl` ,`m`.`name`,`m`.`type`,`m`.`level` FROM `items_users` AS `i` LEFT JOIN `items_main` AS `m` ON `i`.`item_id` = `m`.`id` WHERE `i`.`id` = "' . mysql_real_escape_string($ruid) . '" AND `i`.`uid` = "' . $this->info['id'] . '" AND `i`.`delete` = "0" AND `i`.`inShop` = "0" LIMIT 1' - ) - ); + ) + ); - $it_type = 0; - if (isset($_GET['item_rune'])) { - $name = $_GET['item_rune']; - } - $vi = 0; - $vid = ''; - if (isset($_GET['item_rune_id'])) { - $sp = mysql_query( - 'SELECT + if (isset($_GET['item_rune'])) { + $name = $_GET['item_rune']; + } + $vi = 0; + $vid = ''; + if (isset($_GET['item_rune_id'])) { + $sp = mysql_query( + 'SELECT `i`.`id`,`i`.`item_id`,`i`.`1price`,`i`.`2price`,`i`.`uid`,`i`.`use_text`,`i`.`data`,`i`.`inOdet`,`i`.`inShop`,`i`.`delete`,`i`.`iznosNOW`,`i`.`iznosMAX`,`i`.`gift`,`i`.`gtxt1`,`i`.`gtxt2`,`i`.`kolvo`,`i`.`geniration`,`i`.`magic_inc`,`i`.`maidin`,`i`.`lastUPD`,`i`.`timeOver`,`i`.`overType`,`i`.`secret_id`,`i`.`time_create`,`i`.`inGroup`,`i`.`dn_delete`,`i`.`inTransfer`,`i`.`post_delivery`,`i`.`lbtl_`,`i`.`bexp`,`i`.`so`,`i`.`blvl` ,`m`.`type`,`m`.`2h`,`m`.`inslot`,`m`.`name`,`m`.`img` FROM `items_users` AS `i` LEFT JOIN `items_main` AS `m` ON (`i`.`item_id` = `m`.`id`) WHERE `i`.`inShop` = "0" AND @@ -2064,13 +2036,13 @@ class User ( (`m`.`inslot` > 0 AND `m`.`inslot` < 18) OR "' . $rune['type'] . '" = "37" OR `m`.`inslot` = "51" ) AND `i`.`delete` = "0" AND `i`.`inOdet` = "0" AND `i`.`id` = "' . mysql_real_escape_string( - $_GET['item_rune_id'] - ) . '" AND `i`.`uid` = "' . mysql_real_escape_string($this->info['id']) . '"' - ); - $vi = -1; - } else { - $sp = mysql_query( - 'SELECT + $_GET['item_rune_id'] + ) . '" AND `i`.`uid` = "' . mysql_real_escape_string($this->info['id']) . '"' + ); + $vi = -1; + } else { + $sp = mysql_query( + 'SELECT `i`.`id`,`i`.`item_id`,`i`.`1price`,`i`.`2price`,`i`.`uid`,`i`.`use_text`,`i`.`data`,`i`.`inOdet`,`i`.`inShop`,`i`.`delete`,`i`.`iznosNOW`,`i`.`iznosMAX`,`i`.`gift`,`i`.`gtxt1`,`i`.`gtxt2`,`i`.`kolvo`,`i`.`geniration`,`i`.`magic_inc`,`i`.`maidin`,`i`.`lastUPD`,`i`.`timeOver`,`i`.`overType`,`i`.`secret_id`,`i`.`time_create`,`i`.`inGroup`,`i`.`dn_delete`,`i`.`inTransfer`,`i`.`post_delivery`,`i`.`lbtl_`,`i`.`bexp`,`i`.`so`,`i`.`blvl` ,`m`.`type`,`m`.`2h`,`m`.`inslot`,`m`.`name`,`m`.`img` FROM `items_users` AS `i` LEFT JOIN `items_main` AS `m` ON (`i`.`item_id` = `m`.`id`) @@ -2079,25 +2051,22 @@ class User ( (`m`.`inslot` > 0 AND `m`.`inslot` < 18) OR "' . $rune['type'] . '" = "37" OR `m`.`inslot` = "51" ) AND `i`.`inShop` = "0" AND `i`.`delete` = "0" AND `i`.`inOdet` = "0" AND `m`.`name` LIKE "%' . mysql_real_escape_string( - str_replace('"', '"', $name) - ) . '%" AND `i`.`uid` = "' . mysql_real_escape_string($this->info['id']) . '"' - ); + str_replace('"', '"', $name) + ) . '%" AND `i`.`uid` = "' . mysql_real_escape_string($this->info['id']) . '"' + ); + } + while ($pl = mysql_fetch_array($sp)) { + if (!isset($id['id'])) { + $id = $pl; + $id_type = $pl['type']; } - while ($pl = mysql_fetch_array($sp)) { - $vibor .= '
'; - if (!isset($id['id'])) { - $dt = Conversion::dataStringToArray($pl['data']); - $id = []; - $id = $pl; - $id_type = $pl['type']; - } - if ($vi != -1) { - $vi++; - $vid .= '`iu`.`id` = "' . $pl[0] . '" OR'; - } + if ($vi != -1) { + $vi++; + $vid .= '`iu`.`id` = "' . $pl[0] . '" OR'; } } + if ($vi > 0) { $itm_inv = $this->genInv(80, ' ' . rtrim($vid, 'OR') . ' '); echo '