game/_incl_data/class/User.php

6602 lines
320 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
use Core\Config;
use Core\Database;
use Core\Db;
use Helper\Conversion;
use JetBrains\PhpStorm\NoReturn;
use Model\ActionModel;
use User\Effects;
use User\InfoBox;
use User\ItemsModel;
use User\Reputation;
use User\Stats;
use User\UserCalculatedStats;
use User\UserStats;
class User
{
private static ?self $flag_one = null;
public int $pokol = 2; //Акктуальное поколение предметов
public array $aves = ['now' => 0, 'max' => 0];
public array $room = [];
public array $align_nm = [
1 => 'Свет',
2 => 'Хаос',
3 => 'Тьма',
7 => 'Нейтралитет',
];
public array $mod_nm = [
0 => [0 => ''],
1 => [
'1' => 'Свет',
'1.1' => 'Паладин Поднебесья',
'1.4' => 'Таможенный Паладин',
'1.5' => 'Паладин Солнечной Улыбки',
'1.6' => 'Инквизитор',
'1.7' => 'Паладин Огненной Зари',
'1.75' => 'Паладин-Хранитель',
'1.9' => 'Паладин Неба',
'1.91' => 'Старший Паладин Неба',
'1.92' => 'Ветеран Ордена',
'1.99' => 'Верховный Паладин',
],
3 => [
'3' => 'Тьма',
'3.01' => 'Тарман-Служитель',
'3.05' => 'Тарман-Надсмотрщик',
'3.06' => 'Каратель',
'3.07' => 'Тарман-Убийца',
'3.075' => 'Тарман-Хранитель',
'3.09' => 'Тарман-Палач',
'3.091' => 'Тарман-Владыка',
'3.092' => 'Ветеран Армады',
'3.99' => 'Тарман Патриарх',
],
];
public array $rgd = [0 => 0, 1 => 0];
public array $city_name = [
'emeraldscity' => 'Emeralds city',
'abandonedplain' => 'Abandoned Plain',
'capitalcity' => 'Capital city',
'angelscity' => 'Angels city',
'newcapitalcity' => 'New Capital city',
'demonscity' => 'Demons city',
'fallenearth' => 'Fallen Earth',
'dreamscity' => 'Dreams City',
'suncity' => 'Sun City',
'devilscity' => 'Devils City',
];
public array $is = [ // не играть с кавычками! эти строчки уходят в яваскрипт и всё ломают!
'acestar' => 'Следующий каст будет критическим',
'spasenie' => 'Спасение после смерти',
'more_awards' => 'Повышеная награда %',
'exp' => 'Получаемый опыт (%)',
'align_bs' => 'Служитель закона',
'nopryh' => 'Прямое поподание',
'puti' => 'Запрет перемещения',
'align' => 'Склонность',
'hpAll' => "Уровень жизни (HP)",
'mpAll' => "Уровень маны (МP)",
'enAll' => 'Уровень энергии',
'sex' => 'Пол',
'lvl' => 'Уровень',
's1' => 'Сила',
's2' => 'Ловкость',
's3' => 'Интуиция',
's4' => 'Выносливость',
's5' => 'Интеллект',
's6' => 'Мудрость',
's7' => 'Духовность',
's8' => 'Воля',
's9' => 'Свобода духа',
's10' => 'Божественность',
's11' => 'Энергия',
'm1' => 'Мф. критического удара (%)',
'm2' => 'Мф. против критического удара (%)',
'm3' => 'Мф. мощности крит. удара (%)',
'm21' => 'Мф. абс. попадания (%)',
'm4' => 'Мф. увертывания (%)',
'm5' => 'Мф. против увертывания (%)',
'm6' => 'Мф. контрудара (%)',
'm7' => 'Мф. парирования (%)',
'm8' => 'Мф. блока щитом (%)',
'm9' => 'Мф. удара сквозь броню (%)',
'm14' => 'Мф. абс. критического удара (%)',
'm15' => 'Мф. абс. увертывания (%)',
'm16' => 'Мф. абс. парирования (%)',
'm17' => 'Мф. абс. контрудара (%)',
'm18' => 'Мф. абс. блока щитом (%)',
'm19' => 'Мф. абс. магический промах (%)',
'm20' => 'Мф. удача (%)',
'a1' => 'Мастерство владения ножами, кинжалами',
'a2' => 'Мастерство владения топорами, секирами',
'a3' => 'Мастерство владения дубинами, молотами',
'a4' => 'Мастерство владения мечами',
'a5' => 'Мастерство владения магическими посохами',
'a6' => 'Мастерство владения луками',
'a7' => 'Мастерство владения арбалетами',
'aall' => 'Мастерство владения оружием',
'mall' => 'Мастерство владения магией стихий',
'm2all' => 'Мастерство владения магией',
'mg1' => 'Мастерство владения магией огня',
'mg2' => 'Мастерство владения магией воздуха',
'mg3' => 'Мастерство владения магией воды',
'mg4' => 'Мастерство владения магией земли',
'mg5' => 'Мастерство владения магией Света',
'mg6' => 'Мастерство владения магией Тьмы',
'mg7' => 'Мастерство владения серой магией',
'tj' => 'Тяжелая броня',
'lh' => 'Легкая броня',
'minAtack' => 'Минимальный урон',
'maxAtack' => 'Максимальный урон',
'm10' => 'Мф. мощности урона',
'm11' => 'Мф. мощности магии стихий',
'm11a' => 'Мф. мощности магии',
'pa1' => 'Мф. мощности колющего урона',
'pa2' => 'Мф. мощности рубящего урона',
'pa3' => 'Мф. мощности дробящего урона',
'pa4' => 'Мф. мощности режущего урона',
'pm1' => 'Мф. мощности магии огня',
'pm2' => 'Мф. мощности магии воздуха',
'pm3' => 'Мф. мощности магии воды',
'pm4' => 'Мф. мощности магии земли',
'pm5' => 'Мф. мощности магии Света',
'pm6' => 'Мф. мощности магии Тьмы',
'pm7' => 'Мф. мощности серой магии',
'za' => 'Защита от урона',
'zm' => 'Защита от магии стихий',
'zma' => 'Защита от магии',
'za1' => 'Защита от колющего урона',
'za2' => 'Защита от рубящего урона',
'za3' => 'Защита от дробящего урона',
'za4' => 'Защита от режущего урона',
'zm1' => 'Защита от магии огня',
'zm2' => 'Защита от магии воздуха',
'zm3' => 'Защита от магии воды',
'zm4' => 'Защита от магии земли',
'zm5' => 'Защита от магии Света',
'zm6' => 'Защита от магии Тьмы',
'zm7' => 'Защита от серой магии',
'magic_cast' => 'Дополнительный каст за ход',
'pza' => 'Понижение защиты от урона',
'pzm' => 'Понижение защиты от магии',
'pza1' => 'Понижение защиты от колющего урона',
'min_heal_proc' => 'Эффект лечения (%)',
'notravma' => 'Защита от травм',
'yron_min' => 'Минимальный урон',
'yron_max' => 'Максимальный урон',
'zaproc' => 'Блокировка Физического Урона (%)',
'zmproc' => 'Блокировка Магического Урона (%)',
'zm2proc' => 'Защита от магии Воздуха (%)',
'pza2' => 'Понижение защиты от рубящего урона',
'pza3' => 'Понижение защиты от дробящего урона',
'pza4' => 'Понижение защиты от режущего урона',
'pzm1' => 'Понижение защиты от магии огня',
'pzm2' => 'Понижение защиты от магии воздуха',
'pzm3' => 'Понижение защиты от магии воды',
'pzm4' => 'Понижение защиты от магии земли',
'pzm5' => 'Понижение защиты от магии Света',
'pzm6' => 'Понижение защиты от магии Тьмы',
'pzm7' => 'Понижение защиты от серой магии',
'speedhp' => 'Регенерация здоровья (%)',
'speedmp' => 'Регенерация маны (%)',
'tya1' => 'Колющие атаки',
'tya2' => 'Рубящие атаки',
'tya3' => 'Дробящие атаки',
'tya4' => 'Режущие атаки',
'tym1' => 'Огненные атаки',
'mg2static_points' => 'Уровень заряда (Воздух)',
'tym2' => 'Электрические атаки',
'tym3' => 'Ледяные атаки',
'tym4' => 'Земляные атаки',
'hpProc' => 'Уровень жизни (%)',
'mpProc' => 'Уровень маны (%)',
'tym5' => 'Атаки Света',
'tym6' => 'Атаки Тьмы',
'tym7' => 'Серые атаки',
'min_use_mp' => 'Уменьшает расход маны',
'pog' => 'Поглощение урона',
'pog2' => 'Поглощение урона',
'pog2p' => 'Процент поглощение урона',
'pog2mp' => 'Цена поглощение урона',
'maxves' => 'Увеличивает рюкзак',
'bonusexp' => 'Увеличивает получаемый опыт',
'speeden' => 'Регенерация энергии (%)',
'antm3' => 'Мф. против мощности крита',
'repair_z' => 'Бесплатное извлечение заточек',
'repair_r' => 'Бесплатное извлечение рун',
'yza' => 'Уязвимость физическому урона (%)',
'yzm' => 'Уязвимость магии стихий (%)',
'yzma' => 'Уязвимость магии (%)',
'yza1' => 'Уязвимость колющему урона (%)',
'yza2' => 'Уязвимость рубящему урона (%)',
'yza3' => 'Уязвимость дробящему урона (%)',
'yza4' => 'Уязвимость режущему урона (%)',
'yzm1' => 'Уязвимость магии огня (%)',
'yzm2' => 'Уязвимость магии воздуха (%)',
'yzm3' => 'Уязвимость магии воды (%)',
'yzm4' => 'Уязвимость магии земли (%)',
'yzm5' => 'Уязвимость магии (%)',
'yzm6' => 'Уязвимость магии (%)',
'yzm7' => 'Уязвимость магии (%)',
'rep' => 'Репутация Рыцаря',
'repair_discount' => 'Скидка на ремонт вещей',
'hpVinos' => 'Бонус жизни',
'bronze' => 'Bronze Premium Account',
'silvers' => 'Silver Premium Account',
'gold' => 'Благодать Ангела',
'speed_dungeon' => 'Скорость передвижения по подземельям',
'zona' => 'Дополнительная зона атаки',
];
public array $items = [
'tr' => [
'sex',
'align',
'lvl',
's1',
's2',
's3',
's4',
's5',
's6',
's7',
's8',
's9',
's10',
's11',
'a1',
'a2',
'a3',
'a4',
'a5',
'a6',
'a7',
'mg1',
'mg2',
'mg3',
'mg4',
'mg5',
'mg6',
'mg7',
'mall',
'm2all',
'aall',
'rep',
'align_bs',
],
'add' => [
'no_vor',
'antm3',
'acestar',
'spasenie',
'exp',
'enemy_am1',
'hod_minmana',
'yhod',
'noshock_voda',
'bronze',
'silvers',
'gold',
'repair_discount',
'yza',
'yzm',
'yzma',
'yza1',
'yza2',
'yza3',
'yza4',
'yzm1',
'yzm2',
'yzm3',
'yzm4',
'yzm5',
'yzm6',
'yzm7',
'repair_z',
'repair_r',
'notuse_last_pr',
'yrn_mg_first',
'antishock',
'nopryh',
'speed_dungeon',
'naemnik',
'mg2static_points',
'yrnhealmpprocmg3',
'nousepriem',
'notactic',
'seeAllEff',
'100proboi1',
'pog2',
'pog2p',
'magic_cast',
'min_heal_proc',
'no_yv1',
'no_krit1',
'no_krit2',
'no_contr1',
'no_contr2',
'no_bl1',
'no_pr1',
'no_yv2',
'no_bl2',
'no_pr2',
'silver',
'pza',
'pza1',
'pza2',
'pza3',
'pza4',
'pzm',
'pzm1',
'pzm2',
'pzm3',
'pzm4',
'pzm5',
'pzm6',
'pzm7',
'yron_min',
'yron_max',
'notravma',
'min_zonb',
'min_zona',
'nokrit',
'pog',
'min_use_mp',
'za1proc',
'za2proc',
'za3proc',
'za4proc',
'zaproc',
'zmproc',
'zm1proc',
'zm2proc',
'zm3proc',
'zm4proc',
'shopSale',
'shopSaleEkr',
's1',
's2',
's3',
's4',
's5',
's6',
's7',
's8',
's9',
's10',
's11',
'aall',
'a1',
'a2',
'a3',
'a4',
'a5',
'a6',
'a7',
'm2all',
'mall',
'mg1',
'mg2',
'mg3',
'mg4',
'mg5',
'mg6',
'mg7',
'hpAll',
'hpVinos',
'mpVinos',
'mpAll',
'enAll',
'hpProc',
'mpProc',
'm1',
'm2',
'm3',
'm4',
'm5',
'm6',
'm7',
'm8',
'm9',
'm14',
'm15',
'm16',
'm17',
'm18',
'm19',
'm20',
'm21',
'pa1',
'pa2',
'pa3',
'pa4',
'pm1',
'pm2',
'pm3',
'pm4',
'pm5',
'pm6',
'pm7',
'za',
'za1',
'za2',
'za3',
'za4',
'zma',
'zm',
'zm1',
'zm2',
'zm3',
'zm4',
'zm5',
'zm6',
'zm7',
'mib1',
'mab1',
'mib2',
'mab2',
'mib3',
'mab3',
'mib4',
'mab4',
'speedhp',
'speedmp',
'm10',
'm11',
'm11a',
'zona',
'zonb',
'maxves',
'minAtack',
'maxAtack',
'bonusexp',
'speeden',
],
'sv' => [
'pza',
'pza1',
'pza2',
'pza3',
'pza4',
'pzm',
'pzm1',
'pzm2',
'pzm3',
'pzm4',
'pzm5',
'pzm6',
'pzm7',
'notravma',
'min_zonb',
'min_zona',
'nokrit',
'pog',
'min_use_mp',
'za1proc',
'za2proc',
'za3proc',
'za4proc',
'zaproc',
'zmproc',
'zm1proc',
'zm2proc',
'zm3proc',
'zm4proc',
'shopSale',
'shopSaleEkr',
's1',
's2',
's3',
's4',
's5',
's6',
's7',
's8',
's9',
's10',
's11',
'aall',
'a1',
'a2',
'a3',
'a4',
'a5',
'a6',
'a7',
'm2all',
'mall',
'mg1',
'mg2',
'mg3',
'mg4',
'mg5',
'mg6',
'mg7',
'hpAll',
'mpAll',
'enAll',
'm1',
'm2',
'm3',
'm4',
'm5',
'm6',
'm7',
'm8',
'm9',
'm14',
'm15',
'm16',
'm17',
'm18',
'm19',
'm20',
'm21',
'pa1',
'pa2',
'pa3',
'pa4',
'pm1',
'pm2',
'pm3',
'pm4',
'pm5',
'pm6',
'pm7',
'min_use_mp',
'za',
'za1',
'za2',
'za3',
'za4',
'zma',
'zm',
'zm1',
'zm2',
'zm3',
'zm4',
'zm5',
'zm6',
'zm7',
'mib1',
'mab1',
'mib2',
'mab2',
'mib3',
'mab3',
'mib4',
'mab4',
'speedhp',
'speedmp',
'm10',
'm11',
'zona',
'zonb',
'maxves',
'minAtack',
'maxAtack',
'speeden',
],
];
public string $error2 = '';
public string $btl_txt = '';
public string $error = '';
public array $info = [];
public array $rep;
public $tfer;
public $stats;
private InfoBox $infoBox;
private Reputation $reputation;
private Stats $userStats;
private function __construct()
{
if (empty($_SESSION['uid']) && empty($_COOKIE['login'])) {
return;
}
$user = !empty($_SESSION['uid']) ? $_SESSION['uid'] : $_COOKIE['login'];
$this->info = self::getInfo($user);
unset($user);
Database::init(); // для всяких mysql_*
$this->infoTasks();
if (Core\Config::get('securetime') > 0) {
if (!defined('IP')) {
define('IP', $_SERVER['REMOTE_ADDR']);
}
if (isset($this->info['id']) && ($this->info['ip'] != IP || $this->info['banned'] > 0) && $_SERVER['REQUEST_URI'] != '/') {
unset($this->info, $_COOKIE['login']);
die(Config::get('exit'));
}
}
if (!isset ($_COOKIE['btl'], $this->info['battle']) || $this->info['battle'] != $_COOKIE['btl']) {
setcookie('btl', $this->info['battle'] ?? '', time() + 86400);
}
if (isset($this->info['id'])) {
if ($this->info['invis'] == 1 || $this->info['invis'] > time()) {
$this->info['cast_login'] = '<i>Невидимка</i>';
} else {
$this->info['cast_login'] = $this->info['login'];
}
}
if (isset($this->info['id']) && $this->info['battle'] == 0) {
$sb = $this->info['money2'];
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);
}
if (!isset($sm['id']) && $this->info['frg'] == -1) {
mysql_query(
'UPDATE `users` SET `catch` = "' . round(
$sb
) . '",`frg` = 0 WHERE `id` = ' . $this->info['id']
);
$this->addAction(
time(), 'frg', '[ ' . $this->info['login'] . ' ] ' . date(
'd.m.Y H:i:s'
) . ' [true] , balance: ' . $sb . ' / ' . $this->info['catch'] . ' / ' . $this->info['frg'] . ' '
);
} else {
mysql_query(
'UPDATE `users` SET `catch` = "' . round(
$sb + $this->info['frg']
) . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1'
);
if ($sb - 10 > $this->info['catch'] - $this->info['frg']) {
$this->addAction(
time(), 'frgfalse', '[ ' . $this->info['login'] . ' ] ' . date(
'd.m.Y H:i:s'
) . ' [false] , [' . ($sb - ($this->info['catch'] - $this->info['frg'])) . '] , balance: ' . $sb . ' | ' . $this->info['catch'] . ' | ' . $this->info['frg'] . ' '
);
}
}
}
if ($this->info['login2'] != '' && $this->info['battle'] == 0 && $this->info['zv'] == 0) {
mysql_query('UPDATE `users` SET `login2` = \'\' WHERE `id` = ' . $this->info['id']);
$this->info['login2'] = '';
}
$this->reputation = new Reputation($this->info['id']);
$this->rep = $this->reputation->get();
if ($this->info['login2'] != '' && $this->info['zv'] == 0 && $this->info['battle'] == 0) {
$this->info['login2'] = '';
mysql_query('UPDATE `users` SET `login2` = "" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1');
}
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) {
$this->addAction(time(), 'go_homeworld', '');
$rmt = mysql_fetch_array(
mysql_query(
'SELECT `id`,`lider`,`name`,`city`,`code`,`timeGO`,`file`,`level`,`align`,`clan`,`items`,`effects`,`destroy`,`close`,`roomGo`,`sex`,`FR`,`noatack`,`botgo`,`block_all`,`zvsee` FROM `room` WHERE `name` = "Центральная площадь" AND `city` = "' . $this->info['city'] . '" LIMIT 1'
)
);
if (isset($rmt['id'])) {
//Удаляем все ставки в БС
if ($this->room['file'] == 'bsenter') {
//Удаляем все ставки в БС
$sp_bs = mysql_query(
'SELECT `id`,`bsid`,`money` FROM `bs_zv` WHERE `uid` = "' . $this->info['id'] . '" AND `inBot` = "0" AND `finish` = "0"'
);
while ($pl_bs = mysql_fetch_array($sp_bs)) {
mysql_query(
'UPDATE `bs_turnirs` SET `users` = `users` - 1 WHERE `id` = "' . $pl_bs['bsid'] . '" LIMIT 1'
);
}
unset($sp_bs, $pl_bs);
mysql_query(
'UPDATE `bs_zv` SET `finish` = "' . time() . '" WHERE `uid` = "' . $this->info['id'] . '" AND `inBot` = "0" AND `finish` = "0"'
);
}
$this->info['room'] = $rmt['id'];
mysql_query(
'UPDATE `users` SET `room` = "' . $this->info['room'] . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1'
);
} else {
$this->error = 'В этом городе нельзя пользоваться кнопкой возрата';
}
unset($rmt);
} else {
$this->error = 'Вам запрещено пользоваться кнопкой возрата';
}
unset($hgo);
}
//Заносим текст
if (isset($_GET['itmid']) && isset($_GET['addtext'])) {
$itm = 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`.`max_text` FROM `items_users` AS `i` LEFT JOIN `items_main` AS `m` ON `i`.`item_id` = `m`.`id` WHERE `i`.`id` = "' . mysql_real_escape_string(
$_GET['itmid']
) . '" LIMIT 1'
)
);
if (isset($itm['id'])) {
if ($itm['max_text'] > 0 && $itm['max_text'] - $itm['use_text'] > 0) {
$txt = $_GET['addtext'];
$txt = str_replace(' ', '', $txt);
$txt = str_replace(' ', '', $txt);
if ($txt != '') {
$txt = substr($_GET['addtext'], 0, $itm['max_text'] - $itm['use_text']);
$sx = iconv_strlen($txt);
$itm['use_text'] += $sx;
if ($itm['use_text'] > $itm['max_text']) {
$itm['use_text'] = $itm['max_text'];
}
mysql_query(
'UPDATE `items_users` SET `use_text` = "' . $itm['use_text'] . '" WHERE `id` = "' . $itm['id'] . '" LIMIT 1'
);
mysql_query(
'INSERT INTO `items_text` (`item_id`,`time`,`login`,`text`,`city`,`x`) VALUES ("' . $itm['id'] . '","' . time() . '","' . $this->info['login'] . '","' . mysql_real_escape_string(
htmlspecialchars($txt, null)
) . '","' . $this->info['city'] . '","' . $sx . '")'
);
$this->error = 'Запись успешно произведена';
} else {
$this->error = 'Нужно что-то написать...';
}
} else {
$this->error = 'Предмет для записи не подходит';
}
} else {
$this->error = 'Предмет для записи не найден';
}
}
//Кидаем передачу
if (isset($_POST['trnLogin'], $_GET['transfer']) && $this->info['battle'] == 0) {
$t = self::getInfo($_POST['trnLogin']);
if (isset($t['id'])) {
if ($this->info['login'] == $t['login']) {
$this->error = 'Вы не можете передать самому себе';
} elseif ($t['battle'] > 0) {
$this->error = 'Персонаж находится в бою';
} elseif ($t['room'] != $this->info['room']) {
$this->error = 'Вы должны находится в одной комнате с персонажем';
} else {
//создаем передачу
$tt = mysql_fetch_array(
mysql_query(
'SELECT `id`,`time`,`uid1`,`uid2`,`city`,`room`,`good1`,`good2`,`cancel1`,`cancel2`,`money1`,`money2`,`start1`,`start2`,`text`,`r0`,`r1`,`r2`,`finish1`,`finish2` FROM `transfers` WHERE (`uid1` = "' . $this->info['id'] . '" OR `uid2` = "' . $this->info['id'] . '") AND (`cancel1` = "0" OR (`finish1` > 0 AND `uid1` = "' . $this->info['id'] . '") OR (`finish2` > 0 AND `uid2` = "' . $this->info['id'] . '")) AND (`cancel2` = "0" OR (`finish2` > 0 AND `uid2` = "' . $this->info['id'] . '") OR (`finish1` > 0 AND `uid1` = "' . $this->info['id'] . '")) ORDER BY `id` DESC LIMIT 1'
)
);
if (isset($tt['id'])) {
$this->error = 'Вы уже находитесь в передаче';
} else {
$tt = mysql_fetch_array(
mysql_query(
'SELECT `id`,`time`,`uid1`,`uid2`,`city`,`room`,`good1`,`good2`,`cancel1`,`cancel2`,`money1`,`money2`,`start1`,`start2`,`text`,`r0`,`r1`,`r2`,`finish1`,`finish2` FROM `transfers` WHERE (`uid1` = "' . $t['id'] . '" OR `uid2` = "' . $t['id'] . '") AND (`cancel1` = "0" OR (`finish1` > 0 AND `uid1` = "' . $t['id'] . '") OR (`finish2` > 0 AND `uid2` = "' . $t['id'] . '")) AND (`cancel2` = "0" OR (`finish2` > 0 AND `uid2` = "' . $t['id'] . '") OR (`finish1` > 0 AND `uid1` = "' . $t['id'] . '")) ORDER BY `id` DESC LIMIT 1'
)
);
if (isset($tt['id'])) {
$this->error = 'Персонаж уже проводит сделку';
} else {
$ins = mysql_query(
'INSERT INTO `transfers` (`uid1`,`uid2`,`city`,`room`,`time`,`text`,`start1`) VALUES ("' . $this->info['id'] . '","' . $t['id'] . '","' . $this->info['city'] . '","' . $this->info['room'] . '","' . time() . '","' . mysql_real_escape_string(
htmlspecialchars($_POST['textarea'], null)
) . '","' . time() . '")'
);
if ($ins) {
$this->addAction(
time(),
'trasfer_' . $this->info['city'] . '_' . $this->info['room'] . '_' . $t['id'] . '',
$this->info['login']
);
}
}
}
}
} else {
$this->error = 'Персонаж не найден';
}
}
//Выделяем передачи
$this->tfer = mysql_fetch_array(
mysql_query(
'SELECT `id`,`time`,`uid1`,`uid2`,`city`,`room`,`good1`,`good2`,`cancel1`,`cancel2`,`money1`,`money2`,`start1`,`start2`,`text`,`r0`,`r1`,`r2`,`finish1`,`finish2` FROM `transfers` WHERE (`uid1` = "' . $this->info['id'] . '" OR `uid2` = "' . $this->info['id'] . '") AND (`cancel1` = "0" OR (`finish1` > 0 AND `uid1` = "' . $this->info['id'] . '") OR (`finish2` > 0 AND `uid2` = "' . $this->info['id'] . '")) AND (`cancel2` = "0" OR (`finish2` > 0 AND `uid2` = "' . $this->info['id'] . '") OR (`finish1` > 0 AND `uid1` = "' . $this->info['id'] . '")) ORDER BY `id` DESC LIMIT 1'
)
);
if ($this->tfer) {
if ($this->tfer['uid1'] == $this->tfer['uid2']) {
$this->tfer = false;
}
if (isset($this->tfer['id']) && $this->tfer['cancel1'] == 0 && $this->tfer['cancel2'] == 0) {
if ($this->tfer['uid2'] == $this->info['id'] && $this->tfer['start2'] == 0 && isset($_GET['transfer'])) {
$this->tfer['start2'] = time();
mysql_query(
'UPDATE `transfers` SET `start2` = "' . $this->tfer['start2'] . '" WHERE `id` = "' . $this->tfer['id'] . '" LIMIT 1'
);
}
if ($this->tfer['uid2'] == $this->info['id'] && $this->tfer['start2'] == 0) {
$this->tfer = false;
} elseif ($this->tfer['time'] < time() - 1800) {
//если передача дольше 30 минут, то отмена
$upd = mysql_query(
'UPDATE `transfers` SET `cancel1` = "' . time() . '",`cancel2` = "' . time() . '" WHERE `id` = "' . $this->tfer['id'] . '" LIMIT 1'
);
if ($upd) {
unset($this->tfer, $upd);
}
} elseif ($this->info['room'] != $this->tfer['room'] || $this->info['city'] != $this->tfer['city'] || $this->info['battle'] > 0) {
$upd = mysql_query(
'UPDATE `transfers` SET `cancel1` = "' . time() . '",`cancel2` = "' . time() . '" WHERE `id` = "' . $this->tfer['id'] . '" LIMIT 1'
);
if ($upd) {
mysql_query(
'UPDATE `items_users` SET `inTransfer` = "0" WHERE (`uid` = "' . $this->tfer['uid1'] . '" OR `uid` = "' . $this->tfer['uid2'] . '") AND `inTransfer` > 0'
);
unset($this->tfer, $upd);
}
} elseif (isset($_GET['exit_transfer'])) {
$upd = 1;
if ($this->tfer['uid2'] == $this->info['id']) {
$upd = 2;
}
$upd = mysql_query(
'UPDATE `transfers` SET `cancel' . $upd . '` = "' . time() . '" WHERE `id` = "' . $this->tfer['id'] . '" LIMIT 1'
);
if ($upd) {
$this->error = 'Вы успешно отказались от передачи.';
mysql_query(
'UPDATE `items_users` SET `inTransfer` = "0" WHERE (`uid` = "' . $this->tfer['uid1'] . '" OR `uid` = "' . $this->tfer['uid2'] . '") AND `inTransfer` > 0'
);
//Добавляем сообщение в чат
unset($this->tfer, $upd);
}
}
}
}
/*
автофлудераст
*/
//Статистика персонажа на сегодня
$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'])) {
$this->addAction(
time(), 'statistic_today',
'e=' . $this->info['exp'] . '|w=' . $this->info['win'] . '|l=' . $this->info['lose'] . '|n=' . $this->info['nich']
);
}
//Одеваем боевой комплект
if (isset($_GET['usec1']) && $this->info['battle'] == 0) {
$cmp = Db::getValue('select val from save_com where uid = ? and id = ?', [$this->info['id'], (int)$_GET['usec1']]);
if ($cmp) {
//снимаем все вещи
Db::sql('update items_users set inOdet = 0 where uid = ?', [$this->info['id']]);
//одеваем вещи, если они не удалены
$cm = Conversion::dataStringToArray($cmp);
foreach ($cm as $slot => $itemid) {
Db::sql('update items_users set inOdet = ? where id = ? and uid = ? and inShop = 0', [(int)$slot, (int)$itemid, $this->info['id']]);
}
}
unset($cmp, $cm);
}
$this->room = mysql_fetch_array(
mysql_query(
'SELECT `id`,`extdlg`,`lider`,`name`,`city`,`code`,`timeGO`,`file`,`level`,`align`,`clan`,`items`,`effects`,`destroy`,`close`,`roomGo`,`sex`,`FR`,`noatack`,`botgo`,`block_all`,`zvsee`,`roomAjax` FROM `room` WHERE `id` = "' . $this->info['room'] . '" LIMIT 1'
)
);
$this->stats = $this->getStats($this->info['id'], 0);
if (!isset($_GET['obt_sel']) && $this->info['battle'] == 0 && $this->info['obraz'] != '0.gif') {
//Проверяем текущий образ
$tr = true;
$o = mysql_fetch_array(
mysql_query(
'SELECT `id`,`sex`,`tr`,`img`,`login`,`level`,`admin`,`align`,`clan`,`itm` FROM `obraz` WHERE `img` = "' . mysql_real_escape_string(
$this->info['obraz']
) . '" AND `sex` = "' . $this->info['sex'] . '" AND (`login` = "" OR `login` = "' . $this->info['login'] . '") LIMIT 1'
)
);
$t = $this->items['tr'];
$x = 0;
$po = Conversion::dataStringToArray($o['tr']);
if ($o['itm'] > 0) {
$o['itm'] = explode(',', $o['itm']);
$j = 0;
while ($j < count($o['itm'])) {
$itm_id = $o['itm'][$j];
if ($itm_id > 0) {
$itm_id = mysql_fetch_array(
mysql_query(
'SELECT `id`,`name` FROM `items_main` WHERE `id` = "' . $itm_id . '" LIMIT 1'
)
);
$itm_id_true = mysql_fetch_array(
mysql_query(
'SELECT `id` FROM `items_users` WHERE `item_id` = "' . $itm_id['id'] . '" AND
`delete` = 0 AND `inOdet` > 0 AND `inShop` = 0 AND `uid` = "' . $this->info['id'] . '"
LIMIT 1'
)
);
if (!isset($itm_id_true['id'])) {
$tr = false;
}
}
$j++;
}
}
while ($x < count($t)) {
$n = $t[$x];
if (isset($po['tr_' . $n]) && $po['tr_' . $n] > $this->stats[$n]) {
$tr = false;
}
$x++;
}
if ($this->info['clan'] != $o['clan'] && $o['clan'] != 0) {
$tr = false;
}
if ((!isset($o['id']) || !$tr) && $this->info['obraz'] == $o['img']) {
$this->info['obraz'] = '0.gif';
mysql_query(
'UPDATE `users` SET `obraz` = "' . $this->info['obraz'] . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1'
);
}
}
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'])) {
if (isset($_GET['obr_sel'])) {
$tr = true;
$o = mysql_fetch_array(
mysql_query(
'SELECT `id`,`sex`,`tr`,`img`,`login`,`level`,`admin`,`align`,`clan`,`itm` FROM `obraz` WHERE `id` = "' . ((int)$_GET['obr_sel']) . '" AND `sex` = "' . $this->info['sex'] . '" AND (`login` = "" OR `login` = "' . $this->info['login'] . '") LIMIT 1'
)
);
$t = $this->items['tr'];
$x = 0;
$po = Conversion::dataStringToArray($o['tr']);
if ($o['itm'] > 0) {
$o['itm'] = explode(',', $o['itm']);
$j = 0;
$tritm = '';
while ($j < count($o['itm'])) {
$itm_id = $o['itm'][$j];
if ($itm_id > 0) {
$itm_id = mysql_fetch_array(
mysql_query(
'SELECT `id`,`name` FROM `items_main` WHERE `id` = "' . $itm_id . '" LIMIT 1'
)
);
$itm_id_true = mysql_fetch_array(
mysql_query(
'SELECT `id` FROM `items_users` WHERE `item_id` = "' . $itm_id['id'] . '" AND
`delete` = 0 AND `inOdet` > 0 AND `inShop` = 0 AND `uid` = "' . $this->info['id'] . '"
LIMIT 1'
)
);
if (!isset($itm_id_true['id'])) {
$tr = false;
}
if ($j > 0) {
$tritm .= ', ';
}
$tritm .= '&quot;' . $itm_id['name'] . '&quot;';
}
$j++;
}
if ($tritm != '' && !$tr) {
$this->error = 'Необходимы предметы: ' . $tritm . '';
}
}
while ($x < count($t)) {
$n = $t[$x];
if (isset($po['tr_' . $n]) && $po['tr_' . $n] > $this->stats[$n]) {
$tr = false;
$this->error = 'Недостаточно характеристик или параметров персонажа';
}
$x++;
}
if (isset($o['id']) && $tr) {
if ($this->info['obraz'] != $o['img']) {
mysql_query(
'UPDATE `users` SET `obraz` = "' . $o['img'] . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1'
);
$this->addAction(time(), 'sel_obraz', 'id=' . $o['id'] . '');
$this->info['obraz'] = $o['img'];
}
} else {
if ($this->info['obraz'] == $o['img']) {
$this->info['obraz'] = '0.gif';
mysql_query(
'UPDATE `users` SET `obraz` = "' . $this->info['obraz'] . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1'
);
}
}
}
} else {
$this->error = 'Выбирать образ можно не чаще одного раза в сутки, следующая смена ' . date(
'd.m.Y H:i', $sm['time'] + 86400
) . '';
unset($_GET['obr_sel']);
$_GET['inv'] = 1;
}
}
if ($this->info['zv'] > 0) {
$zv = mysql_fetch_array(
mysql_query(
'SELECT `id` FROM `zayvki` WHERE `id` = "' . $this->info['zv'] . '" AND `btl_id` = "0" AND `cancel` = "0" LIMIT 1'
)
);
if (!isset($zv['id'])) {
$this->info['zv'] = 0;
mysql_query('UPDATE `stats` SET `zv` = "0" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1');
}
}
if ($this->info['wipe'] != 0) {
$this->wipe();
}
$this->allActionsStart();
} elseif (isset($this->info['id'])) {
$this->room = mysql_fetch_array(
mysql_query(
'SELECT `id`,`extdlg`,`lider`,`name`,`city`,`code`,`timeGO`,`file`,`level`,`align`,`clan`,`items`,`effects`,`destroy`,`close`,`roomGo`,`sex`,`FR`,`noatack`,`botgo`,`block_all`,`zvsee`,`roomAjax` FROM `room` WHERE `id` = "' . $this->info['room'] . '" LIMIT 1'
)
);
}
$this->infoBox = new InfoBox($this);
}
/** Выборка из user+stats+room по id или login.
* @param int|string $user
* @return array
*/
public static function getInfo(int|string $user): array
{
$cell = is_numeric($user) ? 'id' : 'login';
$query = 'select
*,
users.id as id,
users.level as level,
users.align as align,
users.sex as sex,
users.clan as clan,
stats.timeGo as timeGo,
users.name as name,
stats.lider as lider,
room.name as room_name
from users
left join stats on users.id = stats.id
left join room on users.room = room.id
where users.' . $cell . ' = ?';
$result = Db::getRow($query, [$user]);
$result['testStats2'] = new UserCalculatedStats(new UserStats(Conversion::dataStringToArray($result['stats'])));
return $result ?: [];
}
private function infoTasks()
{
if (empty($this->info)) {
return;
}
$this->userStats = new Stats($this);
//$this->getStats($this->info); // Бля, а вдруг?
$this->stats = $this->userStats->getStats($this->info);
$this->info['achiv'] = Db::getRow('select * from users_achiv where id = ?', [$this->info['id']]);
if (!isset($this->info['achiv']['id'])) {
Db::sql('insert into users_achiv (id) value (?)', [$this->info['id']]);
$this->info['achiv'] = Db::getRow('select * from users_achiv where id = ?', [$this->info['id']]);
}
if (isset($this->info['id']) && $this->info['exp'] > 300000 && $this->info['twink'] > 0) {
$this->info['exp'] = 300000;
Db::sql('update stats set exp = ? where id = ?', [$this->info['exp'], $this->info['id']]);
}
if (isset($this->info['id']) && $this->info['inUser']) {
$md = [
$this->info['molch1'],
$this->info['molch2'],
$this->info['molch3'],
$this->info['admin'],
$this->info['nadmin'],
$this->info['banned'],
$this->info['align'],
$this->info['id'],
$this->info['level'],
];
$this->info = $this->getUserInfoById($this->info['inUser']);
if ($this->info['molch1'] < $md[0]) {
$this->info['molch1'] = $md[0];
}
if ($this->info['molch2'] < $md[1]) {
$this->info['molch2'] = $md[1];
}
if ($this->info['molch3'] < $md[2]) {
$this->info['molch3'] = $md[2];
}
if ($this->info['admin'] < $md[3]) {
$this->info['admin'] = $md[3];
}
if ($this->info['nadmin'] < $md[4]) {
$this->info['nadmin'] = $md[4];
}
if ($this->info['banned'] < $md[5]) {
$this->info['banned'] = $md[5];
}
$this->info['noreal'] = 1;
$this->info['align_real'] = $md[7];
$this->info['__id'] = $md[8];
$this->info['__level'] = $md[9];
}
}
public function getStats($uid, $i1 = null, $res = 0, $reimg = false, $btl_cache = false, $minimal = false): array
{
$result = new Stats($this);
return $result->getStats($uid, $i1, $res, $reimg, $btl_cache);
}
public function getUserInfoById($id)
{
return Db::getRow('select * from users left join stats on users.id = stats.id where users.id = ?', [$id]);
}
public function testAction($filter, $tp): array
{
if ($tp == 1) {
$query = 'select * from actions where ' . $filter;
} elseif ($tp == 2) {
$query = 'select count(*) from actions where ' . $filter;
} else {
return [];
}
$arr = mysql_fetch_array(mysql_query($query));
return !empty($arr) ? $arr : [];
}
//Удаление определенного типа предметов
public function addAction($time, $vars, $vls, $uid = null): bool
{
$info = $this->info;
if ($uid) {
$info['id'] = $uid;
}
ActionModel::new($info, $vls, $vars, $time);
return true;
}
public function testHome(): array
{
/*----Быстрый(Особенность)----*/
$timeforwait = 3600;
if (isset($st['os3']) && $st['os3'] > 0) {
$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;
}
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;
}
}
return $hgo ?? [];
}
public function wipe()
{
if ($this->info['wipe'] > 0 && $this->info['battle'] == 0) {
//wipe = 1 , значит обнуляем статы и умения
if ($this->info['wipe'] < 4) {
$st = Conversion::dataStringToArray($this->info['stats']);
$n1 = $this->info['ability']; //способности
$n2 = $this->info['skills']; //владение магией и оружием
$n3 = $this->info['sskills']; //особенности
$n4 = $this->info['nskills']; //???
if ($this->info['wipe'] == 1 || $this->info['wipe'] == 2) {
$i = 1;
while ($i <= 11) {
if ($i <= 4) {
$n1 += $st['s' . $i] - 3;
$st['s' . $i] = 3;
} else {
$n1 += $st['s' . $i];
$st['s' . $i] = 0;
}
$i++;
}
$n1 -= $this->info['level'];
$st['s4'] = 3 + $this->info['level'];
if ($this->info['level'] >= 9) {
$st['s4'] += 1;
$n1 -= 1;
}
if ($this->info['level'] >= 10) {
$st['s4'] += 2;
$n1 -= 2;
}
if ($this->info['level'] >= 11) {
$st['s4'] += 4;
$n1 -= 4;
}
}
if ($this->info['wipe'] == 1 || $this->info['wipe'] == 3) {
$i = 1;
while ($i <= 7) {
$n2 += $st['a' . $i];
$n2 += $st['mg' . $i];
$st['a' . $i] = 0;
$st['mg' . $i] = 0;
$i++;
}
}
if ($this->info['wipe'] == 1 || $this->info['wipe'] == 3.5)#---Сброс особенностей
{
$i = 1;
while ($i <= 11) {
$n3 += $st['os' . $i];
$st['os' . $i] = 0;
$i++;
}
}
//сохраняем данные
$st = Conversion::arrayToDataString($st);
$upd = mysql_query(
'UPDATE `stats` SET `wipe`="0",`stats`="' . $st . '",`ability`="' . $n1 . '",`skills`="' . $n2 . '",`sskills`="' . $n3 . '",`nskills`="' . $n4 . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1'
);
if ($upd) {
$this->info['stats'] = $st;
$this->info['ability'] = $n1;
$this->info['skills'] = $n2;
$this->info['sskills'] = $n3;
$this->info['nskills'] = $n4;
}
}
}
}
//Выводим вещи котоыре нужно отремонтировать
//Расчет урона от оружия
public function allActionsStart()
{
global $magic;
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) {
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 = $this->testAction(
'`uid` = "' . $this->info['id'] . '" AND `time`>=' . strtotime(
'now 00:00:00'
) . ' AND `vars` = "create_snowball_cp" LIMIT 25',
2
);
$smt = $smt[0];
if ($smt < 10) {
$this->addAction(time(), 'create_snowball_cp', $this->info['city']);
$magic->addEffect($this->info['id'], 24);
$this->error2 = 'Начинаем лепить снежок, осталось ' . (10 - $smt) . ' раз на сегодня ...';
} else {
$this->error2 = 'Вы уже слепили 10 снежка за сегодня ...';
}
}
}
}
//Расчет защиты
public static function getLoginById(int $uid): string
{
return Db::getValue('select login from users where id = ?', [$uid]) ?: '';
}
//Расчет защиты (магия)
/** Singletone.
* @return User
*/
public static function start(): User
{
if (!isset(self::$flag_one)) {
self::$flag_one = new self();
}
return self::$flag_one;
}
public static function setOnline(int $uid): void
{
Db::sql('update users set online = unix_timestamp() where id = ?', [$uid]);
}
public function dayquest(int $id): string
{
$test = Db::getRow('select id, vals from actions where uid = ? and vars = ?', [$id, 'day_quest']);
$q = [
'1' => 'Убийство Трупожоров',
'2' => 'Победы в хаотических боях',
'3' => 'Спуск в Подземелия',
'4' => 'Набрать в хаотических поединках 100 000 Опыта',
'5' => 'Открыть Сундук Трупожора',
'6' => 'Посетить Излом Хаоса',
'7' => 'Сдача 3 заданий в пещерах',
'8' => 'Поучаствовать в Башне Смерти',
];
if (!isset($test['id'])) {
$n = "<a href='main.php?getq=1'><b style='color:green'>Получить задание</b></a>";
} else {
$n = "<a href='main.php?putq=1'><b style='color:green'>Сдать задание</b></a>";
$n = $n . "<br><b style='color:green'>" . $q[$test['vals']] . "</b>";
}
return $n;
}
public function testAlign($an, int $uid): int
{
$r = 1;
if (floor($an) > 0) {
$a = Db::getValue('select align from users_align where uid = ?', [$uid]);
if (floor((float)$a) != $an) {
$r = 0;
}
}
return $r;
}
public function abilsRoom(string $type): string
{
$r = '';
//
if ($this->info['clan'] > 0 || !in_array($this->room['name'], ['Зал Света', 'Зал Нейтралов', 'Зал Тьмы'])) {
//Нельзя использовать персонажам в клане
return '';
}
if ($type == 'test') {
if (isset($_GET['vhp'])) {
$v = Db::getValue('select time from vortex where uid = ? and type = 1 order by time desc limit 1');
if ($v > time() - 60 * 60) {
//Уже юзали
$this->error = 'Необходимо подождать еще ' . Conversion::secondsToTimeout($v + 60 * 60 - time());
} else {
if ($this->stats['hpNow'] < 1) {
$this->stats['hpNow'] = 0;
}
$this->error = 'Вы успешно восстановили ' . round($this->stats['hpAll'] - $this->stats['hpNow']) . ' HP.';
Db::sql(
'insert into vortex (uid, room, time, val, type) VALUES (?,?,unix_timestamp(),?,1)',
[$this->info['id'], $this->info['room'], round($this->stats['hpAll'] - $this->stats['hpNow'])]
);
$this->stats['hpNow'] = $this->stats['hpAll'];
Db::sql('update stats set hpNow = ? where id = ?', [$this->stats['hpNow'], $this->info['id']]);
}
} elseif (isset($_GET['vmp'])) {
$v = Db::getValue('select time from vortex where uid = ? and type = 2 order by time desc limit 1');
if ($v > time() - 60 * 60) {
//Уже юзали
$this->error = 'Необходимо подождать еще ' . Conversion::secondsToTimeout($v + 60 * 60 - time());
} else {
if ($this->stats['mpNow'] < 1) {
$this->stats['mpNow'] = 0;
}
$this->error = 'Вы успешно восстановили ' . round($this->stats['mpAll'] - $this->stats['mpNow']) . ' MP.';
Db::sql(
'insert into vortex (uid, room, time, val, type) VALUES (?,?,unix_timestamp(),?,2)',
[$this->info['id'], $this->info['room'], round($this->stats['mpAll'] - $this->stats['mpNow'])]
);
$this->stats['mpNow'] = $this->stats['mpAll'];
Db::sql('update stats set mpNow = ? where id = ?', [$this->stats['mpNow'], $this->info['id']]);
}
}
} elseif ($type == 'look') {
$vid = 0;
if ($this->room['name'] == 'Зал Света') {
$vid = 6;
} elseif ($this->room['name'] == 'Зал Тьмы') {
$vid = 7;
} elseif ($this->room['name'] == 'Зал Нейтралов') {
$vid = 10;
}
$v = mysql_fetch_array(
mysql_query(
'SELECT * FROM `vortex` WHERE `uid` = "' . $this->info['id'] . '" AND `type` = 1 ORDER BY `time` DESC LIMIT 1'
)
);
if (isset($v['id']) && $v['time'] + 60 * 60 > time()) {
$r .= '<img style="cursor:pointer;filter:alpha(opacity=47);opacity:0.47;-moz-opacity:0.47;-khtml-opacity:0.47;" onClick="alert(\'Возможно воспользоваться через ' . $this->timeOut(
$v['time'] + 60 * 60 - time()
) . '\');" src="' . Config::img() . '/i/items/healvortex_' . $vid . '.png" width="40" height="25" title="Клодец HP (Задержка)"> ';
} else {
$r .= '<a href="main.php?vhp"><img src="' . Config::img() . '/i/items/healvortex_' . $vid . '.png" width="40" height="25" title="Клодец HP"></a> ';
}
$v = mysql_fetch_array(
mysql_query(
'SELECT * FROM `vortex` WHERE `uid` = "' . $this->info['id'] . '" AND `type` = 2 ORDER BY `time` DESC LIMIT 1'
)
);
if (isset($v['id']) && $v['time'] + 60 * 60 > time()) {
$r .= '<img style="cursor:pointer;filter:alpha(opacity=47);opacity:0.47;-moz-opacity:0.47;-khtml-opacity:0.47;" onClick="alert(\'Возможно воспользоваться через ' . $this->timeOut(
$v['time'] + 60 * 60 - time()
) . '\');" src="' . Config::img() . '/i/items/manavortex_' . $vid . '.png" width="40" height="25" title="Клодец MP (Задержка)"> ';
} else {
$r .= '<a href="main.php?vmp""><img src="' . Config::img() . '/i/items/manavortex_' . $vid . '.png" width="40" height="25" title="Клодец MP"></a> ';
}
}
return $r;
}
/**
* @param $ttm
* @return string
* @deprecated использовать ConversionHelper::secondsToTimeout()
*/
public function timeOut($ttm): string
{
return Conversion::secondsToTimeout($ttm);
}
public function insertAlign($an, $uid): void
{
if ($an <= 0) {
return;
}
Db::sql('replace into users_align (uid, time, align) VALUES (?,unix_timestamp(),?)', [$uid, floor($an)]);
}
public function deleteAlign($an, $uid): void
{
if ($an <= 0) {
return;
}
Db::sql('delete from users_align where uid = ? and align = ?', [$uid, floor($an)]);
}
public function repobmen(int $id, $type): string
{
//echo 'обмен';
$pl = ItemsModel::getOwnedItemById($this->info['id'], $id);
$po = Conversion::dataStringToArray($pl['data']);
if ((!isset($po['frompisher']) || $po['tr_lvl'] < 4) && $pl['type'] != 31) {
$e = 'Не удалось обменять предмет на репутацию.';
} else {
$e = 'Обмен предмета "' . $pl['name'] . '" на репутацию Сapitalcity прошел удачно.';
ItemsModel::delete($pl['id']);
$this->rep['repcapitalcity'] = $this->reputation->addRep('repcapitalcity', 1);
}
return $e;
}
public function lookKeys($m, $i): array
{
$e = explode('|', $m);
$r = [];
while ($i < count($e)) {
$j = explode('=', $e[$i]);
$r[$i] = $j[0];
$i++;
}
return $r;
}
public function zago($v): float
{
if ($v > 1700) {
$v = 1700;
}
return round((1 - (pow(0.5, ($v / 399.51)))) * 100, 2);
}
public function zmgo($v)
{
if ($v > 1000) {
$v = 1000;
}
return (1 - (pow(0.5, ($v / 250)))) * 100;
}
public function inform(string $v)
{
$r = '';
$y = [];
$w1 = 0;
$w2 = 0;
$i = 0;
if ($v == 'yrontest' || $v == 'yrontest-krit') {
/* первое оружие или кулак */
if (is_array($this->stats['items'])) {
while ($i < count($this->stats['items'])) {
if ($this->stats['items'][$i]['inOdet'] == 3 && $w1 == 0 && $this->stats['items'][$i]['type'] >= 18 && $this->stats['items'][$i]['type'] <= 28) {
$w1 = $this->stats['items'][$i];
} elseif ($this->stats['items'][$i]['inOdet'] == 14 && $w2 == 0 && $this->stats['items'][$i]['type'] >= 18 && $this->stats['items'][$i]['type'] <= 28) {
$w2 = $this->stats['items'][$i];
}
$i++;
}
}
if (isset($w1['id']) && $w1['inOdet'] != 14) {
$tp = 0;
$t = 0;
$i = 1;
$d = Conversion::dataStringToArray($w1['data']);
while ($i <= 4) {
if (isset($d['tya' . $i]) && $t < $d['tya' . $i]) {
$t = $d['tya' . $i];
$tp = $i;
}
$i++;
}
$y = $this->weaponAtc($w1, $this->stats, $tp);
if ($v == 'yrontest-krit') {
$y[0] = $y[2];
$y[1] = $y[3];
}
if ($y[0] < 1) {
$y[0] = 1;
}
if ($y[1] < 1) {
$y[1] = 1;
}
$r .= '<span title="' . $w1['name'] . '">' . $y[0] . '-' . $y[1] . '</span>';
} else {
//урон кулаком
$y[0] = ceil(
2 + $this->info['level'] + $this->stats ['s1'] - round($this->stats['s1'] / 5)
) + $this->stats['minAtack'] + $this->stats['yron_min'];
$y[1] = ceil($y[0] + 3) + $this->stats['maxAtack'] + $this->stats['yron_max'];
if ($y[0] < 1) {
$y[0] = 1;
}
if ($y[1] < 1) {
$y[1] = 1;
}
$r .= $y[0] . '-' . $y[1];
}
/* второе оружие */
if (isset($w2['id'])) {
$tp = 0;
$t = 0;
$i = 1;
$d = Conversion::dataStringToArray($w2['data']);
while ($i <= 4) {
if ($t < $d['tya' . $i]) {
$t = $d['tya' . $i];
$tp = $i;
}
$i++;
}
$y = $this->weaponAtc($w2, $this->stats, $tp);
if ($v == 'yrontest-krit') {
$y[0] = $y[2];
$y[1] = $y[3];
}
if ($y[0] < 1) {
$y[0] = 1;
}
if ($y[1] < 1) {
$y[1] = 1;
}
$r .= ' / <span title="' . $w2['name'] . '">' . $y[0] . '-' . $y[1] . '</span>';
}
/* --- */
} elseif ($v == 'yron') {
/* первое оружие или кулак */
while ($i < count($this->stats['items'])) {
if ($this->stats['items'][$i]['inOdet'] == 3 && $w1 == 0 && $this->stats['items'][$i]['type'] >= 18 && $this->stats['items'][$i]['type'] <= 28) {
$w1 = $this->stats['items'][$i];
} elseif ($this->stats['items'][$i]['inOdet'] == 14 && $w2 == 0 && $this->stats['items'][$i]['type'] >= 18 && $this->stats['items'][$i]['type'] <= 28) {
$w2 = $this->stats['items'][$i];
}
$i++;
}
if (isset($w1['id']) && $w1['inOdet'] != 14) {
$tp = 0;
$t = 0;
$i = 1;
$d = Conversion::dataStringToArray($w1['data']);
while ($i <= 4) {
if (isset($d['tya' . $i]) && $t < $d['tya' . $i]) {
$t = $d['tya' . $i];
$tp = $i;
}
$i++;
}
$y = $this->weaponAtc($w1, $this->stats, $tp);
if ($y[0] < 1) {
$y[0] = 1;
}
if ($y[1] < 1) {
$y[1] = 1;
}
$r .= '<span title="' . $w1['name'] . '">' . $y[0] . '-' . $y[1] . '</span>';
} else {
//урон кулаком
$y[0] = ceil($this->stats['s1'] * 1.4) + $this->stats['minAtack'] + $this->stats['yron_min'];
$y[1] = ceil(0.4 + $y[0] / 0.9) + $this->stats['maxAtack'] + $this->stats['yron_max'];
if ($y[0] < 1) {
$y[0] = 1;
}
if ($y[1] < 1) {
$y[1] = 1;
}
$r .= $y[0] . '-' . $y[1];
}
/* второе оружие */
if (isset($w2['id'])) {
$tp = 0;
$t = 0;
$i = 1;
$d = Conversion::dataStringToArray($w2['data']);
while ($i <= 4) {
if ($t < $d['tya' . $i]) {
$t = $d['tya' . $i];
$tp = $i;
}
$i++;
}
$y = $this->weaponAtc($w2, $this->stats, $tp);
if ($y[0] < 1) {
$y[0] = 1;
}
if ($y[1] < 1) {
$y[1] = 1;
}
$r .= ' / <span title="' . $w2['name'] . '">' . $y[0] . '-' . $y[1] . '</span>';
}
} else {
//модификаторы
/* первое оружие или кулак */
$ry = 0;
while ($i < count($this->stats['items'])) {
if ($this->stats['items'][$i]['inOdet'] == 3 && $w1 == 0 && $this->stats['items'][$i]['type'] >= 18 && $this->stats['items'][$i]['type'] <= 28) {
$w1 = $this->stats['items'][$i];
} elseif ($this->stats['items'][$i]['inOdet'] == 14 && $w2 == 0 && $this->stats['items'][$i]['type'] >= 18 && $this->stats['items'][$i]['type'] <= 28) {
$w2 = $this->stats['items'][$i];
}
$i++;
}
if (isset($w1['id']) && $w1['inOdet'] != 14) {
$tp = 0;
$t = 0;
$i = 1;
$d = Conversion::dataStringToArray($w1['data']);
$y = 0;
if (isset($d['sv_' . $v])) {
$y += $d['sv_' . $v];
}
if (isset($this->stats[$v])) {
$y += $this->stats[$v];
}
$ry = $y;
$r .= '<span title="' . $w1['name'] . '">' . $y . '</span>';
} else {
//кулаком
$r .= $this->stats[$v];
$ry = $this->stats[$v];
}
/* второе оружие */
if (isset($w2['id'])) {
$tp = 0;
$t = 0;
$i = 1;
$d = Conversion::dataStringToArray($w2['data']);
$y = @$this->stats[$v] + @$d['sv_' . $v];
if ($y != $ry) {
$r .= ' / <span title="' . $w2['name'] . '">' . $y . '</span>';
} else {
$r = str_replace('title="' . $w1['name'] . '"', '', $r);
}
}
//модификаторы
}
return $r;
}
private function weaponAtc($item, $st, $x)
{
$tp = 0;
if (isset($item['id'])) {
$itm = Conversion::dataStringToArray($item['data']);
//начинаем расчет урона
if (!isset($st['minAtack'])) {
$st['minAtack'] = 0;
}
if (!isset($st['maxAtack'])) {
$st['maxAtack'] = 0;
}
if (!isset($st['yron_min'])) {
$st['yron_min'] = 0;
}
if (!isset($st['yron_max'])) {
$st['yron_max'] = 0;
}
if (!isset($itm['yron_min'])) {
$itm['yron_min'] = 0;
}
if (!isset($itm['yron_max'])) {
$itm['yron_max'] = 0;
}
if (!isset($itm['sv_yron_min'])) {
$itm['sv_yron_min'] = 0;
}
if (!isset($itm['sv_yron_max'])) {
$itm['sv_yron_max'] = 0;
}
$min = $itm['sv_yron_min'] + $st['minAtack'] + $itm['yron_min'] + $st['yron_min'];
$max = $itm['sv_yron_max'] + $st['maxAtack'] + $itm['yron_max'] + $st['yron_max'];
//Тип урона: 0 - нет урона, 1 - колющий, 2 - рубящий, 3 - дробящий, 4 - режущий, 5 - огонь, 6 - воздух, 7 - вода, 8 - земля, 9 - свет, 10 - тьма, 11 - серая
if ($item['type'] == 18) {
//колющий
$sss = ceil($st['s2'] * 0.75);
} elseif ($item['type'] == 19) {
//рубящий
$sss = ceil($st['s1'] * 0.75);
} elseif ($item['type'] == 20) {
//дробящий
$sss = ceil($st['s4'] * 1.5);
} elseif ($item['type'] == 21) {
//режущий
$sss = ceil($st['s3'] * 0.75);
} else {
//без профильного урона
$sss = ceil($st['s1'] * 0.1);
}
//Обычный урон
$p['B'][0] = ceil($st['s1'] * 1);
$p['B'][1] = ceil(0.4 + $p['B'][0] / 0.9);
$p['B'][0] = 2 + $st['level'] + $st['s1'] - round($st['s1'] / 5);
$p['B'][1] = $p['B'][0] + 3;
$p['B']['rnd'] = rand($p['B'][0], $p['B'][1]);
//Добавочный минимальный урон
$p['W'][0] = $min;
$p['W'][1] = $max;
$p['W']['rnd'] = rand($p['W'][0], $p['W'][1]);
// Коэф. оружия
$p['T'] = 1;
//Владения
$bn = 0;
if ($item['type'] == 21) {
// меч
$p['M'] = $st['pa4'];
$bn = $st['a4'];
//ТУТ $p['M'] = $st['pa'.$x];
} elseif ($item['type'] == 20) {
// дубина
$p['M'] = $st['pa3'];
$bn = $st['a3'];
} elseif ($item['type'] == 19) {
// топор
$p['M'] = $st['pa2'];
$bn = $st['a2'];
} elseif ($item['type'] == 18) {
// нож
$p['M'] = $st['pa1'];
$bn = $st['pa1'];
} elseif ($item['type'] == 22) {
// посох
$p['M'] = $st['pa3'];
$bn = $st['a5'];
}
//Мощнность
$min = (($p['B'][0] + $sss + $p['W'][0]) * $p['T'] * (1 + 0.005 * $bn)) * (1 + $p['M'] / 100);
$max = (($p['B'][1] + $sss + $p['W'][1]) * $p['T'] * (1 + 0.005 * $bn)) * (1 + $p['M'] / 100);
//
$kmin = ceil((2 * (1 + $st['m3'] / 100)) * $min);
$kmax = ceil((2 * (1 + $st['m3'] / 100)) * $max);
$tp = [0 => ceil($min), 1 => ceil($max), 2 => ceil($kmin), 3 => ceil($kmax)];
}
return $tp;
}
public function rep_zv(int $id, int $e): string
{
$r = '0 / 0';
if ($id == 1) {
//Храм знаний
if ($e > 9999) {
$r = 'Посвященный третьего круга, ' . $e . ' / ??';
} elseif ($e > 999) {
$r = 'Посвященный второго круга, ' . $e . ' / 9999';
} elseif ($e > 99) {
$r = 'Посвященный первого круга, ' . $e . ' / 999';
} else {
$r = $e . ' / 99';
}
} elseif ($id == 2 || $id == 3 || $id == 4 || $id == 6 || $id == 7 || $id == 8) {
//Capital city
if ($e > 24999) {
$r = 'Рыцарь второго круга, ' . $e . ' / ??';
} elseif ($e > 9999) {
$r = 'Рыцарь первого круга, ' . $e . ' / 24999';
} else {
$r = $e . ' / 10000';
}
} elseif ($id == 5) {
//Алтарь Крови
if ($e > 99) {
$r = 'Посвященный первого круга ' . $e . ' / 999';
} else {
$r = $e . ' / 99';
}
} elseif ($id == 9) {
//Dreams city
if ($e > 9999) {
$r = 'Посвященный третьего круга, [' . $e . ']';
} elseif ($e > 4999) {
$r = 'Посвященный второго круга,' . $e . ' / 9999';
} elseif ($e > 999) {
$r = 'Посвященный первого круга, ' . $e . ' / 4999';
} else {
$r = $e . ' / 999';
}
} elseif ($id == 10) {
//Гора легиона
if ($e > 9999) {
$r = 'Посвященный второго круга,[' . $e . ']';
} elseif ($e > 999) {
$r = 'Посвященный первого круга, ' . $e . ' / 4999';
} else {
$r = $e . ' / 999';
}
} elseif ($id == 11) {
//Излом Хаоса
if ($e > 9999) {
$r = 'Легенда Излома Хаоса, [' . $e . ']';
} elseif ($e > 4999) {
$r = 'Чемпион Излома Хаоса,' . $e . ' / 9999';
} elseif ($e > 999) {
$r = 'Знаток Излома Хаоса, ' . $e . ' / 4999';
} else {
$r = $e . ' / 999';
}
}
return $r;
}
//Удаление определенного типа предметов
public function getNum($v)
{
$plid = $v;
$pi = iconv_strlen($plid);
if ($pi < 5) {
$i = 0;
while ($i <= 5 - $pi) {
$plid = '0' . $plid;
$i++;
}
}
return $plid;
}
/** Возврат имени персонажа со всеми регалиями
* @param int|null $uid id персонажа. Если пусто, возвращается имя персонажа активного игрока.
* @return string
*/
public function getLogin(?int $uid = null):string {
if (is_null($uid)) {
$uid = $this->info['id'];
}
[$align, $login, $level, $clanName] = Db::getRow(
'select
users.align,
login,
users.level,
c.name_mini
from users left join clan as c on c.id = users.clan
where users.id = ?',
[$uid]
);
$imgBase = Config::img() . DIRECTORY_SEPARATOR . 'i';
$alignStr = empty($align) ? '' : "<img src='$imgBase/align/align$align.gif' alt=''>";
$clanStr = empty($clanName) ? '' : "<img src='$imgBase/clan/$clanName.gif' alt='$clanName'>";
$spacedLogin = str_replace(' ', '%20', $login);
$loginLink = "<a href='/inf.php?login=$spacedLogin' target='_blank'><img src='img/inf.gif' title='Инф. о $login' alt='Инф. о $login'></a>";
return "$alignStr$clanStr<strong>$login</strong> [$level]$loginLink";
}
public function addNewbot($id, $botDate, $clon, $logins_bot = null, $luser = null, $round = null)
{
if ($clon != null) {
$r = 0;
if (!is_array($clon)) {
$clon = $this->getUserInfoById((int)$clon);
}
if (isset($clon['id'])) {
if (!isset($clon['loclon'])) {
$clon['login'] .= ' (Клон)';
}
//копируем пользователя
Db::sql(
"insert into users (align, login, level, pass, city, cityreg, name, sex, timereg, obraz, bot_id, inTurnir) values (?,?,?,uuid(),'Неведомые земли','Неведомые земли',?,?,?,?,?,?)",
[
$clon['align'] ?? 0,
$clon['login'],
$clon['level'],
$clon['login'],
$clon['sex'],
$clon['time_reg'],
$clon['obraz'],
$id,
$clon['inTurnir'] ?? 0,
]
);
if ($round > 0) {
//Улучшаем мф. и статы и НР 1 раунд = +10%
$statss = Conversion::dataStringToArray($clon['stats']);
//
$statss['s1'] = ceil($statss['s1'] * (1 + 0.1 * ($round)));
$statss['s2'] = ceil($statss['s2'] * (1 + 0.1 * ($round)));
$statss['s3'] = ceil($statss['s3'] * (1 + 0.1 * ($round)));
$statss['s4'] = ceil($statss['s4'] * (1 + 0.1 * ($round)));
//
$statss['hpAll'] = ceil($statss['hpAll'] * (1 + 0.1 * ($round)));
$statss['mpAll'] = ceil($statss['mpAll'] * (1 + 0.1 * ($round)));
//
$statss['m1'] = ceil($statss['m1'] * (1 + 0.1 * ($round)));
$statss['m2'] = ceil($statss['m2'] * (1 + 0.1 * ($round)));
$statss['m3'] = ceil($statss['m3'] * (1 + 0.1 * ($round)));
$statss['m4'] = ceil($statss['m4'] * (1 + 0.1 * ($round)));
$statss['m5'] = ceil($statss['m5'] * (1 + 0.1 * ($round)));
$statss['za'] = ceil($statss['za'] * (1 + 0.1 * ($round)));
$statss['zm'] = ceil($statss['zm'] * (1 + 0.1 * ($round)));
$clon['stats'] = Conversion::arrayToDataString($statss);
unset($statss);
}
$uid = Db::lastInsertId();
//копируем статы
Db::sql('insert into stats (clone, id, stats, hpNow, upLevel, bot, priems) values (?,?,?,1000000,?,1,?)', [$clon['id'], $uid, $clon['stats'], $clon['upLevel'], $clon['priems']]);
//копируем предметы
Db::sql(
"insert into items_users (uid, item_id, data, inOdet, iznosMAX, kolvo) select ?, item_id, replace(data, 'toclan', 'to_clan_'), inOdet, iznosMAX, kolvo from items_users where inOdet > 0 and uid = ?",
[$uid, $clon['id']]
);
//копируем эффекты
Db::sql(
"insert into eff_users (uid, id_eff, data, name, overType, timeUse, x) select ?, id_eff, data, name, overType, timeUse, x from eff_users where uid = ? and deactiveTime < unix_timestamp() and v1 != 'priem'",
[$uid, $clon['id']]
);
$r = $uid;
}
return $r;
} else {
$bot = Db::getRow('select id, login, stats, upLevel, itemsUse from test_bot where id = ?', [$id]);
if (!isset($bot['id'])) {
return [];
} else {
if (isset($logins_bot[$bot['login']])) {
$logins_bot[$bot['login']]++;
$bot['login'] = $bot['login'] . ' (' . $logins_bot[$bot['login']] . ')';
} else {
$logins_bot[$bot['login']] = 1;
}
Db::sql(
"insert into users (align, login, level, pass, city, cityreg, name, sex, hobby, timereg, obraz, bot_id)
select align, ?, level, uuid(), 'Неведомые земли', 'Неведомые земли', name, sex, hobby, replace(time_reg, 100, unix_timestamp()), obraz, id
from test_bot where id = ?",
[$bot['login'], $id]
);
$uid = Db::lastInsertId();
if ($round > 0) { //Улучшаем мф. и статы и НР 1 раунд = +20%
$statss = Conversion::dataStringToArray($bot['stats']);
$statss['s1'] = ceil($statss['s1'] * (1 + 0.20 * ($round)));
$statss['s2'] = ceil($statss['s2'] * (1 + 0.20 * ($round)));
$statss['s3'] = ceil($statss['s3'] * (1 + 0.20 * ($round)));
$statss['s4'] = ceil($statss['s4'] * (1 + 0.20 * ($round)));
$statss['hpAll'] = ceil($statss['hpAll'] * (1 + 0.20 * ($round)));
$statss['mpAll'] = ceil($statss['mpAll'] * (1 + 0.20 * ($round)));
$statss['m1'] = ceil($statss['m1'] * (1 + 0.20 * ($round)));
$statss['m2'] = ceil($statss['m2'] * (1 + 0.20 * ($round)));
$statss['m3'] = ceil($statss['m3'] * (1 + 0.20 * ($round)));
$statss['m4'] = ceil($statss['m4'] * (1 + 0.20 * ($round)));
$statss['m5'] = ceil($statss['m5'] * (1 + 0.20 * ($round)));
$statss['za'] = ceil($statss['za'] * (1 + 0.20 * ($round)));
$statss['zm'] = ceil($statss['zm'] * (1 + 0.20 * ($round)));
$bot['stats'] = Conversion::arrayToDataString($statss);
unset($statss);
}
Db::sql('insert into stats (id, stats, hpNow, upLevel, bot) values (?,?,1000000,?,1)', [$uid, $bot['stats'], $bot['upLevel']]);
$bot['id'] = $uid;
$bot['logins_bot'] = $logins_bot;
//Выдаем предметы
$iu = explode(',', $bot['itemsUse']);
$i = 0;
$w3b = 0;
foreach ($iu as $item) {
$iditem = ItemsModel::addItem($item, $bot['id']);
$inslot = Db::getValue('select inslot from items_main where id = ?', [$item]) ?? 2000;
if ($inslot === 3) {
if ($w3b === 1) {
$inslot = 14;
} else {
$w3b = 1;
}
}
Db::sql('update items_users set inOdet = ? where id = ?', [$inslot, $iditem]);
}
return $bot;
}
}
}
//Расчет урона от оружия
//Расчет защиты
//Расчет защиты (магия)
public function newAct($test): bool
{
$r = true;
if ($test != $this->info['nextAct'] && $this->info['nextAct'] != '0') {
$r = false;
} else {
$na = md5(time() . '_nextAct_' . rand(0, 100));
$upd = mysql_query(
'UPDATE `stats` SET `nextAct` = "' . $na . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1'
);
if (!$upd) {
$r = false;
} else {
$this->info['nextAct'] = $na;
}
}
return $r;
}
public function addKr($amount, $uid = 0): void
{
if ($uid === 0) {
$uid = $this->info['id'];
$this->info['money'] += $amount;
}
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)) {
$vl = $vl . '.00';
}
$vl = explode('.', $vl);
return $vl[0] . '.<small>' . $vl[1] . '</small>';
}
#[NoReturn] public function __clone()
{
trigger_error('Дублирование не допускается.', E_USER_ERROR);
}
public function freeStatsMod($id, $s, $uid): void
{
$itm = Db::getValue('select data from items_users where id = ? and uid = ? and inShop = 0 and inOdet = 0', [$id, $uid]);
if (!isset($itm)) {
return;
}
$po = Conversion::dataStringToArray($itm);
//статы
if ($_GET['mf'] == 's1' || $_GET['mf'] == 's2' || $_GET['mf'] == 's3' || $_GET['mf'] == 's5') {
if (isset($po['mf_stats']) && $po['mf_stats'] > 0 && isset($po['add_' . $_GET['mf']])) {
$po['mf_stats'] = (int)$po['mf_stats'];
$po['mf_stats'] -= 1;
$po['add_' . $_GET['mf']] += 1;
}
} elseif ($_GET['mf'] == 'm1' || $_GET['mf'] == 'm2' || $_GET['mf'] == 'm4' || $_GET['mf'] == 'm5') {
if (isset($po['mf_mod']) && $po['mf_mod'] > 0 && isset($po['add_' . $_GET['mf']])) {
$po['mf_mod'] = (int)$po['mf_mod'];
$po['mf_mod'] -= 1;
$po['add_' . $_GET['mf']] += 1;
}
} elseif ($_GET['mf'] == 'mib1' || $_GET['mf'] == 'mib2' || $_GET['mf'] == 'mib3' || $_GET['mf'] == 'mib4') {
$s = $_GET['mf'];
$s = str_replace('mib', '', $s);
$s = (int)$s;
if (isset($po['mf_mib']) && $po['mf_mib'] > 0 && (isset($po['add_mib' . $s]) || isset($po['add_mab' . $s]))) {
$po['mf_mib'] = (int)$po['mf_mib'];
$po['mf_mib'] -= 1;
if (isset($po['add_mab' . $s])) {
$po['add_mab' . $s] += 1;
}
if (isset($po['add_mib' . $s])) {
$po['add_mib' . $s] += 1;
}
Db::sql('update items_users set data = ? where id = ?', [Conversion::arrayToDataString($po), $id]);
}
}
if ($_GET['mf'] == 's1' || $_GET['mf'] == 's2' || $_GET['mf'] == 's3' || $_GET['mf'] == 's5' ||
$_GET['mf'] == 'm1' || $_GET['mf'] == 'm2' || $_GET['mf'] == 'm4' || $_GET['mf'] == 'm5') {
Db::sql('update items_users set data = ? where id = ?', [Conversion::arrayToDataString($po), $id]);
}
}
public function freeStatsItem(int $id, int $s, int $uid): void
{
$itm = Db::getValue('select data from items_users where id = ? and uid = ? and inShop = 0 and inOdet = 0', [$id, $uid]);
if (!$itm || $s != 1 && $s != 2 && $s != 3 && $s != 5) {
return;
}
$po = Conversion::dataStringToArray($itm);
if (isset($po['free_stats']) && $po['free_stats'] > 0) {
$po['free_stats'] = (int)$po['free_stats'];
$po['free_stats'] -= 1;
$po['add_s' . $s] += 1;
}
$po = Conversion::arrayToDataString($po);
Db::sql('update items_users set data = ? where id = ?', [$po, $id]);
}
public function freeStats2Item(int $id, int $s, int $uid, int $tp): void
{
$itm = Db::getRow('select id, data, so from items_users where id = ? and uid = ? and inShop = 0 and inOdet = 0', [$id, $uid]);
if (!isset($itm['id']) || $itm['so'] <= 0) {
return;
}
$po = Conversion::dataStringToArray($itm['data']);
if ($tp == 1) {
//статы
if ($s == 1 || $s == 2 || $s == 3 || $s == 5) {
if (10 + 25 * $po['add_s' . $s] <= $itm['so']) {
$itm['so'] -= 10 + 25 * $po['add_s' . $s];
$po['add_s' . $s]++;
$this->error = 'Характеристика улучшена...';
} else {
$this->error = 'Не хватает очков развития...';
}
}
} elseif ($tp == 2) {
//мф
if ($s > 0 && $s < 13) {
if ($s == 1) {
$s = 'm1';
} elseif ($s == 2) {
$s = 'm2';
} elseif ($s == 3) {
$s = 'm4';
} elseif ($s == 4) {
$s = 'm5';
} elseif ($s == 5) {
$s = 'mab1';
} elseif ($s == 6) {
$s = 'mab2';
} elseif ($s == 7) {
$s = 'mab3';
} elseif ($s == 8) {
$s = 'mab4';
} elseif ($s == 9) {
$s = 'm10';
} elseif ($s == 10) {
$s = 'za';
} elseif ($s == 11) {
$s = 'm11a';
} elseif ($s == 12) {
$s = 'zm';
}
$s2 = $s == 9 || $s == 12 ? 4 + 4 * $po['add_' . $s] : 5 + 5 * $po['add_' . $s];
if (4 + 4 * $po['add_' . $s] <= $itm['so']) {
$itm['so'] -= $s2;
if ($s == 'mab1') {
$po['add_mib1']++;
} elseif ($s == 'mab2') {
$po['add_mib2']++;
} elseif ($s == 'mab3') {
$po['add_mib3']++;
} elseif ($s == 'mab4') {
$po['add_mib4']++;
}
$po['add_' . $s]++;
} else {
$this->error = 'Не хватает очков развития...';
}
}
}
Db::sql('update items_users set data = ?, so = ? where id = ?', [Conversion::arrayToDataString($po), $itm['so'], $id]);
}
public function obj_addItem(int $id): void
{
$itm = Db::getRow('select id, inGroup, item_id, uid from items_users where uid = ? and inOdet = 0 and inShop = 0 and id = ?', [$this->info['id'], $id]);
if ($this->info['transfers'] < 1) {
$this->error = 'На сегодня лимит передач исчерпан.';
return;
} elseif (!isset($itm['id'])) {
$this->error = 'Предмет не найден в рюкзаке';
return;
}
if ($itm['inGroup'] > 0 && $this->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');
if ($this->info['transfers'] < 1) {
$this->error = 'На сегодня лимит передач исчерпан.';
return;
} elseif (!isset($itm['id'])) {
$this->error = 'Предмет не найден в сундуке';
return;
}
if ($itm['inGroup'] > 0 && $this->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]);
}
}
public function itemsSmSave(int $id, int $s, int $uid): void
{
$itm = Db::getValue('select data from items_users where id = ? and uid = ? and inShop = 0 and inOdet = 0', [$id, $uid]);
if (!$itm) {
return;
}
$po = Conversion::dataStringToArray($itm['data']);
if (isset($po['sudba']) && $po['sudba'] == '0') {
return;
}
if (isset($po['sm_skill']) && $s > 100) {
$mx2 = 1;
$mx1 = 0;
$mx3 = Conversion::dataStringToArray($this->info['stats']);
while ($mx2 <= 7) {
$mx1 += ($mx3['a' . $mx2] + $mx3['mg' . $mx2]) - ($po['add_a' . $mx2] + $po['add_mg' . $mx2]);
$mx2++;
}
$mx1 += $this->info['skills'];
if ($mx1 > 0) {
//умения
$s = $s - 100;
if ($s > 5 && $s <= 12) {
//магия
$po['add_mg' . ($s - 5)]++;
} elseif ($s > 0) {
//оружие
$po['add_a' . $s]++;
}
}
} elseif (isset($po['sm_abil']) && $s < 11 && $s > 0) {
$mx2 = 1;
$mx1 = 0;
$mx3 = Conversion::dataStringToArray($this->info['stats']);
while ($mx2 <= 7) {
$mx1 += $mx3['s' . $mx2] - $po['add_s' . $mx2];
$mx2++;
}
$mx1 += $this->info['ability'];
if ($mx1 > 0) {
$po['add_s' . $s]++;
}
}
Db::sql('update items_users set data = ? where id = ?', [Conversion::arrayToDataString($po), $id]);
}
//Сверяем требования предмета для его использования
public function runeItem($id, $name = 0, $ruid = 0): void
{
if ($id == null) {
if ($ruid < 1 && isset($_GET['use_rune'])) {
$ruid = $_GET['use_rune'];
echo "
<script language='JavaScript'>
var elem = document.getElementById('se-pre-con');
elem.parentNode.removeChild(elem);
</script>
";
}
$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
`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
( (`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
`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
( (`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('"', '&quot;', $name)
) . '%" AND `i`.`uid` = "' . mysql_real_escape_string($this->info['id']) . '"'
);
}
while ($pl = mysql_fetch_array($sp)) {
$vibor .= '<img src="' . Config::img() . '/i/items/' . $pl['img'] . '"><hr>';
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 > 0) {
$itm_inv = $this->genInv(80, ' ' . rtrim($vid, 'OR') . ' ');
echo '<button style="float:right" class="btn" type="button" onclick="top.frames[\'main\'].location=\'main.php?inv=1&otdel=' . floor(
$_GET['otdel']
) . '\'">Вернуться</button><strong>Выберите предмет для использования &quot;' . $rune['name'] . '&quot;:</strong><br><br><table width="100%" border="0" cellspacing="1" align="center" cellpadding="0" bgcolor="#A5A5A5">' . $itm_inv[2] . '</table>';
die();
} else {
unset($rune);
}
if ($id['id'] > 0) {
if ($ruid < 1 && isset($_GET['use_rune'])) {
$ruid = $_GET['use_rune'];
}
$idtrue = false;
$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'
)
);
if ($rune['level'] > $this->info['level'] && $rune['type'] == 31) {
$this->error = 'У вас слишком маленький уровень чтобы использовать эту руну';
} elseif ($rune['type'] == 31) {
//Встраиваем руну
if ($idt['type'] == 7) {
$idt['type'] = 6;
}
if ($idt['type'] == 5) {
$idt['type'] = 6;
}
if ($idt['type'] == 4) {
$idt['type'] = 6;
}
$data = Conversion::dataStringToArray($id['data']);
$type_rune = [
'хи' => 9, //Серьги
'хэ' => 10, //Ожерелье
'ви' => 11, //Кольцо
'во' => 12, //Перчатки
'кэ' => 14, //Поножи
'ки' => 15, //Обувь
'ми' => 1, //Шлем
'си' => 3, //Наручи
'мо' => 6, //Броня
'со' => 8, //Пояс
];
$type_rune = $type_rune[substr($rune['name'], -2, 2)];
if ($type_rune != $id['type'] && $type_rune != '') {
$type_rune2 = [
'хи' => 'серьги', //Серьги
'хэ' => 'ожерелья', //Ожерелье
'ви' => 'кольцо', //Кольцо
'во' => 'перчатки', //Перчатки
'кэ' => 'поножи', //Поножи
'ки' => 'обувь', //Обувь
'ми' => 'шлем', //Шлем
'си' => 'наручи', //Наручи
'мо' => 'броню', //Броня
'со' => 'пояс', //Пояс
];
$this->error = 'Встроить данную руну возможно только в ' . $type_rune2[substr(
$rune['name'], -2, 2
)] . ' (Тип предмета: ' . $id['type'] . '. Требуемый тип: ' . $type_rune . ')';
} elseif (isset($data['nomodif'])) {
$this->error = 'Улучшить данный предмет невозможно';
} elseif (isset($data['art']) && $data['tr_lvl'] < 0) {
$this->error = 'Встраивание усилений в артефакты ниже 10-го уровня недоступно';
} else {
if (isset($data['rune']) && $data['rune'] > 0) {
$ritm = mysql_fetch_array(
mysql_query(
'SELECT * FROM `items_main_data` WHERE `items_id` = "' . $data['rune_id'] . '" LIMIT 1'
)
);
$j = 0;
$data_r = Conversion::dataStringToArray($ritm['data']);
while ($j < count($this->items['add'])) {
if (isset($data_r['add_' . $this->items['add'][$j]])) {
$data['add_' . $this->items['add'][$j]] -= $data_r['add_' . $this->items['add'][$j]];
}
$j++;
}
}
$data['rune'] = $rune['id'];
$data['rune_id'] = $rune['item_id'];
$data['rune_name'] = $rune['name'];
$data['rune_lvl'] = $rune['level'];
//Добавляем характеристики руны
$add = Conversion::dataStringToArray($rune['data']);
$i = 0;
while ($i < count($this->items['add'])) {
if (isset($add['add_' . $this->items['add'][$i]])) {
$data['add_' . $this->items['add'][$i]] += $add['add_' . $this->items['add'][$i]];
}
$i++;
}
$data = Conversion::arrayToDataString($data);
mysql_query(
'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `id` = "' . $rune['id'] . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
mysql_query(
'UPDATE `items_users` SET `data` = "' . $data . '" WHERE `id` = "' . $id['id'] . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
$this->error = 'Встраивание руны прошло успешно';
}
} else {
$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`.`level`,`m`.`type` 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'
)
);
if (!isset($rune['id'])) {
$this->error = 'Усиление которое вы использовали не найдено';
} elseif ($rune['type'] == 62 && $rune['item_id'] == 6167) {
//-----------------------------------------------
$idt = mysql_fetch_array(
mysql_query(
'SELECT `id`,`name`,`img`,`type`,`inslot`,`2h`,`2too`,`iznosMAXi`,`inRazdel`,`price1`,`price2`,`price3`,`magic_chance`,`info`,`massa`,`level`,`magic_inci`,`overTypei`,`group`,`group_max`,`geni`,`ts`,`srok`,`class`,`class_point`,`anti_class`,`anti_class_point`,`max_text`,`useInBattle`,`lbtl`,`lvl_itm`,`lvl_exp`,`lvl_aexp` FROM `items_main` WHERE `id` = "' . $id['item_id'] . '" LIMIT` 1'
)
);
$data = Conversion::dataStringToArray($id['data']);
$add = Conversion::dataStringToArray($rune['data']);
if (isset($data['nomodif'])) {
$this->error = 'Улучшить данный предмет невозможно';
} elseif (isset($data['art']) && $data['tr_lvl'] < 0) {
$this->error = 'Встраивание усилений в артефакты ниже 10-го уровня недоступно';
} else {
if (isset($data['spell']) && $data['spell'] > 0) {
if (isset($data['spell_st_val_hp'])) {
$data['add_hpAll'] -= $data['spell_st_val_hp'];
unset($data['spell_st_val_hp']);
}
if (isset($data['addspell_mpAll'])) {
$data['add_mpAll'] -= $data['addspell_mpAll'];
unset($data['addspell_mpAll']);
}
unset($data['spell']);
if (isset($data['spell_id'])) {
unset($data['spell_id']);
}
if (isset($data['spell_name'])) {
unset($data['spell_name']);
}
if (isset($data['spell_lvl'])) {
unset($data['spell_lvl']);
}
if (isset($data['spell_st_name'])) {
$data['add_' . $data['spell_st_name']] -= $data['spell_st_val'];
if ($data['add_' . $data['spell_st_name']] == 0) {
unset($data['add_' . $data['spell_st_name']]);
}
unset($data['spell_st_name']);
}
if (isset($data['spell_st_val'])) {
unset($data['spell_st_val']);
}
}
//Новая чарка
$srune = mysql_query('SELECT * FROM `new_charov` WHERE 1');
$irun = 0;
while ($nrune = mysql_fetch_array($srune)) {
$irun++;
$ntrune[$irun] = $nrune;
}
if ($irun > 0) {
$addrune = $ntrune[rand(1, $irun)];
$addrunes = rand($addrune['min'], $addrune['max']);
if (isset($data['add_' . $addrune['gname']])) {
$data['add_' . $addrune['gname']] += $addrunes;
} else {
$data['add_' . $addrune['gname']] = $addrunes;
}
}
$data['spell'] = $rune['id'];
if (!isset($data['sudba'])) {
$data['sudba'] = '0';
}
$data['spell_name'] = 'Зачарованно'; //$info
$data['spell_st_name'] = $addrune['gname'];
$data['spell_st_val'] = $addrunes;
$data['spell_id'] = $rune['item_id'];
$data['spell_lvl'] = 8;
//
$data = Conversion::arrayToDataString($data);
unset($srune, $irun, $nrune, $ntrune, $addrune, $addrunes);
$tid = mysql_query(
'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `id` = "' . $rune['id'] . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
mysql_query(
'UPDATE `items_users` SET `data` = "' . $data . '" WHERE `id` = "' . $id['id'] . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
if (isset($tid)) {
$this->error = 'Чарование прошло успешно!';
} else {
$this->error = 'Что то пошло не так!';
}
unset($tid);
}
//-----------------------------------------------
} elseif ($rune['type'] == 62) {
$idt = mysql_fetch_array(
mysql_query(
'SELECT `id`,`name`,`img`,`type`,`inslot`,`2h`,`2too`,`iznosMAXi`,`inRazdel`,`price1`,`price2`,`price3`,`magic_chance`,`info`,`massa`,`level`,`magic_inci`,`overTypei`,`group`,`group_max`,`geni`,`ts`,`srok`,`class`,`class_point`,`anti_class`,`anti_class_point`,`max_text`,`useInBattle`,`lbtl`,`lvl_itm`,`lvl_exp`,`lvl_aexp` FROM `items_main` WHERE `id` = "' . $id['item_id'] . '" LIMIT` 1'
)
);
if ($idt['type'] == 7) {
$idt['type'] = 6;
}
if ($idt['type'] == 5) {
$idt['type'] = 6;
}
if ($idt['type'] == 4) {
$idt['type'] = 6;
}
//$id['type'] = $idt['type'];
//Встраиваем руну
$data = Conversion::dataStringToArray($id['data']);
$add = Conversion::dataStringToArray($rune['data']);
if (isset($data['nomodif'])) {
$this->error = 'Улучшить данный предмет невозможно';
} elseif (isset($data['art']) && $data['tr_lvl'] < 0) {
$this->error = 'Встраивание усилений в артефакты ниже 10-го уровня недоступно';
} elseif (isset($add['onimposed'])) {
//Встраиваем магию
//Новая чарка
$i = 0;
$j = 0;
$utp = explode(',', $add['onItemType']);
while ($i < count($utp)) {
if ($utp[$i] == $id['type']) {
$j++;
}
$i++;
}
if ($j > 0) {
unset($data['imposed'], $data['imposed_name'], $data['bm_a1']);
$imposed = [
'imposed' => 1,
'imposed_name' => $add['onSpellName'],
'bm_a1' => $add['onSpellFile'],
];
if (!isset($add['onSpellFile'])) {
unset($imposed['bm_a1']);
//
if (isset($add['onSpell_mpAll'])) {
$imposed['addspell_mpAll'] = $add['onSpell_mpAll'];
$imposed['add_mpAll'] = $data['add_mpAll'] + $add['onSpell_mpAll'] - $data['addspell_mpAll'];
}
//
}
$imposed['sudba'] = 1;
$data = array_merge($data, $imposed);
$data = Conversion::arrayToDataString($data);
mysql_query(
'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `id` = "' . $rune['id'] . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
mysql_query(
'UPDATE `items_users` SET `data` = "' . $data . '" WHERE `id` = "' . $id['id'] . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
$this->error = 'Наложены чары "' . $add['onSpellName'] . '" на предмет &quot;' . $id['name'] . '&quot;';
} else {
$this->error = 'Предмет &quot;' . $id['name'] . '&quot; не подходит для усиления.,.';
}
} else {
if (isset($data['spell']) && $data['spell'] > 0) {
//Отнимаем эффект от прошлых чарок
$litm = mysql_fetch_array(
mysql_query(
'SELECT * FROM `items_main_data` WHERE `items_id` = "' . $id['item_id'] . '" LIMIT 1'
)
);
$data_l = Conversion::dataStringToArray($litm['data']);
$pvr = [
'i' => 0,
'spell' => [],
'rune' => [],
'atack' => [],
'podgon' => [],
];
if (isset($data['podgon'])) {
if ($data['tr_lvl'] > $id['level']) {
$id['level'] = $data['tr_lvl'];
}
$pvr['podgon']['hpAll'] = 6 * $id['level'] + 6;
}
if (isset($data['addspell_hpAll'])) {
$pvr['podgon']['hpAll'] += $data['addspell_hpAll'];
}
if (isset($data['rune_id']) && $data['rune_id'] > 0) {
$ritm = mysql_fetch_array(
mysql_query(
'SELECT * FROM `items_main_data` WHERE `items_id` = "' . $data['rune_id'] . '" LIMIT 1'
)
);
$j = 0;
$data_r = Conversion::dataStringToArray($ritm['data']);
while ($j < count($this->items['add'])) {
if (isset($data_r['add_' . $this->items['add'][$j]])) {
$pvr['rune'][$this->items['add'][$j]] = $data_r['add_' . $this->items['add'][$j]];
}
$j++;
}
}
if (isset($data['spell_st_val_hp'])) {
$data['add_hpAll'] -= $data['spell_st_val_hp'];
}
//$i = 0;
//while( $i < count($data)) {
if (!isset($data['spell_st_name'])) {
$delk = count($this->items['add']);
$this->items['add'][] = 'mib1';
$this->items['add'][] = 'mib2';
$this->items['add'][] = 'mib3';
$this->items['add'][] = 'mib4';
$this->items['add'][] = 'mab1';
$this->items['add'][] = 'mab2';
$this->items['add'][] = 'mab3';
$this->items['add'][] = 'mab4';
$j = 0;
while ($j < count($this->items['add'])) {
if (isset($data['add_' . $this->items['add'][$j]])) {
if ($data_l['add_' . $this->items['add'][$j]] != $data['add_' . $this->items['add'][$j]] - $pvr['rune'][$this->items['add'][$j]] - $pvr['podgon'][$this->items['add'][$j]]) {
//echo ''.$this->items['add'][$j].' -> '.$data_l['add_'.$this->items['add'][$j]].' / '.$data['add_'.$this->items['add'][$j]].'<br>';
if (!isset($data_l['add_' . $this->items['add'][$j]])) {
unset($data['add_' . $this->items['add'][$j]]);
} else {
$data['add_' . $this->items['add'][$j]] = $data_l['add_' . $this->items['add'][$j]];
}
}
}
$j++;
}
$i = 0;
while ($i < 8) {
unset($this->items['add'][$delk + $i]);
$i++;
}
}
}
//Новая чарка
$i = 0;
$utp = explode(',', $add['onItemType']);
while ($i < count($utp)) {
if ($utp[$i] == $id['type']) {
// Определили нужный тип оружия.
$itm_twohand = mysql_fetch_array(
mysql_query(
'SELECT `2h` FROM `items_main` WHERE `id` = "' . $id['item_id'] . '" LIMIT 1'
)
);
if (isset($itm_twohand['2h']) && $itm_twohand['2h'] == 1) {
$tw = '2';
} else {
$tw = '';
}
$j = 0;
while ($j < count($this->items['add'])) {
if (isset($add[$tw . 'add' . $utp[$i] . '_' . $this->items['add'][$j]])) {
$rnda[count($rnda)] = $this->items['add'][$j];
}
$j++;
}
if (isset($add['imposed']) && $add['imposed'] != '') {
$imposed = [
'imposed' => '1', // Активно
'imposed_id' => $rune['id'], // ID чарки свитка
'imposed_name' => $rune['name'], // Наименование чар, которое отображается на предмете
'imposed_level' => $rune['level'], // Цвет подсветки заклинания при отображении. По умолчанию: 0;
'bm_a1' => $add['imposed'], // Имя файла заклинания.
'sudba' => $this->info['login'], // Цвет подсветки заклинания при отображении. По умолчанию: 0;
];
if (isset($add['imposed_name'])) {
$imposed['imposed_name'] = $add['imposed_name'];
}
if (isset($add['imposed_level'])) {
$imposed['imposed_level'] = $add['imposed_level'];
}
$rnda[0] = 1;
}
if (count($rnda) >= 0) {
$rnda = $rnda[rand(0, count($rnda) - 1)];
if ($rnda == 'mib1' || $rnda == 'mib2' || $rnda == 'mib3' || $rnda == 'mib4') {
$rnda = str_replace('mib', 'mab', $rnda);
}
if (!isset($this->is[$rnda]) && isset($imposed)) {
$data = array_merge($data, $imposed);
$data = Conversion::arrayToDataString($data);
mysql_query(
'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `id` = "' . $rune['id'] . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
mysql_query(
'UPDATE `items_users` SET `data` = "' . $data . '" WHERE `id` = "' . $id['id'] . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
$this->error = 'Наложены чары "' . $imposed['imposed_name'] . '" на предмет &quot;' . $id['name'] . '&quot;';
} elseif (!isset($this->is[$rnda])
&& $rnda != 'mib1' && $rnda != 'mib2' && $rnda != 'mib3' && $rnda != 'mib4'
&& $rnda != 'mab1' && $rnda != 'mab2' && $rnda != 'mab3' && $rnda != 'mab4'
) {
$this->error = 'Попробуйте зачарить предмет снова. ( ' . $rnda . ' )';
} else {
$data['add_' . $rnda] += $add[$tw . 'add' . $utp[$i] . '_' . $rnda];
if ($rnda == 'mab1' || $rnda == 'mab2' || $rnda == 'mab3' || $rnda == 'mab4') {
$data['add_' . str_replace(
'mab', 'mib', $rnda
)] += $add[$tw . 'add' . $utp[$i] . '_' . $rnda];
}
$data['spell'] = $rune['id'];
if (!isset($data['sudba'])) {
$data['sudba'] = '0';
}
if (isset($data['spell_st_name'])) {
$data['add_' . $data['spell_st_name']] -= $data['spell_st_val'];
if ($data['spell_st_name'] == 'mab1' || $data['spell_st_name'] == 'mab2' || $data['spell_st_name'] == 'mab3' || $data['spell_st_name'] == 'mab4') {
$data['add_' . str_replace(
'mab', 'mib', $data['spell_st_name']
)] -= $data['spell_st_val'];
}
if ($data['add_' . $data['spell_st_name']] == 0) {
unset($data['add_' . $data['spell_st_name']]);
}
}
$data['spell_id'] = $rune['item_id'];
$data['spell_name'] = $rune['name'];
$data['spell_lvl'] = $rune['level'];
$data['spell_st_name'] = $rnda;
$data['spell_st_val'] = $add[$tw . 'add' . $utp[$i] . '_' . $rnda];
if (isset($add['addspell_hpAll'])) {
$data['spell_st_val_hp'] = $add['addspell_hpAll'];
$data['add_hpAll'] += $add['addspell_hpAll'];
} else {
unset($data['spell_st_val_hp']);
}
$data = Conversion::arrayToDataString($data);
$this->is['mab1'] = 'Броня головы';
$this->is['mab2'] = 'Броня корпуса';
$this->is['mab3'] = 'Броня пояса';
$this->is['mab4'] = 'Броня ног';
$this->error = 'Увеличина характеристика предмета &quot;' . $id['name'] . '&quot;, ' . $this->is[$rnda] . ': +' . $add[$tw . 'add' . $utp[$i] . '_' . $rnda];
unset($this->is['mab1'], $this->is['mab2'], $this->is['mab3'], $this->is['mab4']);
mysql_query(
'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `id` = "' . $rune['id'] . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
mysql_query(
'UPDATE `items_users` SET `data` = "' . $data . '" WHERE `id` = "' . $id['id'] . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
}
} else {
$this->error = 'Что-то не так, невозможно зачаровать данным свитком';
}
$i = 100499;
}
$i++;
}
if ($i < 100500) {
$this->error = 'Данный предмет не подходит для зачарования...';
}
}
} elseif ($rune['type'] == 47) {
$add = Conversion::dataStringToArray($id['data']);
$data = Conversion::dataStringToArray($rune['data']);
if ($add['art'] == 1) {
if ($id['iznosNOW'] > 0) {
$id['iznosNOW'] -= $data['repairLevel'];
if ($id['iznosNOW'] < 0) {
$id['iznosNOW'] = 0;
}
mysql_query(
'UPDATE `items_users` SET `iznosNOW` = "' . $id['iznosNOW'] . '" WHERE `id` = "' . $id['id'] . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
mysql_query(
'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `id` = "' . $rune['id'] . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
$this->error = 'Предмет ' . $id['name'] . ' успешно отремонтирован.';
} else {
$this->error = 'Предмет не нуждаеться в ремонте...';
}
} else {
$this->error = 'Свиток ремонтирует только артефакты...';
}
} elseif ($rune['type'] == 46) {
$idt = mysql_fetch_array(
mysql_query(
'SELECT `id`,`name`,`img`,`type`,`inslot`,`2h`,`2too`,`iznosMAXi`,`inRazdel`,`price1`,`price2`,`price3`,`magic_chance`,`info`,`massa`,`level`,`magic_inci`,`overTypei`,`group`,`group_max`,`geni`,`ts`,`srok`,`class`,`class_point`,`anti_class`,`anti_class_point`,`max_text`,`useInBattle`,`lbtl`,`lvl_itm`,`lvl_exp`,`lvl_aexp` FROM `items_main` WHERE `id` = ' . $id['item_id']
)
);
if ($idt['type'] == 5) {
$idt['type'] = 6;
}
$id['type'] = $idt['type'];
if ($id_type < 18 || $id_type > 24) {
$add = Conversion::dataStringToArray($rune['data']);
if (isset($add['uptimeitem'])) {
$data = Conversion::dataStringToArray($id['data']);
if ($data['srok'] > 0 || $id['srok'] > 0) {
if (!isset($data['srok'])) {
$data['srok'] = $id['srok'];
}
if ($data['srok'] + $id['time_create'] - time() > 86400 + 30) {
$this->error = 'Нельзя использовать на предметы с сроком годности 30 и более дней.';
} elseif ($id['inslot'] > 0 && $id['inslot'] < 20) {
$this->error = 'Срок годности предмета &quot;' . $id['name'] . '&quot; продлен на ' . $this->timeOut(
$add['uptimeitem']
) . '.';
if (isset($data['sleep_moroz'])) {
unset($data['sleep_moroz']);
}
$data = Conversion::arrayToDataString($data);
mysql_query(
'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `id` = "' . $rune['id'] . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
mysql_query(
'UPDATE `items_users` SET `data` = "' . $data . '",`time_create` = `time_create` + ' . floor(
$add['uptimeitem']
) . ' WHERE `id` = "' . $id['id'] . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
} else {
$this->error = 'Предмет данного типа нельзя продлить...';
}
} else {
$this->error = 'Это работает только на предметы с сроком годности...';
}
} else {
$this->error = 'Затачивать можно только оружие...';
}
} else {
//Заточка
$data = Conversion::dataStringToArray($id['data']);
$add = Conversion::dataStringToArray($rune['data']);
if (isset($data['upatack_id'])) {
$this->error = 'Предмет уже заточен, вытащите заточку в Ремонтной мастерской.';
} elseif (isset($data['nomodif'])) {
$this->error = 'Улучшить данный предмет невозможно';
} elseif ($add['uptype'] != $id_type || $add['uptype'] == 0) {
$this->error = 'Заточка не подходит к данному предмету...';
} else {
if (isset($data['upatack_id']) && $data['upatack_id'] > 0) {
$ritm = mysql_fetch_array(
mysql_query(
'SELECT * FROM `items_main_data` WHERE `items_id` = "' . $data['upatack_id'] . '" LIMIT 1'
)
);
$data_r = Conversion::dataStringToArray($ritm['data']);
if ($id_type == 22) {
$data['add_m11'] -= $data_r['upatack']; //*2
}
$data['sv_yron_min'] -= $data_r['upatack'];
$data['sv_yron_max'] -= $data_r['upatack'];
}
$data['upatack'] = $rune['id'];
$data['upatack_id'] = $rune['item_id'];
$data['upatack_name'] = $rune['name'];
$data['upatack_lvl'] = $add['upatack'];
$data['upatack_lvl'] = $add['upatack'];
//Добавляем характеристики руны
$i = 0;
while ($i < count($this->items['add'])) {
if (isset($add['add_' . $this->items['add'][$i]])) {
$data['add_' . $this->items['add'][$i]] += $add['add_' . $this->items['add'][$i]];
}
$i++;
}
$data['sv_yron_min'] += $add['upatack'];
$data['sv_yron_max'] += $add['upatack'];
Delo::add(
2,
'System.remont.upatack',
$this->info['id'],
'&quot;<span style="color: #4863A0; ">System.remont.upatack</span>&quot;: Заточка &quot;' . $data['upatack_name'] . '&quot; была успешно <strong>встроена</strong> в предмет &quot;' . $id['name'] . '&quot; [itm:' . $id['id'] . ']',
);
$data = Conversion::arrayToDataString($data);
mysql_query(
'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `id` = "' . $rune['id'] . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
mysql_query(
'UPDATE `items_users` SET `1price` = "' . $id['1price'] . '",`2price` = "' . $id['2price'] . '",`data` = "' . $data . '" WHERE `id` = "' . $id['id'] . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
$this->error = 'Заточка &quot;' . $id['name'] . '&quot; прошла успешно';
}
}
} elseif ($rune['type'] == 48) {
//Профиль
$data = Conversion::dataStringToArray($id['data']);
$add = Conversion::dataStringToArray($rune['data']);
if ($data['tya1'] >= 90 || $data['tya2'] >= 90 || $data['tya3'] >= 90 || $data['tya4'] >= 90) {
$this->error = 'Предмет уже имеет 90 своего профиля';
} elseif (isset($data['nomodif'])) {
$this->error = 'Улучшить данный предмет невозможно';
} elseif ($add['uptype'] != $id_type || $add['uptype'] == 0) {
$this->error = 'Заточка не подходит к данному предмету...';
} else {
if ($add['tya1'] == 1) {
$data['tya1'] += $add['tya1'];
if ($data['tya3'] > 10) {
$data['tya3'] -= $add['tya1'];
}
} elseif ($add['tya2'] == 1) {
$data['tya2'] += $add['tya2'];
if ($data['tya4'] > 10) {
$data['tya4'] -= $add['tya2'];
}
} elseif ($add['tya3'] == 1) {
$data['tya3'] += $add['tya3'];
if ($data['tya1'] > 10) {
$data['tya1'] -= $add['tya3'];
}
} elseif ($add['tya4'] == 1) {
$data['tya4'] += $add['tya4'];
if ($data['tya2'] > 10) {
$data['tya2'] -= $add['tya4'];
}
}
Delo::add(
2,
'System.remont.upatack',
$u->info['id'],
'&quot;<span style="color: #4863A0; ">System.remont.upatack</span>&quot;: Заточка &quot;' . $data['upatack_name'] . '&quot; была успешно <strong>встроена</strong> в предмет &quot;' . $id['name'] . '&quot; [itm:' . $id['id'] . ']',
);
$this->error = 'Заточка &quot;' . $id['name'] . '&quot; прошла успешно! Колка:' . $data['tya1'] . ' Руб:' . $data['tya2'] . ' Дробь:' . $data['tya3'] . ' Реж:' . $data['tya4'] . ' ';
$data = Conversion::arrayToDataString($data);
mysql_query(
'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `id` = "' . $rune['id'] . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
mysql_query(
'UPDATE `items_users` SET `1price` = "' . $id['1price'] . '",`2price` = "' . $id['2price'] . '",`data` = "' . $data . '" WHERE `id` = "' . $id['id'] . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
}
} elseif ($rune['type'] == 50) {
//Страничка саныча
if ($id['item_id'] == 3196 || $id['item_id'] == 3197 || $id['item_id'] == 3198) {
if ($id['iznosNOW'] > 0) {
$id['iznosNOW']--;
$this->error = 'Восстановление &quot;' . $id['name'] . '&quot; прошла успешно! [' . round(
$id['iznosNOW']
) . '/' . round($id['iznosMAX']) . ']';
mysql_query(
'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `id` = "' . $rune['id'] . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
mysql_query(
'UPDATE `items_users` SET `iznosNOW` = "' . $id['iznosNOW'] . '" WHERE `id` = "' . $id['id'] . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
} else {
$this->error = 'Предмет &quot;' . $id['name'] . '&quot; имеет макисмальное значение прочности! [' . round(
$id['iznosNOW']
) . '/' . round($id['iznosMAX']) . ']';
}
} else {
$this->error = 'Данный предмет не подходит для восстановления!!';
}
} elseif ($rune['type'] == 68) {
$idt = mysql_fetch_array(
mysql_query(
'SELECT `id`,`name`,`img`,`type`,`inslot`,`2h`,`2too`,`iznosMAXi`,`inRazdel`,`price1`,`price2`,`price3`,`magic_chance`,`info`,`massa`,`level`,`magic_inci`,`overTypei`,`group`,`group_max`,`geni`,`ts`,`srok`,`class`,`class_point`,`anti_class`,`anti_class_point`,`max_text`,`useInBattle`,`lbtl`,`lvl_itm`,`lvl_exp`,`lvl_aexp` FROM `items_main` WHERE `id` = "' . $id['item_id'] . '" LIMIT` 1'
)
);
if ($idt['type'] == 5) {
$idt['type'] = 6;
}
$id['type'] = $idt['type'];
//Встраиваем руну
$data = Conversion::dataStringToArray($id['data']);
$add = Conversion::dataStringToArray($rune['data']);
if (isset($data['nomodif'])) {
$this->error = 'Улучшить данный предмет невозможно';
} elseif (!isset($data['close']) && $data['close'] != 0) {
$this->error = 'Не подходит к данному предмету, он не закрыт...';
} else {
$data['unopen'] = $rune['id'];
$data['unopen_id'] = $rune['item_id'];
$data['unopen_name'] = $rune['name'];
unset($data['close']);
$data['open'] = 1;
$data = Conversion::arrayToDataString($data);
mysql_query(
'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `id` = "' . $rune['id'] . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
mysql_query(
'UPDATE `items_users` SET `data` = "' . $data . '" WHERE `id` = "' . $id['id'] . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
$this->error = 'Открытие &quot;' . $id['name'] . '&quot; прошло успешно';
}
} elseif ($rune['type'] == 37) {
$idt = mysql_fetch_array(
mysql_query('SELECT * FROM `items_main` WHERE `id` = "' . $id['item_id'] . '" LIMIT 1')
);
if ($idt['type'] != 37) {
//
$data = Conversion::dataStringToArray($id['data']);
$add = Conversion::dataStringToArray($rune['data']);
//
if ($id['gift'] == '' || $id['gift'] == '0') {
if (isset($data['notransfer'])) {
$this->error = 'Предмет нельзя передавать...';
} elseif (isset($data['sudba']) && $data['sudba'] != 0) {
$this->error = 'Предмет связан общей судьбой...';
} else {
if (isset($add['item_inbox']) && $add['item_inbox'] > 0) {
$this->error = 'В упаковке уже что-то есть, осталось сделать подарок!';
} elseif ($id['inTransfer'] > 0 || $id['inShop'] > 0 || $id['inGroup'] > 0) {
$this->error = 'Нельзя передать этот предмет, он в передаче, на прилавке или в группе...';
} else {
//Закидываем предмет в упаковку
$add['item_inbox'] = $id['id'];
$add['open'] = 1;
$add['nosale'] = 1;
$add = Conversion::arrayToDataString($add);
//
mysql_query(
'UPDATE `items_users` SET `inGroup` = 0,`data` = "' . $add . '" WHERE `id` = "' . $rune['id'] . '" LIMIT 1'
);
mysql_query(
'UPDATE `items_users` SET `uid` = -1 WHERE `id` = "' . $id['id'] . '" LIMIT 1'
);
//
$this->error = 'Предмет &quot;' . $idt['name'] . '&quot; упакован в коробку.';
//
}
}
} else {
$this->error = 'Даренное не дарят...';
}
//
} else {
$this->error = 'Вы не сможете упаковать упаковку...';
}
} else {
$this->error = '(' . $rune['type'] . ') Усиление которое вы использовали не найдено...';
}
}
} else {
$this->error = 'Подходящего предмета не нашлось...';
}
}
public function genInv($type, $sort): array
{
global $code;
$i = 0; // счетчик, просто обнуняем.
$j = 0; // Всего предметов while ++
$k = 1; // 0 или 1
$rt = [0 => 0, 1 => 0, 2 => '']; // Количество? Непонятно
$clr = [0 => 'c8c8c8', 1 => 'd4d4d4']; // Цвет фона для предметов
$sort = explode('ORDER BY', $sort);
$where = $sort[0];
$sort = isset($sort[0], $sort[1]) ? ($sort[1] != '' ? $sort[1] : '') : ' `lastUPD` DESC';
$cl = mysql_query(
'SELECT count(`iu`.item_id) as inGroupCount, `im`.`id`,
`im`.`name`,
`im`.`img`,
`im`.`type`,
`im`.`inslot`,
`im`.`2h`,
`im`.`2too`,
`im`.`iznosMAXi`,
`im`.`inRazdel`,
`im`.`price1`,
`im`.`price2`,
`im`.`pricerep`,
`im`.`magic_chance`,
`im`.`info`,
`im`.`massa`,
`im`.`level`,
`im`.`magic_inci`,
`im`.`overTypei`,
`im`.`group`,
`im`.`group_max`,
`im`.`geni`,
`im`.`ts`,
`im`.`srok`,
`im`.`class`,
`im`.`class_point`,
`im`.`anti_class`,
`im`.`anti_class_point`,
`im`.`max_text`,
`im`.`useInBattle`,
`im`.`lbtl`,
`im`.`lvl_itm`,
`im`.`lvl_exp`,
`im`.`lvl_aexp`,
`iu`.`so`,
`iu`.`id`,
`iu`.`item_id`,
`iu`.`1price`,
`iu`.`2price`,
`iu`.`uid`,
`iu`.`use_text`,
`iu`.`data`,
`iu`.`inOdet`,
`iu`.`inShop`,
`iu`.`delete`,
`iu`.`iznosNOW`,
`iu`.`iznosMAX`,
`iu`.`gift`,
`iu`.`gtxt1`,
`iu`.`gtxt2`,
`iu`.`kolvo`,
`iu`.`geniration`,
`iu`.`magic_inc`,
`iu`.`maidin`,
`iu`.`lastUPD`,
`iu`.`timeOver`,
`iu`.`overType`,
`iu`.`secret_id`,
`iu`.`time_create`,
`iu`.`time_sleep`,
`iu`.`inGroup`,
`iu`.`dn_delete`,
`iu`.`inTransfer`,
`iu`.`post_delivery`,
`iu`.`lbtl_`,
`iu`.`bexp`,
`iu`.`so`,
`iu`.`blvl` FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON (`im`.`id` = `iu`.`item_id`) WHERE ' . $where . ' GROUP BY `im`.id,
`iu`.item_id, `iu`.inGroup HAVING `iu`.inGroup > 0 UNION ALL SELECT count(`iu`.item_id) as inGroupCount, `im`.`id`,
`im`.`name`,
`im`.`img`, `im`.`type`,
`im`.`inslot`,
`im`.`2h`,
`im`.`2too`, `im`.`iznosMAXi`,
`im`.`inRazdel`, `im`.`price1`,
`im`.`price2`, `im`.`pricerep`,
`im`.`magic_chance`, `im`.`info`,
`im`.`massa`,
`im`.`level`,
`im`.`magic_inci`, `im`.`overTypei`,
`im`.`group`,
`im`.`group_max`,
`im`.`geni`, `im`.`ts`,
`im`.`srok`,
`im`.`class`, `im`.`class_point`,
`im`.`anti_class`, `im`.`anti_class_point`,
`im`.`max_text`,
`im`.`useInBattle`,
`im`.`lbtl`, `im`.`lvl_itm`,
`im`.`lvl_exp`,
`im`.`lvl_aexp`,
`iu`.`so`,
`iu`.`id`,
`iu`.`item_id`, `iu`.`1price`,
`iu`.`2price`,
`iu`.`uid`, `iu`.`use_text`,
`iu`.`data`,
`iu`.`inOdet`, `iu`.`inShop`,
`iu`.`delete`,
`iu`.`iznosNOW`,
`iu`.`iznosMAX`, `iu`.`gift`,
`iu`.`gtxt1`,
`iu`.`gtxt2`,
`iu`.`kolvo`,
`iu`.`geniration`, `iu`.`magic_inc`, `iu`.`maidin`,
`iu`.`lastUPD`, `iu`.`timeOver`, `iu`.`overType`, `iu`.`secret_id`, `iu`.`time_create`, `iu`.`time_sleep`,
`iu`.`inGroup`,
`iu`.`dn_delete`,
`iu`.`inTransfer`, `iu`.`post_delivery`,
`iu`.`lbtl_`,
`iu`.`bexp`,
`iu`.`so`,
`iu`.`blvl` FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON (`im`.`id` = `iu`.`item_id`) WHERE `iu`.inGroup=0 AND ' . $where . ' GROUP BY `iu`.id, `iu`.item_id ORDER BY ' . $sort . '
'
);
if ($type == 15) {
$anm = mysql_fetch_array(
mysql_query(
'SELECT `id`,`type`,`name`,`uid`,`delete`,`inBattle`,`eda`,`exp`,`obraz`,`stats`,`level`,`sex`,`levelUp`,`pet_in_cage`,`max_exp`,`priems`,`bonus` FROM `users_animal` WHERE `id` = "' . $this->info['animal'] . '" AND `pet_in_cage` = 0 AND `delete` = "0" LIMIT 1'
)
);
}
while ($pl = mysql_fetch_array($cl)) {
if ($type == 30) {
$ChSudba = Conversion::dataStringToArray($pl['data']);
if (isset($ChSudba['sudba']) || $ChSudba['sudba'] != 0 || $ChSudba['nosale'] == 1) {
continue;
}
}
if ($pl['1price'] > 0) {
$pl['price1'] = $pl['1price'];
}
$is1 = '';
$is2 = '';
$d = [];
//тест
$d[0] = 0;
$d[1] = 1;
$d[2] = 0;
$po = Conversion::dataStringToArray($pl['data']);
$see1 = 1;
if ($type == 15) { //кормушка зверя
if ($anm['type'] == 3 && substr_count($pl['img'], 'wisp') == 0) {
$see1 = 0; //светляк
} elseif ($anm['type'] == 2 && substr_count($pl['img'], 'owl') == 0) {
$see1 = 0; //сова
} elseif ($anm['type'] == 1 && substr_count($pl['img'], 'cat') == 0) {
$see1 = 0; //кот
} elseif ($anm['type'] == 4 && substr_count($pl['img'], 'chrt') == 0) {
$see1 = 0; //чертяка
} elseif ($anm['type'] == 5 && substr_count($pl['img'], 'dog') == 0) {
$see1 = 0; //собака
} elseif ($anm['type'] == 6 && substr_count($pl['img'], 'pig') == 0) {
$see1 = 0; //свинья
} elseif ($anm['type'] == 7 && substr_count($pl['img'], 'dragon') == 0) {
$see1 = 0; //дракон
}
} elseif (isset($po['nosale']) && $type == 2) {
$see1 = 0;
} elseif (isset($po['noremont']) && $type == 4) {
$see1 = 0;
} elseif ($type == 5 && $pl['gift'] != '') {
$see1 = 0;
} elseif (($type == 9 || $type == 10) && $pl['gift'] == '') {
$see1 = 0;
} elseif ($type == 5 && isset($po['sudba']) && $po['sudba'] != '0') {
$see1 = 0;
} elseif ($type == 5 && $pl['inTransfer'] > 0) {
$see1 = 0;
} elseif ($type == 6 && !isset($po['fshop'])) {
$see1 = 0;
} elseif ($type == 67 && isset($po['art'])) {
$see1 = 0;
} elseif ($type == 67 && isset($po['sudba'])) {
$see1 = 0;
} elseif ($type == 67 && $pl['gift'] != '') {
$see1 = 0;
} elseif ($type == 11) { // Храм Знаний (плавка предметов)
if (
$pl['inTransfer'] > 0 ||
(!empty($po['sudba']) && $po['sudba'] != $this->info['login']) ||
!in_array($pl['type'], [1, 3, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 18, 19, 20, 21, 22, 72, 1035]) ||
($po['tr_lvl'] < 4 && $pl['item_id'] != 1035)
) {
$see1 = 0;
}
} elseif ($type == 14) { // Храм Знаний (плавка рун)
if ($pl['inTransfer'] > 0 || !in_array($pl['type'], [31, 6001, 6002, 6003])) {
$see1 = 0;
}
} elseif ($type == 12) {
if ($pl['inslot'] != 3 && $pl['inslot'] != 14 && $pl['type'] != 31) {
$see1 = 0;
}
if (!isset($po['frompisher']) && $pl['type'] != 31) {
$see1 = 0;
}
} elseif ($type == 56 && ($pl['inslot'] != 5 || isset($po['podgon']))) {
$see1 = 0;
} elseif (isset($po['musor']) && $po['musor'] > 0 && $pl['iznosNOW'] >= $pl['iznosMAX']) {
$see1 = 0;
} elseif ($type == 57) {
//Подгонка
if ($pl['type'] < 18 || $pl['type'] > 28 || $pl['type'] == 25) {
$see1 = 0;
}
} elseif ($type == 58) {
//Вытаскивание рун
if (!isset($po['rune_id'])) {
$see1 = 0;
}
} elseif ($type == 65) {
if (isset($po['sudba']) && $po['sudba'] != '0') {
$see1 = 0;
}
if (isset($po['toclan'])) {
$po['toclan1'] = explode('#', $po['toclan']);
$po['toclan1'] = $po['toclan1'][0];
if ($po['toclan1'] != $this->info['clan']) {
$see1 = 0;
}
}
} elseif ($type == 67) {
$po['toclan1'] = explode('#', $po['toclan']);
$po['toclan1'] = $po['toclan1'][0];
if ($po['toclan1'] > 0) {
$see1 = 0;
}
if ($po['frompisher'] > 0) {
$see1 = 0;
}
if ($pl['gift'] > 0) {
$see1 = 0;
}
if ($po['sudba'] > 0) {
$see1 = 0;
}
} elseif ($type == 69) {
$po['toclan1'] = explode('#', $po['toclan']);
$po['toclan1'] = $po['toclan1'][0];
if ($po['toclan1'] > 0) {
$see1 = 0;
}
if ($po['frompisher'] == 0) {
$see1 = 0;
}
if ($pl['gift'] > 0) {
$see1 = 0;
}
}
if ($see1 == 1) {
if ($k == 1) {
$k = 0;
} else {
$k = 1;
}
if (($pl['type'] >= 18 && $pl['type'] <= 24) || $pl['type'] == 26 || $pl['type'] == 27) { //Зоны блока +
if (!isset($po['zonb'])) {
$po['zonb'] = 0;
}
$po['zonb']++;
}
//правая часть
$mx = '';
if (isset($po['upatack_lvl'])) {
$mx .= ' +' . $po['upatack_lvl'];
}
if (isset($po['modif'])) {
$mx .= ' (мф)';
}
$col = $this->itemsX($pl['id']);
if ($col > 1 && $pl['inGroup'] != 0) {
$pl['kolvo'] = $col;
$mx .= ' (x' . $col . ')';
}
if (isset($po['tr_align']) && !isset($po['tr_align_bs'])) {
$pl['name'] .= '<img width=12 height=15 src=' . Config::img() . '/i/align/align' . $po['tr_align'] . '.gif >';
} elseif (isset($po['tr_align_bs'])) {
if ($po['tr_align_bs'] == '1') {
$pl['name'] .= '<img width=12 height=15 src=' . Config::img() . '/i/align/align1.75.gif >';
} elseif ($po['tr_align_bs'] == '3') {
$pl['name'] .= '<img width=12 height=15 src=' . Config::img() . '/i/align/align3.01.gif >';
}
}
if (isset($po['renameadd']) && $po['renameadd'] != '') {
$pl['name'] .= ' (<small>Предмет: ' . $po['renameadd'] . '</small>)';
}
if (isset($po['icos'])) {
$pl['name'] = '<span class=icos_' . $po['icos'] . ' >' . $pl['name'] . ' <span><small>&nbsp;' . $po['icos'] . '&nbsp;</small></span></span>';
}
$is2 = '<a oncontextmenu="top.addTo(\'' . $pl['id'] . '\',\'item\'); return false;" class="inv_name" href="/item/' . $pl['item_id'] . '" target="_blank">' . $pl['name'] . '' . $mx . '</a>';
$is2 .= '&nbsp;&nbsp;';
if ($pl['massa'] > 0) {
$is2 .= ' (Масса: ' . ($pl['massa'] * $col) . ')';
}
if ($pl['gift'] != '') {
$ttl = '';
if ($pl['gift'] == 1) {
$ttl = 'Вы не можете передать этот предмет кому-либо';
} else {
$ttl = 'Этот предмет вам подарил ' . $pl['gift'] . '. Вы не сможете передать этот предмет кому-либо еще';
}
$is2 .= ' <img title="' . $ttl . '" src="' . Config::img() . '/i/podarok.gif">';
}
if (isset($po['art'])) {
$is2 .= ' <img title="Артефакт" src="' . Config::img() . '/i/artefact.gif">';
}
if (isset($po['sudba'])) {
if ($po['sudba'] == '0') {
$is2 .= ' <img title="Этот предмет будет связан общей судьбой с первым, кто наденет его. Никто другой не сможет его использовать." src="' . Config::img() . '/i/destiny0.gif">';
} elseif ($po['sudba'] == '1') {
$is2 .= ' <img title="Этот предмет будет связан общей судьбой с первым, кто возьмет предмет. Никто другой не сможет его использовать." src="' . Config::img() . '/i/destiny0.gif">';
} else {
$is2 .= ' <img title="Этот предмет связан общей судьбой с ' . $po['sudba'] . '. Никто другой не сможет его использовать." src="' . Config::img() . '/i/desteny.gif">';
}
}
if ($pl['price1'] > 0) { //цена
$pex = explode('.', $pl['price1']);
if ($pex[1] == '00') {
$pl['price1'] = $pex[0];
}
if ($_GET['toRent'] == 2) {
$is2 .= '<br><strong>Цена: ' . ($pl['price1']) . ' кр.</strong>';
} else {
$is2 .= '<br><strong>Цена: ' . ($pl['price1'] * $col) . ' кр.</strong>';
}
}
if ($pl['pricerep'] > 0) {
$is2 .= ' <small><strong>(' . round(
$pl['pricerep'] * $col, 2
) . ' Воинственности)</strong></small>';
}
if ($pl['iznosMAX'] > 0) { //долговечность
$izcol = '';
if (floor($pl['iznosNOW']) >= (floor($pl['iznosMAX']) - ceil($pl['iznosMAX']) / 100 * 20)) {
$izcol = 'brown';
}
if ($pl['iznosMAXi'] == 999999999) {
$is2 .= '<br>Долговечность: <font color="brown">неразрушимо</font >';
} else {
$is2 .= '<br>Долговечность: <font color="' . $izcol . '">' . floor(
$pl['iznosNOW']
) . '/' . ceil($pl['iznosMAX']) . '</font>';
}
}
if ($po['battleUseZd'] > 0) {
$is2 .= '<br>Задержка использования: ' . $this->timeOut($po['battleUseZd']) . '';
}
if (isset($po['srok']) && $po['srok'] > 0) {
$pl['srok'] = $po['srok'];
}
if ($pl['srok'] > 0) { //Срок годности предмета
$is2 .= '<br>Срок годности: ' . $this->timeOut($pl['srok']) . ' (до ' . date(
'd.m.Y H:i', $pl['time_create'] + $pl['srok']
) . ')';
}
if ($pl['magic_chance'] > 0) {
$is2 .= '<br>Вероятность срабатывания: ' . min([$pl['magic_chance'], 100]) . '%';
}
if ((int)$pl['magic_inci'] > 0) { //Продолжительность действия магии:
$efi = mysql_fetch_array(
mysql_query(
'SELECT `id2`,`mname`,`type1`,`img`,`mdata`,`actionTime`,`type2`,`type3`,`onlyOne`,`oneType`,`noAce`,`see`,`info`,`overch`,`bp`,`noch` FROM `eff_main` WHERE `id2` = "' . ((int)$pl['magic_inci']) . '" LIMIT 1'
)
);
if (isset($efi['id2']) && $efi['actionTime'] > 0) {
$is2 .= '<br>Продолжительность действия: ' . $this->timeOut($efi['actionTime']);
}
}
$notr = 0;
if (isset($po['sudba']) && $po['sudba'] != '0' && $po['sudba'] != $this->info['login']) {
$notr++;
}
$tr = '';
$t = $this->items['tr'];
$x = 0;
while ($x < count($t)) {
$n = $t[$x];
if (isset($po['tr_' . $n]) && $po['tr_' . $n] != 0) {
if ($n == 'sex') {
if ($this->info['sex'] != $po['tr_' . $n]) {
$tr .= '<font color="red">';
$notr++;
}
} elseif ($po['tr_' . $n] > $this->stats[$n]) {
if ($n == 'align_bs' && $this->info['inTurnir'] > 0) {
if ($po['tr_align_bs'] == '1') {
$pal = !($this->info['align_real'] <= 1 || $this->info['align_real'] >= 2);
} elseif ($po['tr_align_bs'] == '3') {
$tar = !($this->info['align_real'] <= 3 || $this->info['align_real'] >= 4);
}
}
if ($n == 'rep') {
$temp = explode('::', $po['tr_' . $n]);
if ($this->rep['rep' . $temp[1]] < $temp[0]) {
$tr .= '<font color="red">';
$notr++;
}
unset($temp);
} elseif ($n == 'align_bs' && $this->info['inTurnir'] > 0 && ($pal = false || $tar = false)) {
$tr .= '<font color="red">';
$notr++;
} elseif ($n != 'align' && $n != 'align_bs' || floor(
$this->info['align']
) != $po['tr_' . $n]) {
$tr .= '<font color="red">';
$notr++;
}
}
$tr .= '<br />• ';
if ($n == 'rep') {
$temp = explode('::', $po['tr_' . $n]);
$tr .= $this->is[$n] . ' ' . ucfirst(
str_replace('city', ' city', $temp[1])
) . ': ' . $temp[0];
unset($temp);
} elseif ($n != 'align' && $n != 'align_bs') {
if ($n == 'sex') {
if ($po['tr_' . $n] == 1) {
$tr .= $this->is[$n] . ': Женский';
} else {
$tr .= $this->is[$n] . ': Мужской';
}
} else {
$tr .= $this->is[$n] . ': ' . $po['tr_' . $n];
}
} else {
$tr .= $this->is[$n] . ': ' . $this->align_nm[$po['tr_' . $n]];
}
if ($n == 'sex') {
if ($this->info['sex'] != $po['tr_' . $n]) {
$tr .= '</font>';
}
} elseif ($po['tr_' . $n] > $this->stats[$n]) {
if ($n == 'align_bs' && $this->info['inTurnir'] > 0 && ($pal = false || $tar = false)) {
$tr .= '</font>';
} elseif ($n != 'align' && $n != 'align_bs' || floor(
$this->info['align']
) != $po['tr_' . $n]) {
$tr .= '</font>';
}
}
}
$x++;
}
if ($tr != '') {
$is2 .= '<br><strong>Требуется минимальное:</strong>' . $tr;
}
//<strong>Действует на:</strong>
$tr = '';
$t = $this->items['add'];
if (isset($po['mf_stats']) && $po['mf_stats'] > 0) {
$tr .= '<br>Свободные характеристики: ' . $po['mf_stats'];
}
if (isset($po['mf_mod']) && $po['mf_mod'] > 0) {
$tr .= '<br>Свободные модификаторы: ' . $po['mf_mod'];
}
if (isset($po['mf_mib']) && $po['mf_mib'] > 0) {
$tr .= '<br>Свободные улучшения брони: ' . $po['mf_mib'];
}
$x = 0;
while ($x < count($t)) {
$n = $t[$x];
if (isset($po['add_' . $n], $this->is[$n])) {
$z = '+';
if ($po['add_' . $n] < 0) {
$z = '';
}
$tr .= '<br>• ' . $this->is[$n] . ': ' . $z . '' . $po['add_' . $n];
if (isset($po['mf_stats']) && $po['mf_stats'] > 0 && ($n == 's1' || $n == 's2' || $n == 's3' || $n == 's5')) {
$tr .= ' <a href="main.php?inv=1&otdel=' . $_GET['otdel'] . '&rstv=' . $pl['id'] . '&mf=' . $n . '"><img src="' . Config::img() . '/i/up.gif" width="11" height="11"></a>';
}
if (isset($po['mf_mod']) && $po['mf_mod'] > 0 && ($n == 'm1' || $n == 'm2' || $n == 'm4' || $n == 'm5')) {
$tr .= ' <a href="main.php?inv=1&otdel=' . $_GET['otdel'] . '&rstv=' . $pl['id'] . '&mf=' . $n . '"><img src="' . Config::img() . '/i/up.gif" width="11" height="11"></a>';
}
}
$x++;
}
//действует на (броня)
$i = 1;
$bn = [1 => 'головы', 2 => 'корпуса', 3 => 'пояса', 4 => 'ног'];
while ($i <= 4) {
if (isset($po['add_mab' . $i])) {
if ($po['add_mab' . $i] == $po['add_mib' . $i] && $pl['geniration'] == 1) {
$z = '+';
if ($po['add_mab' . $i] < 0) {
$z = '';
}
$tr .= '<br>• Броня ' . $bn[$i] . ': ' . $z . '' . $po['add_mab' . $i];
} else {
$tr .= '<br>• Броня ' . $bn[$i] . ': ' . $po['add_mib' . $i] . '-' . $po['add_mab' . $i];
}
if (isset($po['mf_mib']) && $po['mf_mib'] > 0) {
$tr .= ' <a href="main.php?inv=1&otdel=' . $_GET['otdel'] . '&rstv=' . $pl['id'] . '&mf=mib' . $i . '"><img src="' . Config::img() . '/i/up.gif" width="11" height="11"></a>';
}
}
$i++;
}
if ($tr != '') {
$is2 .= '<br><strong>Действует на:</strong>' . $tr;
}
//<strong>Свойства предмета:</strong>
$tr = '';
$t = $this->items['sv'];
if (isset($po['sv_yron_min'], $po['sv_yron_max'])) {
$tr .= '<br>• Урон: ' . $po['sv_yron_min'] . ' - ' . $po['sv_yron_max'];
}
$x = 0;
while ($x < count($t)) {
$n = $t[$x];
if (isset($po['sv_' . $n])) {
$z = '+';
if ($po['sv_' . $n] < 0) {
$z = '';
}
$tr .= '<br>• ' . $this->is[$n] . ': ' . $z . '' . $po['sv_' . $n];
}
$x++;
}
if ($pl['2too'] == 1) {
$tr .= '<br>• Второе оружие';
}
if ($pl['2h'] == 1) {
$tr .= '<br>• Двуручное оружие';
}
if (isset($po['zonb'])) {
$tr .= '<br>• Зоны блокирования: ';
if ($po['zonb'] > 0) {
$x = 1;
while ($x <= $po['zonb']) {
$tr .= '+';
$x++;
}
} else {
$tr .= '—';
}
}
if ($tr != '') {
$is2 .= '<br><strong>Свойства предмета:</strong>' . $tr;
}
if ($notr == 0) {
$d[0] = 1;
if ($pl['magic_inci'] != '' || $pl['magic_inc'] != '') {
$d[2] = 1;
}
}
$tr = '';
if (floor($pl['iznosNOW']) >= ceil($pl['iznosMAX'])) {
$d[0] = 0;
$d[2] = 0;
}
//Апгрейды вещей
//Встроенная магия
if ($pl['magic_inci'] != '' || $pl['magic_inc'] != '') {
if ($pl['magic_inc'] == '') {
$pl['magic_inc'] = $pl['magic_inci'];
}
$mgi = mysql_fetch_array(
mysql_query(
'SELECT * FROM `eff_main` WHERE `id2` = "' . $pl['magic_inc'] . '" AND `type1` = "12345" LIMIT 1'
)
);
if (isset($mgi['id2'])) {
$is2 .= '<div> Встроено заклятие <img height=18 title="' . $mgi['mname'] . '" src="' . Config::img() . '/i/eff/' . $mgi['img'] . '"> ' . $mgi['minfo'] . '</div>';
}
}
if (isset($po['rune']) && $po['rune'] > 0) {
$rnc = explode(' ', $po['rune_name']);
if ($rnc[0] == 'Игнис') {
$rnc = '#9b5d40';
} elseif ($rnc[0] == 'Аква') {
$rnc = '#3a2b64';
} elseif ($rnc[0] == 'Аура') {
$rnc = '#20a3b0';
} elseif ($rnc[0] == 'Тера') {
$rnc = '#4c7718';
} else {
$rnc = '#4c4c4c';
}
$tr .= '<br>&bull; Встроенная руна: <small><font color=green>&bull; <u><strong>' . $po['rune_name'] . '</strong></u></font></small>';
unset($rnc);
}
if (isset($po['spell']) && $po['spell'] > 0) {
$rnc = explode(' ', $po['spell_name']);
if ($rnc[2] == '[0]') {
$rnc = '#282828';
} elseif ($rnc[2] == '[1]') {
$rnc = '#624542';
} elseif ($rnc[2] == '[2]') {
$rnc = '#77090b';
} elseif ($rnc[2] == '[3]') {
$rnc = '#d99800';
} else {
$rnc = '#d99800';
}
$po['spell_name'] = str_replace('Зачаровать ', '', $po['spell_name']);
$this->is['mab1'] = 'Броня головы';
$this->is['mab2'] = 'Броня корпуса';
$this->is['mab3'] = 'Броня пояса';
$this->is['mab4'] = 'Броня ног';
$tr .= '<br>&bull; Встроенно зачарование: <small><font color=' . $rnc . '><u><strong>' . $po['spell_name'] . '</strong></u> (' . $this->is[$po['spell_st_name']] . ': +' . $po['spell_st_val'] . ')</font></small>';
unset($this->is['mab1'], $this->is['mab2'], $this->is['mab3'], $this->is['mab4']);
unset($rnc);
}
if (isset($po['imposed']) && $po['imposed'] > 0) {
if ($po['imposed_lvl'] == 0) {
$rnc = 'maroon';
} elseif ($po['imposed_lvl'] == 1) {
$rnc = '#624542';
} elseif ($po['imposed_lvl'] == 2) {
$rnc = '#77090b';
} elseif ($po['imposed_lvl'] == 3) {
$rnc = '#d99800';
} else {
$rnc = '#282828';
}
$po['imposed_name'] = str_replace('Чары ', '', $po['imposed_name']);
$tr .= '<br>&bull; <font color=' . $rnc . '>Наложены заклятия:</font> ' . $po['imposed_name'] . ' ';
unset($rnc);
}
if ($tr != '') {
$is2 .= '<br><strong>Улучшения предмета:</strong>';
$is2 .= $tr;
}
if (isset($po['free_stats']) && $po['free_stats'] > 0) {
$is2 .= '<br><strong>Распределение статов:</strong>';
$is2 .= '<div style="margin-left:20px;"><small>Сила: ' . $po['add_s1'] . ' <a href="?inv=1&itmid=' . $pl['id'] . '&otdel=' . ((int)$_GET['otdel']) . '&ufs=1"><img src="' . Config::img() . '/i/plus.gif"></a><br>Ловкость: ' . $po['add_s2'] . ' <a href="?inv=1&itmid=' . $pl['id'] . '&otdel=' . ((int)$_GET['otdel']) . '&ufs=2"><img src="' . Config::img() . '/i/plus.gif"></a><br>Интуиция: ' . $po['add_s3'] . ' <a href="?inv=1&itmid=' . $pl['id'] . '&otdel=' . ((int)$_GET['otdel']) . '&ufs=3"><img src="' . Config::img() . '/i/plus.gif"></a><br>Интеллект: ' . $po['add_s5'] . ' <a href="?inv=1&itmid=' . $pl['id'] . '&otdel=' . ((int)$_GET['otdel']) . '&ufs=5"><img src="' . Config::img() . '/i/plus.gif"></a></small></div>';
$is2 .= '&bull; Осталось распределений: ' . $po['free_stats'] . '';
}
if (isset($po['sm_abil'])) {
//Возможно сохранять и распределять скилы
$mx2 = 1;
$mx1 = 0;
$mx3 = Conversion::dataStringToArray($this->info['stats']);
while ($mx2 <= 7) {
$mx1 += $mx3['s' . $mx2] - $po['add_s' . $mx2];
$mx2++;
}
$mx1 += $this->info['ability'];
if ($mx1 > 0) {
$is2 .= '<br><strong>Распределение характеристик:</strong>';
if (isset($po['sudba']) && $po['sudba'] == '0') {
$mx1 = 0;
$is2 .= '<div style="margin-left:20px;"><small>&bull; Распределение характеристик будет доступно после первого одевания</small></div>';
} else {
$is2 .= '<div style="margin-left:20px;"><small>
Сила: ' . (0 + $po['add_s1']) . ' <a href="?inv=1&itmid=' . $pl['id'] . '&otdel=' . ((int)$_GET['otdel']) . '&ufsmst=1"><img src="' . Config::img() . '/i/plus.gif"></a><br>
Ловкость: ' . (0 + $po['add_s2']) . ' <a href="?inv=1&itmid=' . $pl['id'] . '&otdel=' . ((int)$_GET['otdel']) . '&ufsmst=2"><img src="' . Config::img() . '/i/plus.gif"></a><br>
Интуиция: ' . (0 + $po['add_s3']) . ' <a href="?inv=1&itmid=' . $pl['id'] . '&otdel=' . ((int)$_GET['otdel']) . '&ufsmst=3"><img src="' . Config::img() . '/i/plus.gif"></a><br>
Выносливость: ' . (0 + $po['add_s4']) . ' <a href="?inv=1&itmid=' . $pl['id'] . '&otdel=' . ((int)$_GET['otdel']) . '&ufsmst=4"><img src="' . Config::img() . '/i/plus.gif"></a><br>
Интеллект: ' . (0 + $po['add_s5']) . ' <a href="?inv=1&itmid=' . $pl['id'] . '&otdel=' . ((int)$_GET['otdel']) . '&ufsmst=5"><img src="' . Config::img() . '/i/plus.gif"></a><br>
Мудрость: ' . (0 + $po['add_s6']) . ' <a href="?inv=1&itmid=' . $pl['id'] . '&otdel=' . ((int)$_GET['otdel']) . '&ufsmst=6"><img src="' . Config::img() . '/i/plus.gif"></a><br>
</small></div>';
$is2 .= 'Осталось распределений: ' . $mx1;
}
}
unset($mx1, $mx2, $mx3);
}
if (isset($po['sm_skill'])) {
//Возможно сохранять и распределять скилы
$mx2 = 1;
$mx1 = 0;
$mx3 = Conversion::dataStringToArray($this->info['stats']);
while ($mx2 <= 7) {
$mx1 += ($mx3['a' . $mx2] + $mx3['mg' . $mx2]) - ($po['add_a' . $mx2] + $po['add_mg' . $mx2]);
$mx2++;
}
$mx1 += $this->info['skills'];
if ($mx1 > 0) {
$is2 .= '<br><strong>Распределение владений оружием и магией:</strong>';
if (isset($po['sudba']) && $po['sudba'] == '0') {
$mx1 = 0;
$is2 .= '<div style="margin-left:20px;"><small>&bull; Распределение владений будет доступно после первого одевания</small></div>';
} else {
$is2 .= '<div style="margin-left:20px;"><small>
Мастерство владения мечами: ' . (0 + $po['add_a1']) . ' <a href="?inv=1&itmid=' . $pl['id'] . '&otdel=' . ((int)$_GET['otdel']) . '&ufsms=1"><img src="' . Config::img() . '/i/plus.gif"></a><br>
Мастерство владения дубинами, булавами: ' . (0 + $po['add_a2']) . ' <a href="?inv=1&itmid=' . $pl['id'] . '&otdel=' . ((int)$_GET['otdel']) . '&ufsms=2"><img src="' . Config::img() . '/i/plus.gif"></a><br>
Мастерство владения ножами, кастетами: ' . (0 + $po['add_a3']) . ' <a href="?inv=1&itmid=' . $pl['id'] . '&otdel=' . ((int)$_GET['otdel']) . '&ufsms=3"><img src="' . Config::img() . '/i/plus.gif"></a><br>
Мастерство владения топорами, секирами: ' . (0 + $po['add_a4']) . ' <a href="?inv=1&itmid=' . $pl['id'] . '&otdel=' . ((int)$_GET['otdel']) . '&ufsms=4"><img src="' . Config::img() . '/i/plus.gif"></a><br>
Мастерство владения магическими посохами: ' . (0 + $po['add_a5']) . ' <a href="?inv=1&itmid=' . $pl['id'] . '&otdel=' . ((int)$_GET['otdel']) . '&ufsms=5"><img src="' . Config::img() . '/i/plus.gif"></a><br>
Мастерство владения стихией Огня: ' . (0 + $po['add_mg1']) . ' <a href="?inv=1&itmid=' . $pl['id'] . '&otdel=' . ((int)$_GET['otdel']) . '&ufsms=6"><img src="' . Config::img() . '/i/plus.gif"></a><br>
Мастерство владения стихией Воздуха: ' . (0 + $po['add_mg2']) . ' <a href="?inv=1&itmid=' . $pl['id'] . '&otdel=' . ((int)$_GET['otdel']) . '&ufsms=7"><img src="' . Config::img() . '/i/plus.gif"></a><br>
Мастерство владения стихией Воды: ' . (0 + $po['add_mg3']) . ' <a href="?inv=1&itmid=' . $pl['id'] . '&otdel=' . ((int)$_GET['otdel']) . '&ufsms=8"><img src="' . Config::img() . '/i/plus.gif"></a><br>
Мастерство владения стихией Земли: ' . (0 + $po['add_mg4']) . ' <a href="?inv=1&itmid=' . $pl['id'] . '&otdel=' . ((int)$_GET['otdel']) . '&ufsms=9"><img src="' . Config::img() . '/i/plus.gif"></a><br>
Мастерство владения магией Света: ' . (0 + $po['add_mg5']) . ' <a href="?inv=1&itmid=' . $pl['id'] . '&otdel=' . ((int)$_GET['otdel']) . '&ufsms=10"><img src="' . Config::img() . '/i/plus.gif"></a><br>
Мастерство владения магией Тьмы: ' . (0 + $po['add_mg6']) . ' <a href="?inv=1&itmid=' . $pl['id'] . '&otdel=' . ((int)$_GET['otdel']) . '&ufsms=11"><img src="' . Config::img() . '/i/plus.gif"></a><br>
Мастерство владения серой магией: ' . (0 + $po['add_mg7']) . ' <a href="?inv=1&itmid=' . $pl['id'] . '&otdel=' . ((int)$_GET['otdel']) . '&ufsms=12"><img src="' . Config::img() . '/i/plus.gif"></a><br>
</small></div>';
$is2 .= 'Осталось распределений: ' . $mx1;
}
}
unset($mx1, $mx2, $mx3);
}
if (isset($po['complect']) || isset($po['complect2'])) {
$is2 .= '<br><i>Дополнительная информация:</i>';
}
if (isset($po['complect'])) {
//не отображается
$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'
);
while ($plc = mysql_fetch_array($spc)) {
$com1['name'] = $plc['name'];
$com1['text'] .= '&nbsp; &nbsp; &bull; <font color="green">' . $plc['x'] . '</font>: ';
//действие комплекта
$i1c = 0;
$i2c = 0;
$i1e = Conversion::dataStringToArray($plc['data']);
while ($i1c < count($this->items['add'])) {
if (isset($i1e[$this->items['add'][$i1c]])) {
$i3c = $i1e[$this->items['add'][$i1c]];
if ($i3c > 0) {
$i3c = '+' . $i3c;
}
if ($i2c > 0) {
$com1['text'] .= '&nbsp; &nbsp; ' . $this->is[$this->items['add'][$i1c]] . ': ' . $i3c;
} else {
$com1['text'] .= $this->is[$this->items['add'][$i1c]] . ': ' . $i3c;
}
$com1['text'] .= '<br>';
$i2c++;
}
$i1c++;
}
unset($i1c, $i2c, $i3c);
$com1['x']++;
}
$is2 .= '<br>&bull; Часть комплекта: <strong>' . $com1['name'] . '</strong><br><small>';
$is2 .= $com1['text'];
$is2 .= '</small>';
}
if (isset($po['complect2'])) {
//не отображается
$com1 = ['name' => 'Неизвестный Комплект', 'x' => 0, 'text' => ''];
$spc = mysql_query(
'SELECT `id`,`com`,`name`,`x`,`data` FROM `complects` WHERE `com` = "' . $po['complect2'] . '" ORDER BY `x` ASC LIMIT 20'
);
while ($plc = mysql_fetch_array($spc)) {
$com1['name'] = $plc['name'];
$com1['text'] .= '&nbsp; &nbsp; &bull; <font color="green">' . $plc['x'] . '</font>: ';
//действие комплекта
$i1c = 0;
$i2c = 0;
$i1e = Conversion::dataStringToArray($plc['data']);
while ($i1c < count($this->items['add'])) {
if (isset($i1e[$this->items['add'][$i1c]])) {
$i3c = $i1e[$this->items['add'][$i1c]];
if ($i3c > 0) {
$i3c = '+' . $i3c;
}
if ($i2c > 0) {
$com1['text'] .= '&nbsp; &nbsp; ' . $this->is[$this->items['add'][$i1c]] . ': ' . $i3c;
} else {
$com1['text'] .= $this->is[$this->items['add'][$i1c]] . ': ' . $i3c;
}
$com1['text'] .= '<br>';
$i2c++;
}
$i1c++;
}
unset($i1c, $i2c, $i3c);
$com1['x']++;
}
$is2 .= '<br>&bull; Часть комплекта (подгонка): <strong>' . $com1['name'] . '</strong><br><small>';
$is2 .= $com1['text'];
$is2 .= '</small>';
}
if ($pl['max_text'] > 0) {
//Инвентарь
$sm_sp = mysql_query(
'SELECT `id`,`item_id`,`time`,`login`,`type`,`text`,`city`,`x` FROM `items_text` WHERE `item_id` = "' . $pl['id'] . '" ORDER BY `id` ASC LIMIT 500'
);
$sma = 0;
$smt = '';
$ixi = 0;
while ($sm_pl = mysql_fetch_array($sm_sp)) {
if ($sm_pl['type'] == 0) {
$smt .= '<font class="date">' . date(
'd.m.Y H:i', $sm_pl['time']
) . '</font> <strong>' . $sm_pl['login'] . '</strong>. ' . $sm_pl['text'] . '<br>';
} else {
$smt .= $sm_pl['text'] . '<br>';
}
if ($ixi == 2) {
$smt .= '<div style="display:none" id="close_text_itm' . $pl['id'] . '">';
}
$ixi++;
$sma += $sm_pl['x'];
}
$smt .= '</div>';
if ($pl['max_text'] - $pl['use_text'] > 0) {
$is2 .= '<div>Количество символов: ' . ($pl['max_text'] - $pl['use_text']) . '</div>';
}
if ($sma > 0) {
$is2 .= '<div>На предмете записан текст:<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div style="background-color:#e8e8e8;padding:5px;"><CODE>' . $smt . '</CODE></div></td>
<td width="20" align="center" valign="top"><img style="cursor:pointer" onClick="seetext(' . $pl['id'] . ')" src="' . Config::img() . '/expand.gif" height="35" width="10"></td>
</tr>
</table>
</div>';
}
unset($sm_sp, $sma, $sm_pl);
} elseif (isset($po['onitm_text'])) {
$is2 .= '<div>На предмете записан текст:<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div style="background-color:#e8e8e8;padding:5px;"><CODE>' . $po['onitm_text'] . '</CODE></div></td>
</tr>
</table>
</div>';
}
if (isset($po['gravi'])) {
$is2 .= '<br>На поверхности выгравирована надпись: <strong>' . $po['gravi'] . '</strong>';
}
$is2 .= '<small style="">';
if ($pl['info'] != '') {
$is2 .= '<div><strong>Рекомендации:</strong></div><div>' . $pl['info'] . '</div>';
}
if (isset($po['info']) && $po['info'] != '') {
$is2 .= '<div>' . $po['info'] . '</div>';
}
if (isset($po['toclan'])) {
$po['toclan1'] = explode('#', $po['toclan']);
$clpo = mysql_fetch_array(
mysql_query('SELECT * FROM `clan` WHERE `id` = "' . $po['toclan1'][0] . '" LIMIT 1')
);
if (isset($clpo['id'])) {
$is2 .= '<div style="color:brown;">Предмет принадлежит клану <img style="vertical-align:bottom" src="' . Config::img() . '/i/clan/' . $clpo['name_mini'] . '.gif" width="24" height"15"> <strong>' . $clpo['name'] . '</strong>';
$plpo = mysql_fetch_array(
mysql_query(
'SELECT `id`,`login`,`cityreg` FROM `users` WHERE `id` = "' . $po['toclan1'][1] . '" LIMIT 1'
)
);
if (isset($plpo['id'])) {
$is2 .= ' <font color=grey>(Дар игрока <strong>' . $plpo['login'] . '</strong><a href="info/' . $plpo['id'] . '" target="_blank"><img src="' . Config::img() . '/i/inf_' . $plpo['cityreg'] . '.gif" width="9"></a>)</font>';
if ($plpo['login'] == $this->info['login']) {
if (isset($_GET['backmyitm'])) {
$pl['inOdet'] = 0;
$pl['uid'] = $plpo['id'];
unset($po['toclan1'], $po['toclan']);
$pl['data'] = Conversion::arrayToDataString($po);
mysql_query(
'UPDATE `items_users` SET `data` = "' . mysql_real_escape_string(
$pl['data']
) . '",`inOdet` = 0,`uid` = "' . $pl['uid'] . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1'
);
}
$is2 .= '<br>(Вы владелец предмета: <a href="main.php?clan&deposit&backmyitm=' . $pl['id'] . '">Вернуть предмет себе</a>)';
}
}
$is2 .= '</div>';
}
}
if (isset($po['noremont'])) {
$is2 .= '<div style="color:brown;">Предмет не подлежит ремонту</div>';
}
if (isset($po['nosale'])) {
$is2 .= '<div style="color:brown;">Предмет нельзя продать</div>';
}
if (isset($po['nomodif'])) {
$is2 .= '<div style="color:brown;">Предмет нельзя улучшать</div>';
}
if (isset($po['nodelete'])) {
$is2 .= '<div style="color:brown;">Предмет нельзя выбросить</div>';
}
if (isset($po['frompisher'])) {
$is2 .= '<div style="color:brown;">Предмет из подземелья</div>';
}
if (isset($po['sleep_moroz']) && $po['sleep_moroz'] > 0) {
$is2 .= '<div style="color:brown;">Предмет не портится во время сна</div>';
}
if (isset($po['fromlaba']) && $po['fromlaba'] > 0) {
$is2 .= '<div style="color:brown;">Предмет из лабиринта</div>';
}
if (isset($po['vip_sale']) && $po['vip_sale'] > 0) {
if ($this->stats['slvtm'] > time() && $this->stats['silver'] > 1) {
if ($pl['time_create'] != $this->stats['slvtm']) {
$pl['time_create'] = $this->stats['slvtm'];
mysql_query(
'UPDATE `items_users` SET `time_create` = "' . $pl['time_create'] . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1'
);
}
$is2 .= '<div style="color:brown;">Предмет будет недоступен через ' . $this->timeOut(
$pl['time_create'] - time()
) . '</div>';
} else {
$is2 .= '<div style="color:brown;">Предмет недоступен, приобретите конкретный VIP</div>';
if (($pl['time_create'] - time() + 86400 * 30) < 1) {
$is2 .= '<div style="color:brown;">Предмет рассыпался у Вас на глазах...</div>';
} else {
$is2 .= '<div style="color:brown;">Предмет исчезнет через ' . $this->timeOut(
$pl['time_create'] - time() + 86400 * 30
) . '</div>';
}
}
}
if ($pl['dn_delete'] > 0) {
$is2 .= '<div style="color:brown;">Предмет будет удален при выходе из подземелья</div>';
}
if ($this->pokol > $pl['geni']) {
$is2 .= '<div style="color:brown">Предмет устарел</div>';
}
if (isset($po['zazuby']) && $po['zazuby'] > 0) {
$is2 .= '<div style="color:brown;">Предмет куплен за зубы</div>';
}
$is2 .= '</small>';
if ($col > 1000) {
$is1 .= '<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="' . Config::img() . '/i/items/' . $pl['img'] . '"></td>
</tr>
<tr>
<td align="right"><span style="position:relative;margin-bottom:5px;"><small style="position:absolute;background-color:grey;padding:1px;bottom:1px;right:1px;background-color:#E0E0E0;"><strong>x' . $col . '</strong></small></span></td>
</tr>
</table>';
} else {
$is1 .= '<img src="' . Config::img() . '/i/items/' . $pl['img'] . '" style="margin-bottom:5px;">';
}
$is1 .= '<br>';
if ($type == 81) {
$is1 .= '<small><a href="main.php?inv=1&otdel=' . floor($_GET['otdel']) . '&use_rune=' . floor(
$_GET['use_rune']
) . '&item_rune=0&item_rune_id=' . $pl['id'] . '">Выбрать данный предмет</a></small>';
} elseif ($type == 80) {
$itemrun = mysql_fetch_array(
mysql_query('SELECT * FROM `items_users` WHERE `id` ="' . $pl['id'] . '" LIMIT 1')
);
$it = Conversion::dataStringToArray($itemrun['data']);
if (!isset($it['rune_name']) || $_GET['otdel'] == 2) //отдел 2(заточки)
{
$is1 .= '<small><a href="main.php?inv=1&otdel=' . floor($_GET['otdel']) . '&use_rune=' . floor(
$_GET['use_rune']
) . '&item_rune=0&item_rune_id=' . $pl['id'] . '">Выбрать данный предмет</a></small>';
} else {
$is1 .= '<small><strong>Установленна:<br>' . $it['rune_name'] . '</strong></small>';
}
unset($itemrun, $it);
} elseif ($type == 69) {
if (!isset($po['hprs'])) {
$po['hprs'] = 0.001;
}
if (!isset($po['hprp'])) {
$po['hprp'] = 0.0001;
}
$prs1 = $this->floordec($po['hprs'] * $col, 2);
$rps1 = $this->floordec($po['hprp'] * $col);
$is1 .= '<small style="font-size:11px;"><a href="?sale1kr=' . $pl['id'] . '">Обменять на ' . $prs1 . ' кр.</a><br><a href="?sale1rep=' . $pl['id'] . '">Обменять на ' . $rps1 . ' ед. репутации</a>';
$is1 .= '</small>';
} elseif ($type == 68) {
$is1 .= '<small style="font-size:11px;"><a href="?r=3&itm_take=' . $pl['id'] . '">Забрать</a><br><a href="?r=3&itm_cancel=' . $pl['id'] . '">Отказаться</a>';
if ($pl['lastUPD'] > 0) {
$is1 .= '<br><br>(' . $this->timeOut(($pl['lastUPD'] + 7 * 24 * 60 * 60) - time()) . ')';
}
$is1 .= '</small>';
} elseif ($type == 67) {
$is1 .= '<small style="font-size:11px;"><a href="javascript:void(0)" onclick="itmToUser(' . $pl['id'] . ')">передать за ' . (round(
1 + $pl['price1'] / 100 * 7
) * $col) . ' кр.</a></small>';
} elseif ($type == 66) {
$pos = explode('#', $po['toclan']);
$us_1 = $pos[1];
if ($pl['uid'] < 1) {
$is1 .= '<small style=""><a href="?clan&deposit&take_itm=' . $pl['id'] . '">Взять предмет</a></small>';
} else {
$yui = mysql_fetch_array(
mysql_query(
'SELECT `id`,`login`,`cityreg` FROM `users` WHERE `id` = "' . mysql_real_escape_string(
$pl['uid']
) . '" LIMIT 1'
)
);
$is1 .= '<small>Предмет у игрока<br><strong>' . $yui['login'] . '</strong><a href="info/' . $yui['id'] . '" target="_blank"><img width="10" src="' . Config::img() . '/i/inf_' . $yui['cityreg'] . '.gif"></a></small>';
if ($this->info['tt'][14][0] == 1 || ($this->info['id'] == $us_1)) {
$is1 .= '<br><small style=""><a href="?clan&deposit&ungive_itm=' . $pl['id'] . '">Изъять предмет</a></small>';
}
}
} elseif ($type == 65) {
if (!isset($po['toclan'])) {
$is1 .= '<small style=""><a href="?clan&deposit&give_itm=' . $pl['id'] . '">Пожертвовать</a></small>';
} else {
$is1 .= '<small style=""><a href="?clan&deposit&give_itm=' . $pl['id'] . '">Вернуть</a></small>';
}
} elseif ($type == 62) {
$upgitm = mysql_fetch_array(
mysql_query('SELECT * FROM `items_upgrade` WHERE `iid` = "' . $pl['item_id'] . '" LIMIT 1')
);
if (!isset($upgitm['id'])) {
$is1 .= '<small style="">Улучшение невозможно</small>';
} else {
$prcup = '';
if ($upgitm['price1'] > 0) {
$prcup .= $upgitm['price1'] . ' кр.';
}
if ($upgitm['price2'] > 0) {
if ($prcup != '') {
$prcup .= ' и ';
}
$prcup .= $upgitm['price2'] . ' екр.';
}
$is1 .= '<small style=""><a href="?r=8&upgradelvl=' . $pl['id'] . '">Улучшить за ' . $prcup . '</a></small>';
unset($prcup);
}
} elseif ($type == 63) {
$prcup = '';
$is1 .= '<small style=""><a href="?r=9&upgradelvlcom=' . $pl['id'] . '">комплект</a></small>';
unset($prcup);
} elseif ($type == 64) {
$prcup = '';
$is1 .= '<small style=""><a href="?r=9">Выбрать другой предмет</a></small>';
unset($prcup);
} elseif ($type == 61) { //улучшение предмета
if ($pl['price1'] > $pl['1price']) {
$pl['1price'] = $pl['price1'];
}
$prpod = $pl['1price'] / 2.37;
if ($pl['price2'] > $pl['2price']) {
$pl['2price'] = $pl['price2'];
}
$prpod2 = 30 * ($pl['2price'] / 2.37);
if ($prpod2 > $prpod) {
$prpod = $prpod2;
}
if (!isset($po['add_s1']) && !isset($po['add_s2']) && !isset($po['add_s3']) && !isset($po['add_s5'])) {
$prpod = $prpod / 2.37;
}
$prpod = round($prpod + $prpod / 100 * (37.795 * ($po['upgrade'] + 1)));
$is1 .= '<small style=""><a href="?upgrade=' . $pl['id'] . '&r=6&t=2&rnd=' . $code . '">Усилить за ' . $prpod . ' кр.</a></small>';
} elseif ($type == 60) { //модифицирование
if ($pl['price1'] > $pl['1price']) {
$pl['1price'] = $pl['price1'];
}
$prpod = $pl['1price'] / 2;
if ($pl['price2'] > $pl['2price']) {
$pl['2price'] = $pl['price2'];
}
$prpod2 = 30 * ($pl['2price'] / 2.37);
if ($prpod2 > $prpod) {
$prpod = $prpod2;
}
if (!isset($po['add_s1']) && !isset($po['add_s2']) && !isset($po['add_s3']) && !isset($po['add_s5'])) {
$prpod = $prpod / 2;
}
$prpod = round($prpod);
$is1 .= '<small style=""><a href="?modif=' . $pl['id'] . '&r=7&t=2&rnd=' . $code . '">Модифицировать за ' . $prpod . ' кр.</a></small>';
} elseif ($type == 59) { //дезинтеграция
if ($po['tr_lvl'] > $pl['level']) {
$pl['level'] = $po['tr_lvl'];
}
$prpod = 250;
$prpod_ekr = $pl['level'] * 0.25;
if ($this->stats['repair_z'] >= 1) {
$is1 .= '<small style=""><a href="?ubeff=' . $pl['id'] . '&r=3&t=2&rnd=' . $code . '">Бесплатная дезинтеграция</a></small>';
} else {
$is1 .= '<small style=""><a href="?ubeff=' . $pl['id'] . '&r=3&t=2&rnd=' . $code . '">Дезинтегрировать за ' . $prpod . ' Кр.</a></small>
<!--<br><small style=""><a href="?ubeff_ekr=' . $pl['id'] . '&r=3&t=2&rnd=' . $code . '">Дезинтегрировать за ' . $prpod_ekr . ' Екр.</a></small>-->';
}
} elseif ($type == 58) { //вытаскивание рун
if ($po['tr_lvl'] > $pl['level']) {
$pl['level'] = $po['tr_lvl'];
}
$prpod = 2500;
$prpod_ekr = $pl['level'] * 0.15;
if ($this->stats['repair_r'] >= 1) {
$is1 .= '<small style=""><a href="?unrune=' . $pl['id'] . '&r=4&t=2&rnd=' . $code . '">Бесплатно извлечь руны</a></small>';
} else {
$is1 .= '<small style=""><a href="?unrune=' . $pl['id'] . '&r=4&t=2&rnd=' . $code . '">Извлечь руны за ' . $prpod . ' Кр.</a></small><br>
<!--<small style=""><a href="?unrune_ekr=' . $pl['id'] . '&r=4&t=2&rnd=' . $code . '">Извлечь руны за ' . $prpod_ekr . ' Екр.</a>
</small> -->';
}
} elseif ($type == 57) {
$prpod = 30;
if ($pl['type'] == 22) {
$prpod = 35;
} elseif ($pl['type'] == 18) {
$prpod = 15;
}
if (isset($po['gravi'])) {
$is1 .= '<small style=""><a onclick="top.un_grava(\'' . $pl['id'] . '\',\'' . $pl['name'] . '\',\'' . $prpod . '.00\',\'data\')" href="javascript:void(0)">Изменить надпись за ' . $prpod . ' кр.</a></small>';
} else {
$is1 .= '<small style=""><a onclick="top.grava(\'' . $pl['id'] . '\',\'' . $pl['name'] . '\',\'' . $prpod . '.00\',\'data\')" href="javascript:void(0)">Выгравировать надпись за ' . $prpod . ' кр.</a></small>';
}
} elseif ($type == 56) { //Подгонка
if ($po['tr_lvl'] > $pl['level']) {
$pl['level'] = $po['tr_lvl'];
}
$prpod = 5 * $pl['level'] + 10;
$prhp = 6 * $pl['level'] + 6;
$is1 .= '<small style=""><a href="?podgon=' . $pl['id'] . '&r=5&t=2&rnd=' . $code . '">Подогнать за ' . $prpod . ' кр.</a></small>';
} elseif ($type == 15) { //кормушка зверя
$is1 .= '<a href="main.php?pet=1&obj_corm=' . $pl['id'] . '&rnd=' . $code . '">Кормить</a>';
} elseif ($type == 11) {
$pl['rep'] = 0;
if ($this->rep['rep1'] < 100) {
if ($po['tr_lvl'] >= 4 && $po['tr_lvl'] <= 6) {
$pl['rep'] = 1;
}
if ($pl['item_id'] == 1035) {
$pl['rep'] = 2;
}
} elseif ($this->rep['rep1'] > 99 && $this->rep['rep1'] < 1000) {
if ($po['tr_lvl'] >= 7 && $po['tr_lvl'] <= 8) {
$pl['rep'] = 1;
}
if ($pl['item_id'] == 1035) {
$pl['rep'] = 1;
}
} elseif ($this->rep['rep1'] > 999) {
if ($po['tr_lvl'] >= 9 && $po['tr_lvl'] <= 10) {
$pl['rep'] = 1;
}
if ($pl['item_id'] == 1035) {
$pl['rep'] = 1;
}
} else {
if ($pl['item_id'] == 1035) {
$pl['rep'] = 2;
}
}
$is1 .= '<a href="javascript:void(0);" onclick="takeItRun(\'' . $pl['img'] . '\',' . $pl['id'] . ',' . $pl['rep'] . ')">Выбрать</a>';
} elseif ($type == 14) {
$is1 .= '<a href="javascript:void(0);" onclick="massTakeItRun(\'' . $pl['img'] . '\',' . $pl['id'] . ',0)">Выбрать</a>';
} elseif ($type == 12) {
$is1 .= '<a href="javascript:void(0);" onclick="takeItRun(\'' . $pl['img'] . '\',' . $pl['id'] . ',1)">Выбрать</a>';
} elseif ($type == 10) {
//Общага (отображение предметов в общаге (под стеклом))
$is1 .= '<a href="javascript:void(0)" class="obj_take" data-code="' . $code . '" data-room="' . ((int)$_GET['room']) . '" rel="' . $pl['id'] . '">В рюкзак</a>';
} elseif ($type == 9) {
//Общага (отображение предметов в инвентаре (под стеклом))
$is1 .= '<a href="javascript:void(0)" class="obj_add" data-code="' . $code . '" data-room="' . ((int)$_GET['room']) . '" rel="' . $pl['id'] . '">Под стекло</a>';
} elseif ($type == 8) {
//Общага (отображение предметов в инвентаре)
$is1 .= '<a href="javascript:void(0)" class="obj_add" data-code="' . $code . '" data-room="' . ((int)$_GET['room']) . '" rel="' . $pl['id'] . '">В сундук</a>';
} elseif ($type == 7) {
//Общага (отображение предметов в общаге)
$is1 .= '<a href="javascript:void(0)" class="obj_take" data-code="' . $code . '" data-room="' . ((int)$_GET['room']) . '" rel="' . $pl['id'] . '">В рюкзак</a>';
} elseif ($type == 6) {
//Цветочный магазин
$is1 .= '<a href="main.php?otdel=2&add_item_f=' . $pl['id'] . '&rnd=' . $code . '">Добавить</a>';
} elseif ($type == 5) {
//передача
$is1 .= '<a onClick="saleitem(' . $pl['id'] . ',1) return false;" href="javascript:void(0)">подарить</a><br><a onClick="saleitem(' . $pl['id'] . ',2) return false;" href="#">передать</a><br><small style="font-size:10px">(налог: 1 кр.)</small>';
} elseif ($type == 12) {
//передача почта
$skcd = round($col * ($pl['price1'] * 0.06 - 0.01 * $this->stats['os1']), 2);
if ($skcd < 0.06) {
$skcd = 0.06;
}
$is1 .= '<a href="main.php?otdel=' . $_GET['otdel'] . '&setlogin=' . $_REQUEST['setlogin'] . '&setobject=' . $pl['id'] . '&room=2&tmp=' . $code . '" onclick="return confirm(\'Передать предмет ' . $pl['name'] . '?\')">передать&nbsp;за&nbsp;' . (1 + $skcd) . '&nbsp;кр.</A>';
} elseif ($type == 13) {
//Забираем шмот
if ($pl['1price'] > 0) {
$mess = "Отказаться от предмета? Предмет будет уничтожен!";
$pl['name'] = 'Деньги ' . $pl['1price'] . ' кр.';
} else {
$mess = "Отказаться от предмета? Предмет будет возвращен отправителю";
}
$date1 = $pl['delete'] - time();
$is1 .= '<BR><NOBR><A href="?room=4&to_box=' . $pl['id'] . '&tmp=' . $code . '">Забрать</A></NOBR>
<BR><NOBR><A onclick="return confirm(\'' . $mess . '\')" href="?room=4&del_box=' . $pl['id'] . '&tmp=' . $code . '">Отказаться</A></NOBR><SMALL><BR><BR>(' . date(
"j дн. H ч.", $date1
) . ' )</small></TD>';
} elseif ($type == 4) {
//ремонт
$r1 = round($pl['price1'] * 0.1 / 100, 2);
$r2 = round($pl['price1'] * 0.1 / 10, 2);
$r3 = round($pl['price1'] * $pl['iznosNOW'] * 0.10 / 100, 2);
if ($this->stats['repair_discount'] >= 1) {
$r1 = round(($r1 / 100 * 25), 2);
$r2 = round(($r2 / 100 * 25), 2);
$r3 = round(($r3 / 100 * 25), 2);
}
if ($r1 < 0.01) {
$r1 = 0.01;
}
if ($r2 < 0.01) {
$r2 = 0.01;
}
if ($r3 < 0.01) {
$r3 = 0.01;
}
$is1 .= '<small style=""><a href="?remon=' . $pl['id'] . '&t=1&rnd=' . $code . '">Ремонт 1 ед. за ' . $r1 . ' кр.</a><br>';
if ($pl['iznosNOW'] >= 10) {
$is1 .= '<a href="?remon=' . $pl['id'] . '&t=2&rnd=' . $code . '">Ремонт 10 ед. за ' . $r2 . ' кр.</a><br>';
}
$is1 .= '<a href="?remon=' . $pl['id'] . '&t=3&rnd=' . $code . '">Полный ремонт за ' . $r3 . ' кр.</a></small>';
} elseif ($type == 3) {
$is1 .= '<input type="button" onClick="document.getElementById(\'itemgift\').value=' . $pl['id'] . ';document.F1.submit();" value="Подарить" />';
} elseif ($type == 2) {
global $shopProcent;
$shpCena = $pl['1price'];
if ($pl['1price'] == 0) {
$shpCena = $pl['price1'];
}
$plmx = 0;
if ($pl['iznosMAXi'] != $pl['iznosMAX'] && $pl['iznosMAX'] != 0) {
$plmx = $pl['iznosMAX'];
} else {
$plmx = $pl['iznosMAXi'];
}
if ($pl['iznosNOW'] > 0) {
$prc1 = floor($pl['iznosNOW']) / ceil($plmx) * 100;
} else {
$prc1 = 0;
}
$shpCena = $this->shopSaleM($shpCena, $pl);
$shpCena = $shpCena / 100 * (100 - $prc1);
if ($pl['iznosMAXi'] < 999999999) {
if ($pl['iznosMAX'] > 0 && $pl['iznosMAXi'] > 0 && $pl['iznosMAXi'] > ceil($pl['iznosMAX'])) {
$shpCena = $shpCena / 100 * (ceil($pl['iznosMAX']) / $pl['iznosMAXi'] * 100);
}
}
$shpCena = $this->round2($shpCena / 100 * (100 - $shopProcent));
if ($shpCena < 0) {
$shpCena = 0;
}
if ($pl['kolvo'] > 0) {
$shpCena = $shpCena * $pl['kolvo'];
}
if (isset($po['toclan'])) {
$po['toclan1'] = explode('#', $po['toclan']);
$us_1 = $po['toclan1'][1];
if ($us_1 != $this->info['id']) {
$d_s = false;
} else {
$d_s = true;
}
} else {
$d_s = true;
}
if ($d_s) { // Продать за кр тут
$is1 .= '<a href="javascript:void(0)" onClick="if(confirm(\'Продать предмет &quot;' . $pl['name'] . '&quot; за ' . $shpCena . ' кр.?\')){ location = \'main.php?sale&sd4=' . $this->info['nextAct'] . '&item=' . $pl['id'] . '&rnd=' . $code . '\'; }">Продать за ' . $shpCena . ' кр.</a>';
if ($pl['pricerep'] > 0) {
$is1 .= '<br><a href="javascript:void(0)" onClick="if(confirm(\'Обменять предмет &quot;' . $pl['name'] . '&quot; на ' . floor(
$pl['pricerep'] * $pl['kolvo'] / 2
) . ' воинственности?\')){ location = \'main.php?sale&sd4=' . $this->info['nextAct'] . '&item_rep=' . $pl['id'] . '&rnd=' . $code . '\'; }">Обменять на ' . floor(
$pl['pricerep'] * $pl['kolvo'] / 2
) . ' Воинc. </a>';
}
} else {
$is1 .= 'Это не ваш предмет.';
}
} elseif ($type == 16) {
$shpCena = $pl['price2'];
if ($pl['2price'] > 0) {
$shpCena = $pl['2price'];
}
$shpCena = $this->shopSaleM($shpCena, $pl);
if ($pl['kolvo'] > 0) {
$shpCena = $shpCena * $pl['kolvo'];
}
$plmx = 0;
if ($pl['iznosMAXi'] != $pl['iznosMAX'] && $pl['iznosMAX'] != 0) {
$plmx = $pl['iznosMAX'];
} else {
$plmx = $pl['iznosMAXi'];
}
if ($pl['iznosNOW'] > 0) {
$prc1 = floor($pl['iznosNOW']) / ceil($plmx) * 100;
} else {
$prc1 = 0;
}
$shpCena = $shpCena / 100 * (100 - $prc1);
if ($pl['iznosMAX'] > 0 && $pl['iznosMAXi'] > 0 && $pl['iznosMAXi'] > $pl['iznosMAX']) {
$shpCena = $shpCena / 100 * ($pl['iznosMAX'] / $pl['iznosMAXi'] * 100);
}
$shpCena = $this->round2($shpCena * $this->berezCena());
if ($shpCena < 0) {
$shpCena = 0;
}
if (isset($po['toclan'])) {
$po['toclan1'] = explode('#', $po['toclan']);
$us_1 = $po['toclan1'][1];
if ($us_1 != $this->info['id']) {
$d_s = false;
} else {
$d_s = true;
}
} else {
$d_s = true;
}
if ($d_s) {
$is1 .= '<a href="javascript:void(0)" onClick="if(confirm(\'Продать предмет &quot;' . $pl['name'] . '&quot; за ' . $shpCena . ' екр.?\')){ location = \'main.php?sale&sd4=' . $this->info['nextAct'] . '&item=' . $pl['id'] . '&rnd=' . $code . '\'; }">Продать за ' . $shpCena . ' екр.</a>';
} else {
$is1 .= 'Это не ваш предмет.';
}
} elseif ($type == 30) {
if (isset($po['toclan'])) {
$po['toclan1'] = explode('#', $po['toclan']);
$us_1 = $po['toclan1'][1];
$d_s = !($us_1 != $this->info['id']);
} else {
$d_s = true;
}
if ($d_s) {
$is1 .= '<form method="POST"><input type="hidden" value="' . $pl['id'] . '" name="iid"><input type="text" value="" name="summTR"><input type="submit" value="Сдать в магазин" name="PresTR"></form>';
} else {
$is1 .= 'Это не ваш предмет.';
}
} elseif ($type == 31) {
$is1 .= '<form method="POST"><input type="hidden" value="' . $pl['id'] . '" name="iid"><input type="submit" value="Забрать" name="PresTR"> </form>';
} else {
if ($d[2] == 1) { //можно использовать
$inv1 = '';
if (isset($_GET['inv'])) {
$inv1 = 'inv=1&';
}
if ($pl['item_id'] == 74) {
$is1 .= '<a onclick="top.addNewSmile(' . $pl['id'] . ',0) return false;" href="javascript:void(0)" title="Использовать">исп-ть</a>';
} else {
$useUrl = '';
if ($pl['magic_inc'] == '') {
$pl['magic_inc'] = $pl['magic_inci'];
}
if ($pl['magic_inc'] && $pl['type'] == 30) {
//используем эликсир
$pldate = '<table border=\\\'0\\\' width=\\\'100%\\\' cellspacing=\\\'0\\\' cellpadding=\\\'5\\\'><tr><td rowspan=2 width=\\\'80\\\' valign=\\\'middle\\\'><div align=\\\'center\\\'><img src=\\\'' . Config::img() . '/i/items/' . $pl['img'] . '\\\'></div></td><td valign=\\\'middle\\\' align=\\\'left\\\'>&quot;<strong>' . $pl['name'] . '</strong>&quot;<br>Использовать сейчас?</td></tr></table>';
$useUrl = 'top.useiteminv(\'' . (0 + $pl['id']) . '\',\'' . $pl['img'] . '\',\'' . $pl['img'] . '\',1,\'' . $pldate . '\',\'' . (0 + $_GET['otdel']) . '\');';
} elseif ($pl['magic_inc'] && $pl['type'] == 29) { //используем заклятие
if (isset($po['useOnLogin']) && !isset($po['zazuby'])) { //на персонажа
$useUrl = 'top.useMagic(\'' . $pl['name'] . '\',' . (0 + $pl['id']) . ',\'' . $pl['img'] . '\',1,\'main.php?' . $inv1 . 'otdel=' . ((int)$_GET['otdel']) . '&use_pid=' . $pl['id'] . '&rnd=' . $code . '\');';
} else { //просто использование (на себя, либо без указания предмета\логина)
$pldate = '<table border=\\\'0\\\' width=\\\'100%\\\' cellspacing=\\\'0\\\' cellpadding=\\\'5\\\'><tr><td rowspan=2 width=\\\'80\\\' valign=\\\'middle\\\'><div align=\\\'center\\\'><img src=\\\'' . Config::img() . '/i/items/' . $pl['img'] . '\\\'></div></td><td valign=\\\'middle\\\' align=\\\'left\\\'>&quot;<strong>' . $pl['name'] . '</strong>&quot;<br>Использовать сейчас?</td></tr></table>';
$useUrl = 'top.useiteminv(\'' . (0 + $pl['id']) . '\',\'' . $pl['img'] . '\',\'' . $pl['img'] . '\',1,\'' . $pldate . '\',\'' . (0 + $_GET['otdel']) . '\',' . (0 + $_GET['otdel']) . ');';
}
//на предмет
}
if ($useUrl != '') {
$is1 .= '<a href="javascript:void(0)" onClick="' . $useUrl . '" title="Использовать">исп-ть</a>';
} else {
$d[2] = 0;
}
}
}
if ($pl['max_text'] > 0 && $pl['max_text'] - $pl['use_text'] > 0) {
$is1 .= '<a onclick="top.addNewText(' . $pl['id'] . ',' . ($pl['max_text'] - $pl['use_text']) . ',' . $pl['inRazdel'] . ') return false;" href="javascript:void(0)" title="Записать текст на предмете">Записать</a><br>';
}
if ($pl['type'] == 31 || $pl['type'] == 46 || $pl['type'] == 48 || $pl['type'] == 50 || $pl['type'] == 62 || $pl['type'] == 68 || $pl['type'] == 37 || $pl['type'] == 47) {
if ($d[2] == 1) {
$is1 .= '<br>';
}
if (($pl['type'] != 37 || !isset($po['item_inbox']) || $po['item_inbox'] == 0) && $pl['item_id'] != 10038 && $pl['item_id'] != 10039 && $pl['item_id'] != 10040) {
$is1 .= '<a href="javascript:void(0);" onClick="top.useRune(' . $pl['id'] . ',\'' . $pl['name'] . '\',\'' . $pl['img'] . '\',\'main.php?inv=1&otdel=' . ((int)$_GET['otdel']) . '&use_rune=' . $pl['id'] . '&rnd=' . $code . "\')return false;\" title=\"Использовать\">исп-ть</a>'";
}
}
//можно одеть
if ($d[0] == 1 && $pl['type'] != 30 && $pl['type'] != 31 && (($pl['type'] != 38 && $pl['type'] != 39 && $pl['type'] != 37) || $pl['gift'] != '') && !isset($po['noodet']) && $pl['inslot'] > 0) {
if ($d[2] == 1) {
$is1 .= '<br>';
}
$is1 .= '<a href="main.php?otdel=' . $pl['inRazdel'] . '&inv=1&oid=' . $pl['id'] . '&rnd=' . $code . '" title="Надеть">надеть</a>';
}
if (isset($po['open']) && $d[0] == 1) {
if ($d[2] == 1) {
$is1 .= '<br>';
}
$is1 .= '<a href="main.php?otdel=' . $pl['inRazdel'] . '&inv=1&open=1&oid=' . $pl['id'] . '&rnd=' . $code . '" title="Открыть">Открыть</a>';
}
if (isset($po['close'])) {
if ($d[2] == 1) {
$is1 .= '<br>';
}
$is1 .= '<small><strong>Предмет закрыт</strong></small>';
}
if ($pl['group'] > 0) {
$is1 .= '<br>';
if ($this->itemsX($pl['id']) < $pl['group_max']) {
$is1 .= '<a href="main.php?inv=1&otdel=' . ((int)$_GET['otdel']) . '&stack=' . $pl['id'] . '&rnd=' . $code . '" title="Собрать"><img src="' . Config::img() . '/i/stack.gif" /></a>';
}
if ($this->itemsX($pl['id']) > 1) {
$tbl = '<table style="border: 0; width: 100%;" cellspacing="0" cellpadding="5"><tr><td style="text-align: center; width: 70px;" rowspan="2">
<img src="' . Config::img() . '/i/items/' . $pl['img'] . '" alt=""></td>
<td>Разделить предмет <strong>' . $pl['name'] . '</strong>?</td></tr></table>';
$link = '/main.php?inv=1otdel=' . (int)$_GET['otdel'] . '&unstack=' . $pl['id'] . '&rnd=' . $code;
$onclickStr = sprintf("top.unstack('%d','%s','%s',1,'%s','%d'); return false;", $pl['id'], $pl['img'], $pl['name'], $tbl, (int)$_GET['otdel']);
$is1 = "<a onclick='$onclickStr' href='$link' title='Разделить'><img src='" . Config::img() . "/i/unstack.gif' alt=''></a>";
}
}
if (isset($po['toclan'])) {
$po['toclan1'] = explode('#', $po['toclan']);
$us_1 = $po['toclan1'][1];
if ($us_1 != $this->info['id']) {
$d[1] = 0;
}
}
$is1 .= ' <a href="javascript:void(0);" onclick="top.addfastpanel(\'' . $pl['id'] . '\',\'' . $pl['name'] . '\',\'' . $pl['type'] . '\',\'' . $pl['1price'] . '\',\'' . $pl['2price'] . '\',\'' . $this->city_name[$pl['maidin']] . '\',\'' . $pl['img'] . '\',\'' . $pl['item_id'] . '\',\'' . $pl['iznosNOW'] . '\',\'' . $pl['iznosMAX'] . '\',\'' . intval(
$_GET['otdel']
) . '\',\'' . $d[0] . '\',\'' . $d[2] . '\',\'0\');" title="Добавить в избранное"><img width="16" height="15" src="' . Config::img() . '/add_itm2.gif"></a> ';
if ($d[1] == 1) { //можно выкинуть
if (!isset($po['nodelete'])) {
$is1 .= ' <a onClick="top.drop(' . $pl['id'] . ',\'' . $pl['img'] . '\',\'' . $pl['name'] . '\',1,\'<table border=\\\'0\\\' width=\\\'100%\\\' cellspacing=\\\'0\\\' cellpadding=\\\'5\\\'><tr><td rowspan=2><img src=\\\'' . Config::img() . '/i/items/' . $pl['img'] . '\\\'></td><td align=\\\'left\\\'>Предмет <strong>' . $pl['name'] . '</strong> будет утерян, вы уверены ?</td></tr></table>\',\'' . intval(
$_GET['otdel']
) . Config::img() . ' / i / clear . gif"></a>';
}
}
}
//собираем все в одно (:
$rt[2] .= '<tr class="item"><td align="center" bgcolor="#' . $clr[$k] . '"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td width="100" align="center" style="border-right:#A5A5A5 1px solid; padding:5px;">' . $is1 . '</td><td valign="top" align="left" style="padding-left:3px; padding-bottom:3px; padding-top:7px;"><div align="left">' . $is2 . '</div></td></tr></table></td></tr>';
$rt[1] += $pl['massa'];
$i++;
}
$j++;
}
$rt[0] = $i;
$rt['collich'] = $j;
return $rt;
}
private function floordec($zahl, $decimals = 2): float|int
{
return floor($zahl * pow(10, $decimals)) / pow(10, $decimals);
}
private function shopSaleM($val, $itm): float
{
$procs = [
0, //0
0, //1
0, //2
0, //3
0, //4
0, //5
0, //6
0, //7
5,
30,
30,
30,
30,
30,
30,
30,
30,
30,
30,
30,
30,
30,
];
$po = Conversion::dataStringToArray($itm['data']);
$proc = $procs[$po['tr_lvl']];
//
if ($itm['type'] >= 28) {
$proc = 50;
}
if ($itm['type'] == 46) {
$proc = 0;
}
if (Config::get('shop_all') > 0) {
$proc = 100 - Config::get('shop_all');
} elseif (Config::get('shop_all_type1') > 0 && !isset($this->info['inBerezka'])) {
$proc = 100 - Config::get('shop_all_type1');
} elseif (Config::get('shop_all_type2') > 0 && isset($this->info['inBerezka'])) {
$proc = 100 - Config::get('shop_all_type2');
}
return round(($val / 100 * (100 - $proc)), 2);
}
public function round2($v): float|string
{
$v = explode('.', $v);
$v = doubleval($v[0] . '.' . $v[1][0] . $v[1][1]);
$f = explode('.', $v);
if (!isset($f[1])) {
$v = $v . '.00';
}
return $v;
}
public function berezCena(): float
{
return round((Config::get('shop_type2') / 100), 2);
}
public function testBattle($id): bool
{
return !($id == 0 || Db::getValue('select count(*) from battle where id = ? and team_win > -1', [$id]) > 0);
}
public function stack($id)
{
$where = '';
$itm = mysql_fetch_array(
mysql_query(
'SELECT
`im`.`id`,
`im`.`name`,
`im`.`img`,
`im`.`type`,
`im`.`inslot`,
`im`.`2h`,
`im`.`2too`,
`im`.`iznosMAXi`,
`im`.`inRazdel`,
`im`.`price1`,
`im`.`price2`,
`im`.`pricerep`,
`im`.`magic_chance`,
`im`.`info`,
`im`.`massa`,
`im`.`level`,
`im`.`magic_inci`,
`im`.`overTypei`,
`im`.`group`,
`im`.`group_max`,
`im`.`geni`,
`im`.`ts`,
`im`.`srok`,
`im`.`class`,
`im`.`class_point`,
`im`.`anti_class`,
`im`.`anti_class_point`,
`im`.`max_text`,
`im`.`useInBattle`,
`im`.`lbtl`,
`im`.`lvl_itm`,
`im`.`lvl_exp`,
`im`.`lvl_aexp`,
`iu`.`id`,
`iu`.`item_id`,
`iu`.`1price`,
`iu`.`2price`,
`iu`.`uid`,
`iu`.`use_text`,
`iu`.`data`,
`iu`.`inOdet`,
`iu`.`inShop`,
`iu`.`delete`,
`iu`.`iznosNOW`,
`iu`.`iznosMAX`,
`iu`.`gift`,
`iu`.`gtxt1`,
`iu`.`gtxt2`,
`iu`.`kolvo`,
`iu`.`geniration`,
`iu`.`magic_inc`,
`iu`.`maidin`,
`iu`.`lastUPD`,
`iu`.`timeOver`,
`iu`.`overType`,
`iu`.`secret_id`,
`iu`.`time_create`,
`iu`.`time_sleep`,
`iu`.`inGroup`,
`iu`.`dn_delete`,
`iu`.`inTransfer`,
`iu`.`post_delivery`,
`iu`.`lbtl_`,
`iu`.`bexp`,
`iu`.`so`,
`iu`.`blvl`, count(`iuu`.id) as inGroupCount
FROM `items_users` AS `iu`
LEFT JOIN `items_main` AS `im` ON (`im`.`id` = `iu`.`item_id`)
LEFT JOIN `items_users` as `iuu` ON (`iuu`.inGroup = `iu`.inGroup AND `iuu`.item_id = `im`.id AND `iuu`.inShop = 0)
WHERE `iu`.`id` = "' . mysql_real_escape_string(
(int)$id
) . '" AND `iu`.`uid` = "' . $this->info['id'] . '" AND `iuu`.`uid` = "' . $this->info['id'] . '" AND `iu`.`delete` = "0" AND `iu`.`inOdet` = "0" AND `iu`.`inShop` = "0" AND `im`.`group` = "1" LIMIT 1'
)
);
if (isset($itm['id']) && $itm['iznosNOW'] == 0) { //группируем похожие свободные предметы с этим
// создаем группу
if ($itm['inGroup'] == 0) { // Если предмет не в группе, собираем все похожие предметы по группам.
$items = mysql_num_rows(
mysql_query(
'SELECT `iu`.id, `iu`.inGroup, `iu`.`item_id` FROM `items_users` AS `iu` WHERE `iu`.`uid`="' . $this->info['id'] . '" AND `iu`.`delete`="0"AND `iu`.`inGroup`="0" AND `iu`.item_id="' . $itm['item_id'] . '"'
)
);
$items = ceil($items / $itm['group_max']);
} else { // Добираем предметы в группу до полного количества, из предметов с inGroup == 0
$curG = mysql_num_rows(
mysql_query(
'SELECT `iu`.id, `iu`.inGroup, `iu`.`item_id` FROM `items_users` AS `iu` WHERE `iu`.`uid`="' . $this->info['id'] . '" AND `iu`.`delete`="0"AND `iu`.`inGroup`="' . $itm['inGroup'] . '" AND `iu`.item_id="' . $itm['item_id'] . '"'
)
); // Текущее количество предметов в выбранной группе
$curNG = mysql_num_rows(
mysql_query(
'SELECT `iu`.id, `iu`.inGroup, `iu`.`item_id` FROM `items_users` AS `iu` WHERE `iu`.`uid`="' . $this->info['id'] . '" AND `iu`.`delete`="0"AND `iu`.`inGroup`="0" AND `iu`.item_id="' . $itm['item_id'] . '"'
)
); // Текущее количество предметов которые без группы
$needG = $itm['group_max'] - $curG; // Задаем требуемое количество для добора, если нужно больше 0 и требуемое количество меньше
if ($needG > 0 && $curNG == 0) {
$curItem = mysql_fetch_array(
mysql_query(
'SELECT `iu`.id, `iu`.inGroup, count(`iu`.inGroup) as itemsInGroup, `iu`.`item_id` FROM `items_users` AS `iu` WHERE `iu`.`inGroup`!="' . $itm['inGroup'] . '" AND `iu`.`uid`="' . $this->info['id'] . '" AND `iu`.`delete`="0" AND `iu`.item_id="' . $itm['item_id'] . '" GROUP BY `iu`.inGroup HAVING itemsInGroup <= "' . $needG . '" ORDER BY itemsInGroup DESC LIMIT 1'
)
);
if (isset($curItem['id'])) {
$where = ' `iu`.`inGroup` = "' . $curItem['inGroup'] . '" AND ';
}
}
$itm['group_max'] = $needG;
$items = 1;
}
$s = 0;
do {
if (!isset($curG) && $curNG == 0) {
$itm['inGroup'] = $this->stackGroupCheck($this->info['id'], $itm['inGroup'], $itm['item_id']);
}
$sp = mysql_query(
'SELECT `im`.`id`,
`im`.`name`,
`im`.`img`,
`im`.`type`,
`im`.`inslot`,
`im`.`2h`,
`im`.`2too`,
`im`.`iznosMAXi`,
`im`.`inRazdel`,
`im`.`price1`,
`im`.`price2`,
`im`.`pricerep`,
`im`.`magic_chance`,
`im`.`info`,
`im`.`massa`,
`im`.`level`,
`im`.`magic_inci`,
`im`.`overTypei`,
`im`.`group`,
`im`.`group_max`,
`im`.`geni`,
`im`.`ts`,
`im`.`srok`,
`im`.`class`,
`im`.`class_point`,
`im`.`anti_class`,
`im`.`anti_class_point`,
`im`.`max_text`,
`im`.`useInBattle`,
`im`.`lbtl`,
`im`.`lvl_itm`,
`im`.`lvl_exp`,
`im`.`lvl_aexp`,
`iu`.`id`,
`iu`.`item_id`,
`iu`.`1price`,
`iu`.`2price`,
`iu`.`uid`,
`iu`.`use_text`,
`iu`.`data`,
`iu`.`inOdet`,
`iu`.`inShop`,
`iu`.`delete`,
`iu`.`iznosNOW`,
`iu`.`iznosMAX`,
`iu`.`gift`,
`iu`.`gtxt1`,
`iu`.`gtxt2`,
`iu`.`kolvo`,
`iu`.`geniration`,
`iu`.`magic_inc`,
`iu`.`maidin`,
`iu`.`lastUPD`,
`iu`.`timeOver`,
`iu`.`overType`,
`iu`.`secret_id`,
`iu`.`time_create`,
`iu`.`time_sleep`,
`iu`.`inGroup`,
`iu`.`dn_delete`,
`iu`.`inTransfer`,
`iu`.`post_delivery`,
`iu`.`lbtl_`,
`iu`.`bexp`,
`iu`.`so`,
`iu`.`blvl` FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON (`im`.`id` = `iu`.`item_id`) WHERE ' . $where . ' `iu`.`kolvo` = "1" AND `iu`.`item_id` = "' . $itm['item_id'] . '" AND `iu`.`uid` = "' . $this->info['id'] . '" AND `iu`.`delete` = "0" AND `iu`.`inOdet` = "0" AND `iu`.`inShop` = "0" AND `im`.`group` = "1" ORDER BY `iu`.`inGroup` ASC LIMIT ' . $itm['group_max'] . ''
);
$i = 0;
$j = 0;
while ($pl = mysql_fetch_array($sp)) {
$pl['data'] = Conversion::dataStringToArray($pl['data']);
unset($pl['data']['frompisher']);
$pl['data'] = Conversion::arrayToDataString($pl['data']);
$itm['data'] = Conversion::dataStringToArray($itm['data']);
unset($itm['data']['frompisher']);
$itm['data'] = Conversion::arrayToDataString($itm['data']);
if ($pl['data'] == $itm['data'] && $pl['name'] == $itm['name'] && $itm['iznosMAX'] == $pl['iznosMAX'] && $pl['iznosNOW'] == 0 && ($pl['timeOver'] == 0 || $pl['timeOver'] > time()) && $pl['gift'] == $itm['gift']) {
$upd = mysql_query(
'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `inGroup` = "' . $itm['inGroup'] . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1'
);
if ($upd) {
$j++;
}
$i++;
}
}
mysql_query(
'UPDATE `items_users` SET `lastUPD` = "' . time() . '" WHERE `id` = "' . $itm['id'] . '" LIMIT 1'
);
$s++;
} while ($s < $items);
}
}
private function stackGroupCheck($uid, $group, $item): int
{ // Находит неиспользованный ID группы предметов.
$g = 0;
$i = 0;
do { //fixme ужасный цикл, ужасный запрос.
$i++;
$gr = Db::getValue('select inGroup from items_users where uid = ? and inGroup = ? and item_id = ?', [$uid, $i, $item]);
if (empty($gr)) {
$g = 1;
}
} while ($g == 0);
return $i;
}
public function testItems($uid, $sn, $dt)
{
if ($uid != $this->info['id']) {
$u = self::getInfo($uid);
if ($sn == 0) {
$sn = $this->getStats($uid);
}
} else {
$u = $this->info;
if (isset($this->stats['hpAll'])) {
$sn = $this->stats;
} elseif ($sn == 0) {
$sn = $this->getStats($uid);
}
}
if (!isset($u['id'])) {
return 0;
}
$snIt = 0;
//Проверяем одетые вещи и вещи с сроком годности
$itm = Db::getRow("select
items_main.id,
items_users.id as iduid,
data,
type,
price2,
2price,
srok,
item_id,
time_create,
time_sleep,
timeOver,
name,
overType,
inOdet,
iznosNOW,
iznosMAX,
iznosMAXi
from items_users
left join items_main on items_main.id = item_id
where
(
inOdet != 0 or
data like '%srok%' or
data like '%vip_sale%' or
data like '%sudba=1%' or
iznosNOW > 0 or
srok > 0 or
(timeOver !=0 and timeOver < unix_timestamp())
) and uid = ?",
[$u['id']]);
$t = $this->items['tr'];
$x = 0;
$notr = 0;
if (empty($itm['data'])) {
if ($this->info['twink'] > 0) {
//Не дороже 100 екр.
if ($itm['price2'] > 1 || $itm['2price'] > 1) {
$notr++;
}
}
if ($itm['iznosNOW'] >= ceil($itm['iznosMAX']) && $itm['iznosMAXi'] != 999999999) {
$notr++;
}
if ($notr > 0 && $itm['inOdet'] != 0) {
//снимаем предмет
$this->snatItem($itm['id'], $u['id']);
$snIt++;
}
} else {
$po = Conversion::dataStringToArray($itm['data']);
$po['lvl'] = $u['level'];
//проверяем требования
$j = 1;
while ($j <= 4) {
if (!isset($po['tr_s' . $j]) && $itm['type'] != 26) {
$po['tr_s' . $j] = 0;
}
$j++;
}
while ($x < count($t)) {
$n = $t[$x];
if (isset($po['tr_' . $n]) && $n == 'sex') {
if ($po['tr_' . $n] != $this->info['sex']) {
$notr++;
}
} elseif (isset($po['tr_' . $n])) {
if ($po['tr_' . $n] > $this->stats[$n] && $n != 'align' && $n != 'align_bs') {
$notr++;
}
}
$x++;
}
if ($this->info['twink'] > 0) {
//Не дороже 100 екр.
if ($itm['price2'] > 1 || $itm['2price'] > 1) {
$notr++;
}
//Нельзя руны + чарки
if (isset($po['rune']) && $po['rune'] > 0) {
$notr++;
}
if (isset($po['spell_id']) && $po['spell_id'] > 0) {
$notr++;
}
}
if (isset($po['sudba']) && $po['sudba'] == 1) {
$po['sudba'] = $u['login'];
Db::sql('update items_users set data = ? where id = ? and uid = ?', [Conversion::arrayToDataString($po), $itm['iduid'], $u['id']]);
}
if (isset($po['srok']) && $po['srok'] > 0) {
$itm['srok'] = $po['srok'];
}
if (isset($po['vip_sale']) && $sn['silver'] < 2 && ($itm['time_create'] - time()) < 0) {
if ($itm['item_id'] == 4704) {
$po['musor2'] = 4708;
}
ItemsModel::itemDecay($itm['id'], $itm['overType'], $u['id'], (int)$po['musor2'], $itm['type'], $itm['name']);
$notr++;
}
if ($itm['iznosNOW'] >= ceil($itm['iznosMAX']) && $itm['iznosMAXi'] != 999999999) {
$notr++;
}
if ($notr > 0 && $itm['inOdet'] != 0) {
//снимаем предмет
$this->snatItem($itm['id'], $u['id']);
$snIt++;
}
//проверяем срок годности
if ($itm['iznosNOW'] >= ceil($itm['iznosMAX']) && $itm['iznosMAXi'] != 999999999 && isset($po['musor']) && $po['musor'] > 0) {
//предмет сломался
$this->itemDestroy($itm['id'], $u['id'], (int)$po['musor']);
}
if ($itm['time_create'] + $itm['srok'] <= time() && $itm['srok'] > 0 && $itm['time_sleep'] == 0) {
if ($itm['inOdet'] != 0) {
$this->snatItem($itm['id'], $u['id']);
$snIt++;
}
//удаляем предмет
if ($itm['item_id'] == 4704) {
$po['musor2'] = 4708;
}
ItemsModel::itemDecay($itm['id'], $itm['overType'], $u['id'], (int)$po['musor2'], $itm['type'], $itm['name']);
}
}
if ($snIt > 0) {
$this->testItems($uid, $sn, 1);
} elseif ($dt == 0) {
return -2;
}
}
public function snatItem(?int $id, int $uid = 0): int
{
if (empty($id)) {
return 0;
}
$sql = 'select count(*) from items_users where id = ? and inOdet != 0';
$args = [$id];
if ($uid > 0) {
$sql .= ' and uid = ?';
$args[] = $uid;
}
if (empty(Db::getValue($sql, $args))) {
return 0;
}
Db::sql('update items_users set lastUPD = unix_timestamp(), inOdet = 0 where id = ?', [$id]);
if (isset($_GET['remitem']) || isset($_GET['sid'])) {
$this->info['autospell'] = 1;
Db::sql('update users set autospell = 1 where id = ?', [$this->info['id']]);
}
return 1;
}
private function itemDestroy(int $id, int $uid = 0, int $id2 = 0): void
{
if ($id == 0) {
return;
}
$sql = 'delete from items_users where id = ?';
$args = [$id];
if ($uid > 0) {
$sql .= ' and uid = ?';
$args[] = $uid;
}
Db::sql($sql, $args);
Delo::add(2, 'system.inventory', $uid, "Предмет [id:$id] был сломан.");
if ($id2 > 1) {
//Добавляем пустую бутылку
ItemsModel::addItem($id2, $uid, 'noodet=1|noremont=1');
}
}
public function btlMagicList(): string
{
$sv = array_fill(1, 10, '<img class="nopriemuse" title="Пустой слот магия" src="' . Config::img() . '/i/items/w/w101.gif" alt="">');
foreach ($this->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] = "<img alt='' '$vl' title='$iznos' src='$img'>";
}
$r = '<table style="border:0;border-spacing:0;border-collapse:collapse;">' .
'<tr>' .
'<td>' . $sv[1] . '</td>' .
'<td>' . $sv[2] . '</td>' .
'<td>' . $sv[3] . '</td>' .
'<td>' . $sv[4] . '</td>' .
'<td>' . $sv[5] . '</td>' .
'<td>' . $sv[6] . '</td>' .
'<td>' . $sv[7] . '</td>' .
'<td>' . $sv[8] . '</td>' .
'<td>' . $sv[9] . '</td>' .
'<td>' . $sv[10] . '</td>' .
'<td>' . $sv[11] . '</td>' .
'<td>' . $sv[12] . '</td>' .
'</tr>' .
'</table>';
return str_replace('"', '\"', $r);
}
/** Отрисовка коробочки персонажа с логином. */
public function getInfoPers($uid, $i1, $sn = 0, $ivv = 0): array
{
if (empty($this->infoBox)) {
$this->infoBox = new InfoBox($this); //fixme почему-то не дружит с конструктором.
}
return $this->infoBox->getInfoPers($uid, $i1, $sn, $ivv);
}
public function endEffect($id, $u): int
{
$e = Db::getRow('select id, uid, id_eff, name, sleeptime, data, type1 from eff_users left join eff_main on id_eff = id2 where id = ? and deactiveTime < unix_timestamp()', [$id]);
if (!isset($e['id'])) {
return 0;
}
$sleep = $this->testAction('`vars` = "sleep" AND `uid` = "' . $e['uid'] . '" LIMIT 1', 1);
if ($e['id_eff'] == 2) {
//Проверка
$et = Db::getRow("select id, time from actions where uid = ? and vars like '%read%' and vals = (select id from items_main where name = ? limit 1)",
[$e['uid'], str_replace('Изучение: ', '', $e['name'])]);
$et = isset($et['id']) && $et['time'] >= time();
} else {
$et = false;
}
if ($et || $e['sleeptime'] != 0 || $sleep['vars'] == 'sleep') {
return 0;
}
Effects::removeById($e['uid'], $e['id']);
$po = Conversion::dataStringToArray($e['data']);
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();
$cmsg->setRoom($u['room']);
$cmsg->setTo($u['login']);
$cmsg->setText($text);
$cmsg->setType(6);
(new Chat())->sendMsg($cmsg);
if ($u['battle'] > 0) {
$lastHOD = Db::getValue('select if(type != 6, id_hod + 1, id_hod) as id_hod from battle_logs where battle = ? order by id_hod desc limit 1', [$u['battle']]);
if (!empty($lastHOD)) {
Db::sql("insert into battle_logs (time, battle, id_hod, text, vars, zona1, zonb1, zona2, zonb2, type) values (unix_timestamp(),?,?,?,?,'','','','',6)",
[$u['battle'], $lastHOD, "{tm1}$text у игрока {u1}", "login1={$u['login']}||t1={$u['team']}||time=" . time()]);
}
}
}
return 1;
}
public function info_remont(): string
{
$r = '';
$sp = Db::getRows('select iznosNOW, iznosMAX, name from items_users left join items_main on item_id = items_main.id where uid = ? and inShop = 0 and inOdet between 1 and 18 limit 18',
[$this->info['id']]);
foreach ($sp as $pl) {
if ($pl['iznosNOW'] <= ceil($pl['iznosMAX'] * 0.80)) {
continue;
}
$r .= '<strong>' . $pl['name'] . '</strong> [<span style="color: brown">' . floor($pl['iznosNOW']) . '/' .
ceil($pl['iznosMAX']) . '</span>] требуется ремонт<br>';
}
return '<div style="font-size: smaller;">' . $r . '</div>';
}
public function snatItemAll(int $uid): int
{
if ($uid < 1) {
return 0;
}
Db::sql('update items_users set lastUPD = unix_timestamp(), inOdet = 0 where inOdet != 0 and uid = ?', [$uid]);
return 1;
}
public function odetItem(int $id, int $uid)
{
$sql = "select items_users.id, data, 2price, inGroup, gift, gtxt1, `group`, price2, name, type, inslot, 2too, 2h
from items_users
left join items_main on item_id = items_main.id
where items_users.id = ? and inOdet = 0 and inShop = 0";
$args = [$id];
if ($uid) {
$sql .= ' and items_users.uid = ?';
$args[] = $uid;
}
$itm = Db::getRow($sql, $args);
unset($sql, $args);
if (isset($itm['id'])) {
if ($itm['group'] == 1 && $this->itemsX($itm['id']) > 1) {
$this->unstack($itm['id'], 1);
}
$tr = Conversion::dataStringToArray($itm['data']);
$notr = $this->trItem($tr);
$msb = '';
if (
isset($tr['maks_itm_one']) &&
$tr['maks_itm_one'] > 0 &&
Db::getValue('select true from items_users where uid = ? and inOdet > 0 and data like ? limit 1', [$this->info['id'], "%maks_itm_one={$tr['maks_itm_one']}%"])
) {
$this->error = 'Возможное использование максимум одного предмета!';
$notr++;
}
if ($this->info['twink'] > 0) {
//Не дороже 100 екр.
if ($itm['price2'] > 100 || $itm['2price'] > 100) {
$notr++;
}
//Нельзя руны + чарки
if (isset($tr['rune']) && $tr['rune'] > 0) {
$notr++;
}
if (isset($tr['spell_id']) && $tr['spell_id'] > 0) {
$notr++;
}
}
if (isset($tr['vip_sale']) && $this->stats['silver'] < 2) {
$notr++;
}
if (isset($tr['sudba'])) {
if ($tr['sudba'] != '0' && $tr['sudba'] != $this->info['login']) {
$notr++;
} elseif ($tr['sudba'] == '0') {
$tr['sudba'] = $this->info['login'];
$itm['data'] = Conversion::arrayToDataString($tr);
$msb = ',`data`="' . $itm['data'] . '"';
}
}
if (isset($tr['tr_align_bs']) && $this->info['inTurnir'] > 0) {
if ($tr['tr_align_bs'] == '1') {
if ($this->info['align_real'] <= 1 || $this->info['align_real'] >= 2) {
$notr++;
} else {
$notr = 0;
}
} else {
if ($this->info['align_real'] <= 3 || $this->info['align_real'] >= 4) {
$notr++;
} else {
$notr = 0;
}
}
}
if ($notr > 0) {
//Не хватает характеристик или не совпадают условия
$this->error = isset($tr['open']) && isset($_GET['open']) ? 'Вы не можете открыть данный предмет' : 'Нельзя одеть больше одного предмета данного типа';
return 0;
} elseif (isset($tr['open']) && isset($_GET['open']) && isset($tr['items_in_file'])) {
$io = '';
if ($itm['inGroup'] > 0) {
Db::sql('update items_users set lastUPD = unix_timestamp(), inGroup = 0 where id = ?', [$itm['id']]);
}
if (file_exists('_incl_data/class/Magic/' . $tr['items_in_file'] . '.php')) {
require_once '_incl_data/class/Magic/' . $tr['items_in_file'] . '.php';
if (!isset($no_open_itm)) {
$this->deleteItem($itm['id'], $this->info['id']);
$this->error = 'Вы успешно открыли &quot;' . $itm['name'] . '&quot;:<br>' . $io . '...';
} else {
unset($no_open_itm);
}
} else {
$this->error = 'Предмет &quot;' . $itm['name'] . '&quot; невозможно открыть...';
}
} elseif (isset($tr['open']) && isset($_GET['open'])) {
//открываем предмет
$io = '';
$i = 0;
$itms = explode(',', $tr['items_in']);
if ($itm['type'] == 37) {
//Распаковываем упаковку
$itmin = Db::getRow('select * from items_users where id = ?', [$tr['item_inbox']]);
$itmmn = Db::getRow('select * from items_main where id = ?', [$itmin['item_id']]);
//
if ($itm['gift'] == '' || $itm['gift'] == '0') {
$this->error = 'Предмет должен быть подарен, прежде чем его открывать!';
} elseif (!isset($itmin['id'])) {
$this->error = 'В упаковке ничего нет, скорее всего предмет кто-то вытащил от туда...';
} else {
$io .= $itmmn['name'];
if ($itmin['item_id'] == 4867) {
//Не откроешь
$this->deleteItem($itm['id'], $this->info['id']);
$this->deleteItem($itmin['id'], $this->info['id']);
$this->error = 'Не удалось открыть подарок. Содержимое испорчено.';
} elseif ($itmin['item_id'] == 4868) {
//Летучая мышь
Db::sql('update stats set hpNow = 1, mpNow = 1 where id = ?', [$this->info['id']]);
$this->deleteItem($itm['id'], $this->info['id']);
$this->deleteItem($itmin['id'], $this->info['id']);
$this->error = 'Вы потеряли все HP...';
} elseif ($itmin['item_id'] == 4870) {
//Минута молчания
Db::sql('update users set molch1 = if(molch1 > unix_timestamp(), molch1 + 3600, unix_timestamp() + 3600) where id = ?', [$this->info['id']]);
$this->deleteItem($itm['id'], $this->info['id']);
$this->deleteItem($itmin['id'], $this->info['id']);
$this->error = 'Вы оказались под действие заклятия молчания...';
} elseif ($itmin['item_id'] == 4873) {
//Крысиный яд
$a = Db::getValue('select name from users_animal where uid = ? and id = ? and pet_in_cage = 0', [$this->info['id'], $this->info['animal']]);
$this->deleteItem($itm['id'], $this->info['id']);
$this->deleteItem($itmin['id'], $this->info['id']);
if ($a) {
$this->error = 'Ваш зверь &quot;' . $a . '&quot; странно позеленел...';
Db::sql('update users_animal set eda = 0, yad = unix_timestamp() + 7 * 86400 where id = ?', [$this->info['animal']]);
} else {
$this->error = 'Кто-то пытался отравить вашего зверя, которого у вас нет :)';
}
} elseif ($itmin['item_id'] == 4869) {
//Неасчастный случай (легкая травма на 1 час)
$this->deleteItem($itm['id'], $this->info['id']);
$this->deleteItem($itmin['id'], $this->info['id']);
mysql_query(
'INSERT INTO `eff_users`
(`overType`,`timeUse`,`hod`,`name`,`data`,`uid`, `id_eff`, `img2`, `timeAce`, `v1`) VALUES (
"0","' . (time() + 3600) . '","-1",
"Неверие в человечество","add_s' . rand(1, 3) . '=-' . rand(
5, 15
) . '","' . $this->info['id'] . '",
"4", "bad_present_travma1.gif","0", "1"
)'
);
$this->error = 'Вы травмированы. В том числе и физически...';
} elseif ($itmin['item_id'] == 4872) {
//Трагедия (средняя травма на 1 час)
$this->deleteItem($itm['id'], $this->info['id']);
$this->deleteItem($itmin['id'], $this->info['id']);
mysql_query(
'INSERT INTO `eff_users`
(`overType`,`timeUse`,`hod`,`name`,`data`,`uid`, `id_eff`, `img2`, `timeAce`, `v1`) VALUES (
"0","' . (time() + 3600) . '","-1",
"Неверие в человечество","add_s' . rand(1, 3) . '=-' . rand(
16, 25
) . '","' . $this->info['id'] . '",
"4", "bad_present_travma2.gif","0", "2"
)'
);
$this->error = 'Вы травмированы. В том числе и физически...';
} elseif ($itmin['item_id'] == 4876) {
//Катастрофа (тяжелая травма на 1 час)
$this->deleteItem($itm['id'], $this->info['id']);
$this->deleteItem($itmin['id'], $this->info['id']);
mysql_query(
'INSERT INTO `eff_users`
(`overType`,`timeUse`,`hod`,`name`,`data`,`uid`, `id_eff`, `img2`, `timeAce`, `v1`) VALUES (
"0","' . (time() + 3600) . '","-1",
"Неверие в человечество","add_s' . rand(1, 3) . '=-' . rand(
26, 35
) . '","' . $this->info['id'] . '",
"4", "bad_present_travma3.gif","0", "3"
)'
);
$this->error = 'Вы травмированы. В том числе и физически...';
} elseif ($itmin['item_id'] == 4878) {
//Недвижимость (add_puti=7200)
$this->deleteItem($itm['id'], $this->info['id']);
$this->deleteItem($itmin['id'], $this->info['id']);
mysql_query(
'INSERT INTO `eff_users`
(`overType`,`timeUse`,`hod`,`name`,`data`,`uid`, `id_eff`, `img2`, `timeAce`, `v1`) VALUES (
"0","' . (time() + 7200) . '","-1",
"Недвижимость","add_puti=1","' . $this->info['id'] . '",
"4", "bad_present_chains.gif","0", "3"
)'
);
$this->error = 'Вы не можете передвигаться...';
} elseif ($itmin['item_id'] == 4874) {
//Сюрприз для мага на час
$this->deleteItem($itm['id'], $this->info['id']);
$this->deleteItem($itmin['id'], $this->info['id']);
mysql_query(
'INSERT INTO `eff_users`
(`overType`,`timeUse`,`hod`,`name`,`data`,`uid`, `id_eff`, `img2`, `timeAce`, `v1`) VALUES (
"0","' . (time() + 3600) . '","-1",
"Сюрприз для Мага","add_s5=-50","' . $this->info['id'] . '",
"4", "bad_present_dmage.gif","0", "3"
)'
);
$this->error = 'Вам нехорошо...';
} elseif ($itmin['item_id'] == 4871) {
//Сюрприз для воина на час
$this->deleteItem($itm['id'], $this->info['id']);
$this->deleteItem($itmin['id'], $this->info['id']);
mysql_query(
'INSERT INTO `eff_users`
(`overType`,`timeUse`,`hod`,`name`,`data`,`uid`, `id_eff`, `img2`, `timeAce`, `v1`) VALUES (
"0","' . (time() + 3600) . '","-1",
"Сюрприз для Воина","add_s1=-50","' . $this->info['id'] . '",
"4", "bad_present_dfighter.gif","0", "3"
)'
);
$this->error = 'Вам нехорошо...';
} elseif (mysql_query(
'UPDATE `items_users` SET `uid` = "' . $this->info['id'] . '",`lastUPD` = "' . time() . '",`gift` = "' . $itm['gift'] . '",`gtxt1` = "' . $itm['gtxt1'] . '",`gtxt2` = "Предмет из упаковки. Дата запаковки: ' . date(
'd.m.Y H:i:s', $itmin['time_create']
) . '" WHERE `id` = "' . $itmin['id'] . '" LIMIT 1'
)) {
//Удаляем упаковку
$this->deleteItem($itm['id'], $this->info['id']);
$this->error = 'Вы успешно открыли &quot;' . $itm['name'] . '&quot;, внутри было найдено:<br>' . $io . '...';
} else {
$this->error = 'Неудалось открыть подарок, что же там?';
}
//
}
//
} else {
while ($i < count($itms)) {
if (isset($itms[$i])) {
$x = 0;
$itms[$i] = explode('*', $itms[$i]);
$x += (int)$itms[$i][1];
$itms[$i] = $itms[$i][0];
$s = mysql_fetch_array(
mysql_query(
'SELECT `id`,`name`,`img`,`type`,`inslot`,`2h`,`2too`,`iznosMAXi`,`inRazdel`,`price1`,`price2`,`price3`,`magic_chance`,`info`,`massa`,`level`,`magic_inci`,`overTypei`,`group`,`group_max`,`geni`,`ts`,`srok`,`class`,`class_point`,`anti_class`,`anti_class_point`,`max_text`,`useInBattle`,`lbtl`,`lvl_itm`,`lvl_exp`,`lvl_aexp` FROM `items_main` WHERE `id`="' . ((int)$itms[$i]) . '" LIMIT 1'
)
);
if (isset($s['id'])) {
$j = 1;
while ($j <= $x) {
$pid = ItemsModel::addItem($s['id'], $this->info['id']);
if ($pid > 0) {
mysql_query(
'UPDATE `items_users` SET `lastUPD` = "' . time() . '",`gift` = "' . $itm['gift'] . '" WHERE `id` = "' . $pid . '" AND `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
}
$j++;
}
$io .= '' . $s['name'] . ' (x' . $x . '), ';
}
}
$i++;
}
if ($itm['inGroup'] > 0) {
mysql_query(
'UPDATE `items_users` SET `lastUPD` = "' . time() . '",`inGroup` = "0", `delete` = "0" WHERE `id` = "' . $itm['id'] . '" LIMIT 1'
);
}
$this->deleteItem($itm['id'], $this->info['id']);
$this->error = 'Вы успешно открыли &quot;' . $itm['name'] . '&quot;, внутри было найдено:<br>' . $io . '...';
}
} else {
$inSlot = $itm['inslot'];
$s = mysql_query(
'SELECT `iu`.`id`,
`iu`.`inOdet` FROM `items_users` AS `iu` WHERE `iu`.`inOdet`!="0" AND `iu`.`uid`="' . $uid . '" AND `iu`.`delete`="0"'
);
$d = [];
while ($p = mysql_fetch_array($s)) {
$d[$p['inOdet']] = $p['id'];
}
//Если в слот оружия и можно одеть в левую руку
if ($itm['2too'] == 1 && $inSlot == 3 && isset($d[3])) {
$inSlot = 14;
}
if ($inSlot == 3 || $inSlot == 14) {
//Проверяем есть-ли двуручное оружие
//И естественно снимаем его, даже если руки пусты, отправляя туда NULL и ломая игру. Сука!
if ($this->stats['items'][$this->stats['wp3id']]['2h'] == 1 || $this->stats['items'][$this->stats['wp14id']]['2h'] == 1 || $itm['2h'] == 1) {
$this->snatItem($this->stats['items'][$this->stats['wp3id']]['id'], $uid);
$this->snatItem($this->stats['items'][$this->stats['wp14id']]['id'], $uid);
}
}
if (isset($d[$inSlot])) {
if ($inSlot == 10) {
if (!isset($d[12])) {
$inSlot = 12;
} elseif (!isset($d[11])) {
$inSlot = 11;
}
} elseif ($inSlot == 40) {
$i = 40;
while ($i <= 51) {
if (!isset($d[$i])) {
$inSlot = $i;
$i = 52;
} elseif ($i == 50) {
$inSlot = 50;
}
$i++;
}
} elseif ($inSlot == 53) {
if (!isset($d[53])) {
$inSlot = 53;
} elseif (!isset($d[54])) {
$inSlot = 54;
}
} elseif ($inSlot == 56) {
if (!isset($d[56])) {
$inSlot = 56;
} elseif (!isset($d[57])) {
$inSlot = 57;
} elseif (!isset($d[58])) {
$inSlot = 58;
} else {
$inSlot = 58;
}
} elseif ($inSlot == 59) {
if (!isset($d[59])) {
$inSlot = 59;
} elseif (!isset($d[60])) {
$inSlot = 60;
} elseif (!isset($d[61])) {
$inSlot = 61;
} elseif (!isset($d[62])) {
$inSlot = 62;
}
}
}
if (isset($d[$inSlot])) {
$this->snatItem($d[$inSlot], $uid);
}
$upd = mysql_query(
'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `inOdet` = "' . $inSlot . '"' . $msb . ' WHERE `id` = "' . $itm['id'] . '" LIMIT 1'
);
if ($itm['inGroup'] > 0) {
mysql_query(
'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `inGroup` = 0, `delete` = 0 WHERE `id` = "' . $itm['id'] . '" LIMIT 1'
);
}
if ($upd) {
//Если предмет привязывается после одевания
$this->info['autospell'] = 1;
mysql_query(
'UPDATE `users` SET `autospell` = "1" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1'
);
return 1;
} else {
$this->error = '(!) Ошибка обновления данных';
return 0;
}
}
} else {
$this->error = 'Предмет не найден в вашем рюкзаке';
return 0;
}
}
public function unstack($id, $x = null)
{
$id = (int)$id;
$itm = mysql_fetch_array(
mysql_query(
'SELECT `iu`.id, `iu`.inGroup, `im`.`id` as item_id,
`im`.`name`, count(`iuu`.id) as inGroupCount
FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON (`im`.`id` = `iu`.`item_id`) LEFT JOIN `items_users` as `iuu` ON (`iuu`.inGroup = `iu`.inGroup AND `iuu`.item_id = `im`.id )
WHERE `iuu`.`uid`="' . $this->info['id'] . '" AND `iu`.`uid`="' . $this->info['id'] . '" AND `iu`.`delete`="0" AND `im`.`group` = "1" AND `iu`.`inOdet`="0" AND `iu`.`inShop`="0" AND `iu`.id=' . mysql_real_escape_string(
(int)$id
) . '
ORDER BY `iu`.lastUPD DESC
LIMIT 1'
)
);
if (isset($itm['id']) && $itm['inGroup'] > 0 && $itm['inGroupCount'] > 0) {
if ($x == 0 or $x == null) {
$x = $this->itemsX($itm['id']); //кол-во распада
$inGroup = 0;
} elseif ($x != 0) {
$inGroup = $this->stackGroupCheck($this->info['id'], $itm['inGroup'], $itm['item_id']);
} else {
$inGroup = 0;
}
$sp = mysql_query(
'SELECT `im`.`id`,
`im`.`name`,
`im`.`img`,
`im`.`type`,
`im`.`inslot`,
`im`.`2h`,
`im`.`2too`,
`im`.`iznosMAXi`,
`im`.`inRazdel`,
`im`.`price1`,
`im`.`price2`,
`im`.`pricerep`,
`im`.`magic_chance`,
`im`.`info`,
`im`.`massa`,
`im`.`level`,
`im`.`magic_inci`,
`im`.`overTypei`,
`im`.`group`,
`im`.`group_max`,
`im`.`geni`,
`im`.`ts`,
`im`.`srok`,
`im`.`class`,
`im`.`class_point`,
`im`.`anti_class`,
`im`.`anti_class_point`,
`im`.`max_text`,
`im`.`useInBattle`,
`im`.`lbtl`,
`im`.`lvl_itm`,
`im`.`lvl_exp`,
`im`.`lvl_aexp`,
`iu`.`id`,
`iu`.`item_id`,
`iu`.`1price`,
`iu`.`2price`,
`iu`.`uid`,
`iu`.`use_text`,
`iu`.`data`,
`iu`.`inOdet`,
`iu`.`inShop`,
`iu`.`delete`,
`iu`.`iznosNOW`,
`iu`.`iznosMAX`,
`iu`.`gift`,
`iu`.`gtxt1`,
`iu`.`gtxt2`,
`iu`.`kolvo`,
`iu`.`geniration`,
`iu`.`magic_inc`,
`iu`.`maidin`,
`iu`.`lastUPD`,
`iu`.`timeOver`,
`iu`.`overType`,
`iu`.`secret_id`,
`iu`.`time_create`,
`iu`.`time_sleep`,
`iu`.`inGroup`,
`iu`.`dn_delete`,
`iu`.`inTransfer`,
`iu`.`post_delivery`,
`iu`.`lbtl_`,
`iu`.`bexp`,
`iu`.`so`,
`iu`.`blvl` FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON (`im`.`id` = `iu`.`item_id`) WHERE `iu`.`uid` = "' . $this->info['id'] . '" AND `iu`.`delete` = "0" AND `iu`.`inGroup` = "' . $itm['inGroup'] . '" AND `iu`.`item_id` = "' . $itm['item_id'] . '" AND `iu`.`inOdet` = "0" AND `iu`.`inShop` = "0" AND `im`.`group` = "1" LIMIT ' . $x . ''
);
$i = 0;
$j = 0;
while ($pl = mysql_fetch_array($sp)) {
$upd = mysql_query(
'UPDATE `items_users` SET `inGroup` = "' . $inGroup . '", `lastUPD` = "' . time() . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1'
);
if ($upd) {
$j++;
}
$i++;
}
if ($this->itemsX($itm['id']) == 1) {
mysql_query(
'UPDATE `items_users` SET `inGroup` = "0", `lastUPD` = "' . time() . '" WHERE `id` = "' . $itm['id'] . '" LIMIT 1'
);
}
if ($this->itemsX($pl['id']) == 1) {
mysql_query(
'UPDATE `items_users` SET `inGroup` = "0", `lastUPD` = "' . time() . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1'
);
}
}
}
private function trItem($po)
{
$tr = '';
$t = $this->items['tr'];
$x = 0;
$notr = 0;
while ($x < count($t)) {
$n = $t[$x];
if (isset($po['tr_' . $n])) {
if ($n == 'sex') {
if ($this->info['sex'] != $po['tr_' . $n]) {
$notr++;
}
} elseif ($po['tr_' . $n] > $this->stats[$n] && $n != 'align') {
$notr++;
}
}
$x++;
}
return $notr;
}
public function deleteItem($id, $uid = 0, $coldel = 0)
{
if ($uid != 0) {
$au = 'AND `iu`.`uid`="' . mysql_real_escape_string($uid) . '"';
} else {
$au = '';
}
$itm = mysql_fetch_array(
mysql_query(
'SELECT `im`.*,
`iu`.*
FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON (`im`.`id` = `iu`.`item_id`) WHERE `iu`.`id`="' . mysql_real_escape_string(
$id
) . '" AND `iu`.`inOdet`="0" AND `iu`.`inShop`="0" ' . $au . ' AND (`iu`.`delete`="0" OR `iu`.`delete`="1000") LIMIT 1'
)
);
if (isset($itm['id'])) {
if ($coldel == 0) {
//Удаляем целиком
$upd = mysql_query(
'UPDATE `items_users` SET `lastUPD`="' . time() . '",`delete`="' . time() . '" WHERE `id`="' . $itm['id'] . '" LIMIT 1'
);
$col = $this->itemsX($itm['id']);
if ($col > 0) {
mysql_query(
'UPDATE `items_users` SET `lastUPD`="' . time() . '",`delete`="' . time() . '",`inGroup` = "0" WHERE `inGroup`="' . $itm['id'] . '" LIMIT ' . $col
);
}
} else {
//Удаляем конкретное кол-во
$col = $this->itemsX($itm['id']);
if ($col > 1) {
if ($col <= $coldel) {
mysql_query(
'UPDATE `items_users` SET `lastUPD`="' . time() . '",`delete`="' . time() . '" WHERE `id`="' . $itm['id'] . '" LIMIT 1'
);
}
mysql_query(
'UPDATE `items_users` SET `lastUPD`="' . time() . '",`delete`="' . time() . '",`inGroup` = "0" WHERE `inGroup`="' . $itm['id'] . '" AND `delete` = "1000" LIMIT ' . $coldel
);
} else {
//Удаляем целиком
mysql_query(
'UPDATE `items_users` SET `lastUPD`="' . time() . '",`delete`="' . time() . '" WHERE `id`="' . $itm['id'] . '" LIMIT 1'
);
mysql_query(
'UPDATE `items_users` SET `lastUPD`="' . time() . '",`delete`="' . time() . '",`inGroup` = "0" WHERE `inGroup`="' . $itm['id'] . '" AND `delete` = "1000" LIMIT ' . $col
);
}
}
if (isset($_GET['deleteall7'])) {
$st = Conversion::dataStringToArray($itm['data']);
$whr = '';
if (isset($st['frompisher'])) {
$whr .= 'AND `data` LIKE "%frompisher=' . $st['frompisher'] . '%"';
}
$col = mysql_fetch_array(
mysql_query(
'SELECT COUNT(*) FROM `items_users` WHERE `item_id`="' . $itm['item_id'] . '" AND `inOdet` = 0 AND `delete` < 100000 AND `uid` = "' . $itm['uid'] . '" AND `data` NOT LIKE "%nodelete%"' . $whr
)
);
$col = $col[0];
mysql_query(
'UPDATE `items_users` SET `lastUPD`="' . time() . '",`delete`="' . time() . '" WHERE `item_id`="' . $itm['item_id'] . '" AND `inOdet` = 0 AND `delete` < 100000 AND `uid` = "' . $itm['uid'] . '" AND `data` NOT LIKE "%nodelete%"' . $whr
);
$this->error = 'Предметы "' . $itm['name'] . ' (x' . ($col + 1) . ')" выброшены';
Delo::add(
1,
'System.inventory',
$uid,
'&quot;<span style="color: maroon; ">System.inventory</span>&quot;: Предметы &quot;<strong>' . $itm['name'] . ' (x' . $col . ')</strong>&quot; [itm:' . $itm['id'] . '=' . time() . '] были <strong>выброшены</strong>.',
);
} else {
$this->error = 'Предмет "' . $itm['name'] . '" выброшен';
Delo::add(
1,
'System.inventory',
$uid,
'&quot;<span style="color: maroon; ">System.inventory</span>&quot;: Предмет &quot;<strong>' . $itm['name'] . '</strong>&quot; [itm:' . $itm['id'] . '] был <strong>выброшен</strong>.',
);
}
return 1;
} else {
$this->error = 'Предмет не найден в вашем рюкзаке';
}
}
public function testLevel()
{
$rt = 0;
if ($this->info['expstopu'] > 2 && $this->info['exp'] > Config::get('expstopu')) {
$this->info['exp'] = Config::get('expstopu');
Db::sql('update stats set exp = ? where id = ?', [Config::get('expstopu'), $this->info['id']]);
} elseif ($this->info['exp'] > Config::get('expstop') && $this->info['expstopu'] < 3) {
//upexpdate
if ($this->info['upexpdate'] == 0) {
$this->info['upexpdate'] = time();
Db::sql('update stats set upexpdate = unix_timestamp() where id = ?', [$this->info['id']]);
} elseif (time() >= ($this->info['upexpdate'] + 400 * 60 * 60 * 24)) {
$this->info['upexpdate'] = time();
$this->info['expstopu'] = $this->info['expstopu'] + 1;
Db::sql(
'update stats set upexpdate = unix_timestamp(), expstopu = expstopu + 1 where id = ?',
[$this->info['id']]
);
}
if ($this->info['expstopu'] < 3) {
$this->info['exp'] = Config::get('expstop');
Db::sql('update stats set exp = ? where id = ?', [Config::get('expstop'), $this->info['id']]);
}
}
if (isset($this->stats['levels']['upLevel'])) {
$telvl = [];
$sp = mysql_query('SELECT `upLevel`,`exp` FROM `levels`');
while ($pl = mysql_fetch_array($sp)) {
$telvl[$pl['upLevel']] = $pl['exp'];
}
if ($this->info['exp'] >= $telvl[$this->info['upLevel']]) {
$lvl = mysql_fetch_array(
mysql_query(
'SELECT `duh`,`vinos`,`bprice`,`upLevel`,`nextLevel`,`exp`,`money`,`money_bonus1`,`money_bonus2`,`ability`,`skills`,`nskills`,`sskills`,`expBtlMax`,`hpRegen`,`mpRegen`,`money2` FROM `levels` WHERE `upLevel`="' . $this->info['upLevel'] . '" LIMIT 1'
)
);
$lvln = mysql_fetch_array(
mysql_query(
'SELECT `duh`,`vinos`,`bprice`,`upLevel`,`nextLevel`,`exp`,`money`,`money_bonus1`,`money_bonus2`,`ability`,`skills`,`nskills`,`sskills`,`expBtlMax`,`hpRegen`,`mpRegen`,`money2` FROM `levels` WHERE `upLevel`="' . ($lvl['upLevel'] + 1) . '" LIMIT 1'
)
);
//Кристал вечности
if ($this->info['exp'] > 12499 && $this->info['level'] <= 5 && Config::get('infinity5level')) {
$itm = mysql_fetch_array(
mysql_query(
'SELECT `id`,`item_id`,`1price`,`2price`,`3price`,`uid`,`use_text`,`data`,`inOdet`,`inShop`,`delete`,`iznosNOW`,`iznosMAX`,`gift`,`gtxt1`,`gtxt2`,`kolvo`,`geniration`,`magic_inc`,`maidin`,`lastUPD`,`timeOver`,`overType`,`secret_id`,`time_create`,`inGroup`,`dn_delete`,`inTransfer`,`post_delivery`,`lbtl_`,`bexp`,`so`,`blvl` FROM `items_users` WHERE `item_id` = "1204" AND `delete` = "0" AND `uid` = "' . $this->info['id'] . '" AND `inShop` = "0" AND `inTransfer` = "0" LIMIT 1'
)
);
if (!isset($itm['id']) && $this->info['host_reg'] != 'noinfinity5' && $this->info['twink'] == 0) {
$this->info['exp'] = 12499;
mysql_query(
'UPDATE `stats` SET `exp` = "12499" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1'
);
echo '<script>chat.sendMsg(["new","' . time() . '","6","","' . $this->info['login'] . '","Для перехода на 6-ой уровень требуется &quot;<strong>Кристалл Вечности [6]</strong>&quot;.","Black","1","1","0"]);</script>';
} else {
mysql_query(
'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `id` = "' . $itm['id'] . '" LIMIT 1'
);
$text = 'Предмет &quot;<strong>Кристалл Вечности [6]</strong>&quot; был успешно использован.';
echo '<script>chat.sendMsg(["new","' . time() . '","6","","' . $this->info['login'] . '","' . $text . '","Black","1","1","0"]);</script>';
}
}
$i = 0;
$ult = 0;
$sex1 = '';
if ($this->info['sex'] == 1) {
$sex1 = 'ла';
}
while ($i != 1) {
if (Config::get('nolevel') && $this->info['exp'] >= $lvl['exp'] && isset($lvln['upLevel'])) {
$tlus = mysql_fetch_array(
mysql_query(
'SELECT COUNT(*) FROM `users` WHERE `real` = 1 AND `level` = "' . $this->info['level'] . '" LIMIT 1'
)
);
//берем апп или уровень, $lvln
if ($tlus[0] < $this->info['level'] * 5) {
//Нельзя получать лвл/аппы пока не будет 100 персонажей текущего уровня
$this->info['exp'] = $lvl['exp'] - 1;
mysql_query(
'UPDATE `stats` SET `exp` = "' . $this->info['exp'] . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1'
);
}
}
if ($this->info['exp'] < $lvl['exp'] || !isset($lvln['upLevel'])) {
$i = 1;
} else {
if ($lvl['nextLevel'] > $this->info['level']) {
//повышаем выносливость
$a4 = 1;
if ($lvl['nextLevel'] == 9) {
$a4 = 2;
} elseif ($lvl['nextLevel'] == 10) {
$a4 = 3;
} elseif ($lvl['nextLevel'] == 11) {
$a4 = 5;
} elseif ($lvl['nextLevel'] == 12) {
$a4 = 30;
}
$this->stats['s4'] += $a4;
$ult = 1;
//Рефералы
if ($this->info['twink'] == 0 && (round(
$this->info['host_reg']
) > 0 && ($this->info['dieline'] == 0 || $this->info['dieline'] < $lvl['exp']))) {
$mtest = mysql_fetch_array(
mysql_query(
'SELECT `id`,`uid`,`uid2`,`ip` FROM `mults` WHERE (`uid` = "' . $this->info['id'] . '" AND `uid2` = "' . ((int)$this->info['host_reg']) . '") OR (`uid2` = "' . $this->info['id'] . '" AND `uid` = "' . ((int)$this->info['host_reg']) . '") LIMIT 1'
)
);
$rlog = mysql_fetch_array(
mysql_query(
'SELECT `id`,`login`,`catch`,`host_reg` FROM `users` WHERE `id` = "' . ((int)$this->info['host_reg']) . '" LIMIT 1'
)
);
$rlogs = mysql_fetch_array(
mysql_query(
'SELECT `id`,`ref_data` FROM `stats` WHERE `id` = "' . ((int)$this->info['host_reg']) . '" LIMIT 1'
)
);
if (!isset($mtest['id']) && isset($rlog['id'])) {
$rtg = true;
} else {
$rtg = mysql_fetch_array(
mysql_query(
'SELECT * FROM `ref_mult` WHERE `uid1` = "' . $rlog['id'] . '" LIMIT 1'
)
);
if (isset($rtg['id'])) {
if ($this->info['id'] == $rtg['uid2']) {
$rtg = true;
} else {
$rtg = false;
}
} else {
mysql_query(
'INSERT INTO `ref_mult` (`uid1`,`uid2`,`time`) VALUES (
"' . $rlog['id'] . '" , "' . $this->info['id'] . '","' . time() . '"
)'
);
$rtg = true;
}
}
$cmsg = new ChatMessage();
$cmsg->setRoom($this->info['room']);
$cmsg->setTo($rlog['login']);
$cmsg->setType(6);
if (($rtg || !isset($mtest['id'])) && isset($rlog['id'])) {
$rfs['data'] = explode('|', $rlogs['ref_data']);
$bonus = [
9 => 30,
10 => 75,
11 => 150,
12 => 250,
];
$ekr = $bonus[$lvl['nextlevel']];
if (isset($ekr)) {
$this->addEkr($ekr, $rlog['id']);
//Реферал 1-го уровня
$krtxt = ", $ekr екр.";
$cmsg->setText(
'Ваш реферал <strong>' . $this->info['login'] . '</strong> достиг' . $sex1 . ' уровня ' . $lvl['nextLevel'] . '! Вам зачисленно ' . $krtxt
);
(new Chat())->sendMsg($cmsg);
$rlog['catch'] += $ekr;
mysql_query(
'UPDATE `users` SET `catch` = "' . $rlog['catch'] . '" WHERE `id` = "' . $rlog['id'] . '" LIMIT 1'
);
if ((int)$rlog['host_reg'] > 0) {
//Реферал 2-го уровня
$llogin = $rlog['login'];
$ekr = round($ekr * 0.4, 2);
$rlog = mysql_fetch_array(
mysql_query(
'SELECT `id`,`login`,`catch`,`host_reg` FROM `users` WHERE `id` = "' . ((int)$rlog['host_reg']) . '" LIMIT 1'
)
);
if (isset($rlog['id'])) {
$cmsg->setText(
'Ваш реферал <strong>' . $this->info['login'] . '</strong> (2-го уровня от &quot;' . $llogin . '&quot; ) достиг' . $sex1 . ' уровня ' . $lvl['nextLevel'] . '! Вам зачисленно ' . $krtxt
);
(new Chat())->sendMsg($cmsg);
$rlog['catch'] += $ekr;
$this->addEkr($ekr, $rlog['id']);
if ((int)$rlog['host_reg'] > 0) {
//Реферал 3-го уровня
$llogin2 = $rlog['login'];
$ekr = round($ekr * 0.2, 2);
$rlog = mysql_fetch_array(
mysql_query(
'SELECT `id`,`login`,`catch`,`host_reg` FROM `users` WHERE `id` = "' . ((int)$rlog['host_reg']) . '" LIMIT 1'
)
);
if (isset($rlog['id'])) {
$cmsg->setText(
'Ваш реферал <strong>' . $this->info['login'] . '</strong> (3-го уровня от &quot;' . $llogin2 . '&quot; (Реферал ' . $llogin . ') ) достиг' . $sex1 . ' уровня ' . $lvl['nextLevel'] . '! Вам зачисленно ' . $krtxt
);
(new Chat())->sendMsg($cmsg);
$rlog['catch'] += $ekr;
$this->addEkr($ekr, $rlog['id']);
}
}
}
}
}
//
mysql_query(
"UPDATE `users` SET `referals` = `referals` + 5 WHERE `id` = '" . mysql_real_escape_string(
$rlog['id']
) . "' LIMIT 1"
);
//
} elseif (isset($rlog['id'])) {
$cmsg->setText(
'Ваш реферал <strong>' . $this->info['login'] . '</strong> достиг' . $sex1 . ' уровня ' . $lvl['nextLevel'] . '! <small style="color: red">(Персонаж не активирован, либо у вас совпадают IP! Разрешено не более 1 такого реферала!)</small>'
);
(new Chat())->sendMsg($cmsg);
}
}
}
$tst = Conversion::dataStringToArray($this->info['stats']);
$tst['s4'] += $lvl['vinos'];
$tst['s7'] += $lvl['duh'];
$this->info['stats'] = Conversion::arrayToDataString($tst);
$this->info['level'] = $lvl['nextLevel'];
$this->stats['levels'] = $lvln;
$this->info['ability'] += $lvl['ability'];
$this->info['skills'] += $lvl['skills'];
$this->info['sskills'] += $lvl['sskills'];
$this->info['nskills'] += $lvl['nskills'];
if ($this->info['twink'] == 0) {
$this->info['money'] = $lvl['money'] + $this->info['money'];
$this->info['money2'] = $lvl['money2'] + $this->info['money2'];
}
$lvl = $lvln;
$lvln = mysql_fetch_array(
mysql_query(
'SELECT `bprice`,`upLevel`,`nextLevel`,`exp`,`money`,`money_bonus1`,`money_bonus2`,`ability`,`skills`,`nskills`,`sskills`,`expBtlMax`,`hpRegen`,`mpRegen`,`money2` FROM `levels` WHERE `upLevel`="' . ($lvl['upLevel'] + 1) . '" LIMIT 1'
)
);
$this->info['upLevel'] += 1;
$rt++;
}
}
if ($ult == 1) {
$chat = new Chat();
$cmsg = new ChatMessage();
$cmsg->setRoom($this->info['room']);
$cmsg->setType(6);
if ($this->info['level'] == 4 || $this->info['level'] == 8) {
//Убрать задержки на пещеры
mysql_query(
'DELETE FROM `actions` WHERE `uid` = "' . $this->info['id'] . '" AND `vars` LIKE "psh%"'
);
$cmsg->setTo($this->info['login']);
$cmsg->setText('Обязательно используйте свитки и эликсиры в своем инвентаре!!!!!!!!!!!!!!!.');
$chat->sendMsg($cmsg);
}
$cmsg->setTypeTime(2);
$cmsg->setText(
'<strong>' . $this->info['login'] . '</strong> достиг' . $sex1 . ' уровня ' . $this->info['level'] . '!'
);
$chat->sendMsg($cmsg);
}
if ($rt > 0) {
$this->info['stopexp'] = 0;
$upd = mysql_query(
'UPDATE `users_twink` SET `stopexp` = "' . $this->info['stopexp'] . '" WHERE `uid` = "' . $this->info['id'] . '" LIMIT 1'
);
if ($upd) {
mysql_query(
'UPDATE `stats` SET `ability` = "' . $this->info['ability'] . '",`skills` = "' . $this->info['skills'] . '",`nskills` = "' . $this->info['nskills'] . '",`sskills` = "' . $this->info['sskills'] . '",`stats` = "' . $this->info['stats'] . '",`upLevel` = "' . $this->info['upLevel'] . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1'
);
$this->info['money'] = $this->r2($this->info['money']);
}
return 1;
}
//****************
}
}
/*------------*/
if ($this->info['animal'] > 0) {
//уровень зверя
$a = mysql_fetch_array(
mysql_query(
'SELECT `id`,`type`,`name`,`uid`,`delete`,`inBattle`,`eda`,`exp`,`obraz`,`stats`,`level`,`sex`,`levelUp`,`pet_in_cage`,`max_exp`,`priems`,`bonus` FROM `users_animal` WHERE `uid` = "' . $this->info['id'] . '" AND `id` = "' . $this->info['animal'] . '" AND `pet_in_cage` = "0" AND `delete` = "0" LIMIT 1'
)
);
if (isset($a['id']) && $a['level'] < 12) {
$ea = [
0 => 0,
1 => 110,
2 => 410,
3 => 1300,
4 => 2500,
5 => 5000,
6 => 12500,
7 => 30000,
8 => 100000,
9 => 3000000,
10 => 10000000,
11 => 50000000,
12 => 150000000,
];
$mx = [
0 => 140,
1 => 400,
2 => 500,
3 => 650,
4 => 700,
5 => 1400,
6 => 3000,
7 => 6000,
8 => 10000,
9 => 16000,
10 => 24000,
11 => 40000,
12 => 60000,
];
$iz = 0;
while ($iz != -1) {
if ($ea[$a['level'] + 1] <= $a['exp']) {
//поднимаем уровень
$a['level']++;
$a['max_exp'] = $mx[$a['level']];
} else {
if ($iz > 0) {
$a['stats'] = mysql_fetch_array(
mysql_query(
'SELECT `id`,`type`,`exp`,`level`,`stats`,`bonus` FROM `levels_animal` WHERE `type` = "' . $a['type'] . '" AND `level` = "' . $a['level'] . '" LIMIT 1'
)
);
$a['stats'] = $a['stats']['stats'];
$cmsg = new ChatMessage();
$cmsg->setRoom($this->info['room']);
$cmsg->setCity($this->info['city']);
$cmsg->setTo($this->info['login']);
$cmsg->setText('<strong>' . $a['name'] . '</strong> достиг ' . $a['level'] . ' уровня!');
$cmsg->setType(6);
(new Chat())->sendMsg($cmsg);
mysql_query(
'UPDATE `users_animal` SET `stats` = "' . $a['stats'] . '",`level`="' . $a['level'] . '",`max_exp`="' . $a['max_exp'] . '" WHERE `id` = "' . $a['id'] . '" LIMIT 1'
);
}
$iz = -2;
}
if ($iz > 1000) {
$iz = -2;
}
$iz++;
}
}
}
}
//получаем уровень
public function addEkr($amount, $uid = 0): void
{
if ($uid === 0) {
$uid = $this->info['id'];
$this->info['money2'] += $amount;
}
Db::sql('update users set money2 = money2 + ? where id = ?', [$amount, $uid]);
}
public function r2($v): string
{
return number_format($v, 2, '.', ' ');
}
public function addVoinstvennost($amount, $uid = 0): void
{
if ($uid === 0) {
$uid = $this->info['id'];
}
Db::sql('update rep set rep3 = rep3 + ? where id = ?', [$amount, $uid]);
}
/**
* @param $uid
* @param $st
* @param $i1
* @return array|int[]
*/
public function regen($uid, $st, $i1): array
{
if ($uid != $this->info['id']) {
$where = is_numeric($uid) ? "users.id = $uid" : "login = $uid";
$u = Db::getRow("select battle, stats.* from users left join stats on users.id = stats.id where $where");
if (!isset($st['hpAll'])) {
$st = $this->getStats($uid, $i1);
}
} else {
$u = $this->info;
$st = isset($this->stats['hpAll']) ? $this->stats : $this->getStats($uid, $i1);
}
if (!empty($u['battle'])) {
return [0, 0];
}
$sth = $u['minHP'] ?: 300; //Стандартное время восстановления в минутах HP
$stm = $u['minMP'] ?: 300; //Стандартное время восстановления в минутах MP
if (empty($st['speedhp'])) {
$st['speedhp'] = 0;
}
if (empty($st['speedmp'])) {
$st['speedmp'] = 0;
}
//Тестеры первой волны
//тесты боев
# А не эта ли херня делала очень быструю регенерацию, которую считают нормой?
$st['speedhp'] += 150;
$st['speedmp'] += 150;
//hp
$sh = ($st['hpAll'] / (60 * $sth));
$sh += ($sh / 100) * (1 + $st['speedhp'] + $st['levels']['hpRegen']);
$st['hpNow'] += $sh * (time() - $u['regHP']);
$st['hpNow'] = $st['hpNow'] > 0 ? min($st['hpNow'], $st['hpAll']) : 0;
//mp
$sm = ($st['mpAll'] / (60 * $stm));
$sm += ($sm / 100) * (1 + $st['speedmp'] + $st['levels']['mpRegen']);
$st['mpNow'] += $sm * (time() - $u['regMP']);
$st['mpNow'] = $st['mpNow'] > 0 ? min($st['mpNow'], $st['mpAll']) : 0;
//Заносим новые данные в базу
if ($u['hpNow'] < $st['hpAll'] || $u['mpNow'] < $st['mpAll']) {
Db::sql(
'update stats set
regHP = unix_timestamp(),
regMP = unix_timestamp(),
hpNow = ?,
mpNow = ?
where id = ?', [$st['hpNow'], $st['mpNow'], $u['id']]
);
}
if ($this->info['id'] == $u['id']) {
$this->stats['regHP'] = time();
$this->stats['regMP'] = time();
$this->stats['hpNow'] = $st['hpNow'];
$this->stats['mpNow'] = $st['mpNow'];
}
return [$sh, $sm, 'hpNow' => $st['hpNow'], 'mpNow' => $st['mpNow']];
}
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 = '<font color="#FF0000"><strong>Вы не можете изьять данный предмет, он не принадлежит клану</strong></font><br />';
} elseif (isset($itm_['id'])) {
if ($user['inTurnir'] == 0 && $user['inTurnirnew'] == 0) {
if ($itm_['inOdet'] != 0) {
$o = ', `inOdet` = 0';
} else {
$o = '';
}
$r = '<font color="#FF0000"><strong>Вы успешно изъяли предмет &quot;' . $itm_['name'] . '&quot;</strong></font><br />';
$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 = '<font color="#FF0000"><strong>Во время участия в турнире запрещено использовать клановое хранилище.</strong></font><br />';
}
} else {
$r = '<font color="#FF0000"><strong>Предмет не найден.</strong></font><br />';
}
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];
}
if ($user['inTurnir'] == 0 && $user['inTurnirnew'] == 0) {
$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 = '<font color="#FF0000"><strong>Вы успешно взяли предмет &quot;' . $itm_['name'] . '&quot; из хранилища</strong></font><br />';
} else {
$r = '<font color="#FF0000"><strong>Во время участия в турнире запрещено использовать клановое хранилище.</strong></font><br />';
}
} else {
$r = '<font color="#FF0000"><strong>Предмет не найден.</strong></font><br />' . $id;
}
return $r;
}
public function rem_itm_cl($user, $cl, $type): void
{
$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'] . '")'
);
}
}
}
public function isModerator(): bool
{
return $this->isAdmin() || $this->info['align'] > 3 && $this->info['align'] < 4;
}
public function isAdmin(): bool
{
return $this->info['admin'] > 0;
}
/** Игрок имеет меньше 30% хп.
* @return bool
*/
public function isWeakened(): bool
{
return $this->stats['hpNow'] < ceil($this->stats['hpMax'] / 100 * 30);
}
public function isBlocked(): bool
{
return $this->info['banned'] > 0;
}
}