WIP: перед введенимем класса Fighter.php

This commit is contained in:
2024-01-06 00:14:35 +02:00
parent 07f905ef64
commit a2c658166d
67 changed files with 5555 additions and 7135 deletions
+123 -190
View File
@@ -9,6 +9,7 @@ use Model\ActionModel;
use User\Effects;
use User\InfoBox;
use User\ItemsModel;
use User\Login;
use User\Reputation;
use User\Stats;
use User\UserCalculatedStats;
@@ -17,7 +18,6 @@ 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 = [
@@ -26,34 +26,6 @@ class User
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',
@@ -584,25 +556,35 @@ class User
public string $error = '';
public array $info = [];
public array $rep;
public $tfer;
public $stats;
/** Для переводов персонажа */
public array|false $tfer;
public array $stats;
private InfoBox $infoBox;
private Reputation $reputation;
private Stats $userStats;
private function __construct()
private function __construct(int $uid = 0)
{
if (empty($_SESSION['uid']) && empty($_COOKIE['login'])) {
if (empty($_SESSION['uid']) && empty($_COOKIE['login']) && empty($uid)) {
return;
}
$user = !empty($_SESSION['uid']) ? $_SESSION['uid'] : $_COOKIE['login'];
$user = match (true) {
!empty($uid) => $uid,
!empty($_SESSION['uid']) => $_SESSION['uid'],
default => $_COOKIE['login']
};
$this->info = self::getInfo($user);
unset($user);
Database::init(); // для всяких mysql_*
$this->userStats = new Stats($this);
//$this->getStats($this->info); // Бля, а вдруг?
$this->stats = $this->userStats->getStats($this->info);
$this->infoTasks();
if (Core\Config::get('securetime') > 0) {
@@ -813,11 +795,18 @@ class User
}
//Выделяем передачи
$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'
)
$this->tfer = Db::getRow(
'select *
from transfers
where (uid1 = ? or uid2 = ?)
and (cancel1 = 0 or (finish1 > 0 and uid1 = ?) or (finish2 > 0 and uid2 = ?))
and (cancel2 = 0 or (finish2 > 0 and uid2 = ?) or (finish1 > 0 and uid1 = ?))
order by id desc
limit 1',
[$this->info['id'], $this->info['id'], $this->info['id'], $this->info['id'], $this->info['id'], $this->info['id']]
);
if ($this->tfer) {
if ($this->tfer['uid1'] == $this->tfer['uid2']) {
$this->tfer = false;
@@ -891,11 +880,11 @@ class User
$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']]);
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']]);
Db::sql('update items_users set inodet = ? where id = ? and uid = ? and inshop = 0', [(int)$slot, (int)$itemid, $this->info['id']]);
}
}
@@ -1013,7 +1002,7 @@ class User
$j++;
}
if ($tritm != '' && !$tr) {
$this->error = 'Необходимы предметы: ' . $tritm . '';
$this->error = 'Необходимы предметы: ' . $tritm;
}
}
while ($x < count($t)) {
@@ -1029,7 +1018,7 @@ class User
mysql_query(
'UPDATE `users` SET `obraz` = "' . $o['img'] . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1'
);
$this->addAction(time(), 'sel_obraz', 'id=' . $o['id'] . '');
$this->addAction(time(), 'sel_obraz', 'id=' . $o['id']);
$this->info['obraz'] = $o['img'];
}
} else {
@@ -1044,7 +1033,7 @@ class User
} else {
$this->error = 'Выбирать образ можно не чаще одного раза в сутки, следующая смена ' . date(
'd.m.Y H:i', $sm['time'] + 86400
) . '';
);
unset($_GET['obr_sel']);
$_GET['inv'] = 1;
}
@@ -1115,9 +1104,6 @@ class User
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'])) {
@@ -1365,12 +1351,13 @@ class User
//Расчет защиты (магия)
/** Singletone.
* @param int $uid
* @return User
*/
public static function start(): User
public static function start(int $uid = 0): User
{
if (!isset(self::$flag_one)) {
self::$flag_one = new self();
self::$flag_one = new self($uid);
}
return self::$flag_one;
}
@@ -1401,13 +1388,10 @@ class User
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";
if (!isset($login)) {
return "uid:$uid";
}
return (new Login($align, $clanName, $level, $login))->fullLogin;
}
public function dayquest(int $id): string
@@ -1465,11 +1449,11 @@ class User
}
$this->error = 'Вы успешно восстановили ' . round($this->stats['hpAll'] - $this->stats['hpNow']) . ' HP.';
Db::sql(
'insert into vortex (uid, room, time, val, type) VALUES (?,?,unix_timestamp(),?,1)',
'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']]);
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');
@@ -1482,11 +1466,11 @@ class User
}
$this->error = 'Вы успешно восстановили ' . round($this->stats['mpAll'] - $this->stats['mpNow']) . ' MP.';
Db::sql(
'insert into vortex (uid, room, time, val, type) VALUES (?,?,unix_timestamp(),?,2)',
'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']]);
Db::sql('update stats set mpnow = ? where id = ?', [$this->stats['mpNow'], $this->info['id']]);
}
}
@@ -1532,7 +1516,7 @@ class User
if ($an <= 0) {
return;
}
Db::sql('replace into users_align (uid, time, align) VALUES (?,unix_timestamp(),?)', [$uid, floor($an)]);
Db::sql('replace into users_align (uid, time, align) values (?,unix_timestamp(),?)', [$uid, floor($an)]);
}
@@ -1987,7 +1971,7 @@ class User
//копируем пользователя
Db::sql(
"insert into users (align, login, level, pass, city, cityreg, name, sex, timereg, obraz, bot_id, inTurnir) values (?,?,?,uuid(),'Неведомые земли','Неведомые земли',?,?,?,?,?,?)",
"insert into users (align, login, level, pass, city, cityreg, name, sex, timereg, obraz, bot_id, inturnir) values (?,?,?,uuid(),'Неведомые земли','Неведомые земли',?,?,?,?,?,?)",
[
$clon['align'] ?? 0,
$clon['login'],
@@ -2027,17 +2011,17 @@ class User
$uid = (int)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 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 = ?",
"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'",
"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']]
);
@@ -2047,7 +2031,7 @@ class User
} else {
$bot = Db::getRow('select id, login, stats, upLevel, itemsUse from test_bot where id = ?', [$id]);
$bot = Db::getRow('select id, login, stats, uplevel, itemsuse from test_bot where id = ?', [$id]);
if (!isset($bot['id'])) {
return [];
@@ -2088,7 +2072,7 @@ class User
$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']]);
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;
@@ -2109,7 +2093,7 @@ class User
$w3b = 1;
}
}
Db::sql('update items_users set inOdet = ? where id = ?', [$inslot, $iditem]);
Db::sql('update items_users set inodet = ? where id = ?', [$inslot, $iditem]);
}
return $bot;
}
@@ -2188,7 +2172,7 @@ class User
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]);
$itm = Db::getValue('select data from items_users where id = ? and uid = ? and inshop = 0 and inodet = 0', [$id, $uid]);
if (!isset($itm)) {
return;
@@ -2236,7 +2220,7 @@ class User
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]);
$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;
}
@@ -2253,7 +2237,7 @@ class User
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]);
$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;
}
@@ -2323,7 +2307,7 @@ class User
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]);
$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;
@@ -2332,25 +2316,25 @@ class User
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']]);
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]);
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]);
$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 = ?',
'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');
$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;
@@ -2359,15 +2343,15 @@ class User
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']]);
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]);
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]);
$itm = Db::getValue('select data from items_users where id = ? and uid = ? and inshop = 0 and inodet = 0', [$id, $uid]);
if (!$itm) {
return;
}
@@ -2619,7 +2603,7 @@ class User
//-----------------------------------------------
$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'
'SELECT `id`,`name`,`img`,`type`,`inslot`,`2h`,`2too`,`iznosMAXi`,`inRazdel`,`price1`,`price2`,`price3`,`magic_chance`,`info`,`massa`,`level`,`magic_inci`,`overTypei`,`group`,`group_max`,`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'
)
);
@@ -2664,7 +2648,7 @@ class User
}
//Новая чарка
$srune = mysql_query('SELECT * FROM `new_charov` WHERE 1');
$srune = mysql_query('select * from new_charov where 1');
$irun = 0;
while ($nrune = mysql_fetch_array($srune)) {
$irun++;
@@ -2711,7 +2695,7 @@ class User
} 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'
'SELECT `id`,`name`,`img`,`type`,`inslot`,`2h`,`2too`,`iznosMAXi`,`inRazdel`,`price1`,`price2`,`price3`,`magic_chance`,`info`,`massa`,`level`,`magic_inci`,`overTypei`,`group`,`group_max`,`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) {
@@ -3011,7 +2995,7 @@ class User
} 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']
'SELECT `id`,`name`,`img`,`type`,`inslot`,`2h`,`2too`,`iznosMAXi`,`inRazdel`,`price1`,`price2`,`price3`,`magic_chance`,`info`,`massa`,`level`,`magic_inci`,`overTypei`,`group`,`group_max`,`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) {
@@ -3190,7 +3174,7 @@ class User
} 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'
'SELECT `id`,`name`,`img`,`type`,`inslot`,`2h`,`2too`,`iznosMAXi`,`inRazdel`,`price1`,`price2`,`price3`,`magic_chance`,`info`,`massa`,`level`,`magic_inci`,`overTypei`,`group`,`group_max`,`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) {
@@ -3310,7 +3294,6 @@ class User
`im`.`overTypei`,
`im`.`group`,
`im`.`group_max`,
`im`.`geni`,
`im`.`ts`,
`im`.`srok`,
`im`.`class`,
@@ -3371,7 +3354,7 @@ class User
`im`.`magic_inci`, `im`.`overTypei`,
`im`.`group`,
`im`.`group_max`,
`im`.`geni`, `im`.`ts`,
`im`.`ts`,
`im`.`srok`,
`im`.`class`, `im`.`class_point`,
`im`.`anti_class`, `im`.`anti_class_point`,
@@ -4241,10 +4224,6 @@ class User
$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>';
}
@@ -4867,7 +4846,6 @@ class User
`im`.`overTypei`,
`im`.`group`,
`im`.`group_max`,
`im`.`geni`,
`im`.`ts`,
`im`.`srok`,
`im`.`class`,
@@ -4983,7 +4961,6 @@ class User
`im`.`overTypei`,
`im`.`group`,
`im`.`group_max`,
`im`.`geni`,
`im`.`ts`,
`im`.`srok`,
`im`.`class`,
@@ -5064,7 +5041,7 @@ class User
$i = 0;
do { //fixme ужасный цикл, ужасный запрос.
$i++;
$gr = Db::getValue('select inGroup from items_users where uid = ? and inGroup = ? and item_id = ?', [$uid, $i, $item]);
$gr = Db::getValue('select ingroup from items_users where uid = ? and ingroup = ? and item_id = ?', [$uid, $i, $item]);
if (empty($gr)) {
$g = 1;
@@ -5107,24 +5084,24 @@ class User
item_id,
time_create,
time_sleep,
timeOver,
timeover,
name,
overType,
inOdet,
iznosNOW,
iznosMAX,
iznosMAXi
overtype,
inodet,
iznosnow,
iznosmax,
iznosmaxi
from items_users
left join items_main on items_main.id = item_id
where
(
inOdet != 0 or
inodet != 0 or
data like '%srok%' or
data like '%vip_sale%' or
data like '%sudba=1%' or
iznosNOW > 0 or
iznosnow > 0 or
srok > 0 or
(timeOver !=0 and timeOver < unix_timestamp())
(timeover !=0 and timeover < unix_timestamp())
) and uid = ?",
[$u['id']]
);
@@ -5141,7 +5118,9 @@ class User
$notr++;
}
}
if ($itm['iznosNOW'] >= ceil($itm['iznosMAX']) && $itm['iznosMAXi'] != 999999999) {
if (isset($itm['iznosNOW'], $itm['iznosMAX'], $itm['iznosMAXi']) &&
$itm['iznosNOW'] >= ceil($itm['iznosMAX']) &&
$itm['iznosMAXi'] != 999999999) {
$notr++;
}
if ($notr > 0 && $itm['inOdet'] != 0) {
@@ -5240,7 +5219,7 @@ class User
return 0;
}
$sql = 'select count(*) from items_users where id = ? and inOdet != 0';
$sql = 'select count(*) from items_users where id = ? and inodet != 0';
$args = [$id];
if ($uid > 0) {
$sql .= ' and uid = ?';
@@ -5250,7 +5229,7 @@ class User
if (empty(Db::getValue($sql, $args))) {
return 0;
}
Db::sql('update items_users set lastUPD = unix_timestamp(), inOdet = 0 where id = ?', [$id]);
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']]);
@@ -5282,7 +5261,7 @@ class User
public function btlMagicList(): string
{
$sv = array_fill(1, 10, '<img class="nopriemuse" title="Пустой слот магия" src="' . Config::img() . '/i/items/w/w101.gif" alt="">');
$sv = array_fill(1, 12, '<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])) {
@@ -5335,7 +5314,7 @@ class User
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]);
$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;
@@ -5391,11 +5370,15 @@ class User
{
$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',
'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)) {
if (
!isset($pl['iznosMAX']) ||
!isset($pl['iznosNOW']) ||
$pl['iznosNOW'] <= ceil($pl['iznosMAX'] * 0.80)
) {
continue;
}
$r .= '<strong>' . $pl['name'] . '</strong> [<span style="color: brown">' . floor($pl['iznosNOW']) . '/' .
@@ -5409,16 +5392,16 @@ class User
if ($uid < 1) {
return 0;
}
Db::sql('update items_users set lastUPD = unix_timestamp(), inOdet = 0 where inOdet != 0 and uid = ?', [$uid]);
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
$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";
where items_users.id = ? and inodet = 0 and inshop = 0";
$args = [$id];
if ($uid) {
@@ -5439,7 +5422,7 @@ class User
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']}%"])
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++;
@@ -5491,7 +5474,7 @@ class User
} 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']]);
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';
@@ -5530,7 +5513,7 @@ class User
$this->error = 'Не удалось открыть подарок. Содержимое испорчено.';
} elseif ($itmin['item_id'] == 4868) {
//Летучая мышь
Db::sql('update stats set hpNow = 1, mpNow = 1 where id = ?', [$this->info['id']]);
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...';
@@ -5660,7 +5643,7 @@ class User
$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'
'SELECT `id`,`name`,`img`,`type`,`inslot`,`2h`,`2too`,`iznosMAXi`,`inRazdel`,`price1`,`price2`,`price3`,`magic_chance`,`info`,`massa`,`level`,`magic_inci`,`overTypei`,`group`,`group_max`,`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'])) {
@@ -5809,10 +5792,8 @@ LIMIT 1'
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;
$inGroup = $this->stackGroupCheck($this->info['id'], $itm['inGroup'], $itm['item_id']);
}
$sp = mysql_query(
'SELECT `im`.`id`,
@@ -5835,7 +5816,6 @@ LIMIT 1'
`im`.`overTypei`,
`im`.`group`,
`im`.`group_max`,
`im`.`geni`,
`im`.`ts`,
`im`.`srok`,
`im`.`class`,
@@ -5906,25 +5886,21 @@ LIMIT 1'
}
}
private function trItem($po)
private function trItem($po): int
{
$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++;
}
foreach ($this->items['tr'] as $trn) {
if (!isset($po["tr_$trn"])) {
continue;
}
if (
$trn === 'sex' && $this->info['sex'] != $po["tr_$trn"] ||
$trn !== 'align' && $po["tr_$trn"] > $this->stats[$trn]
) {
$notr++;
}
$x++;
}
return $notr;
}
@@ -6046,67 +6022,23 @@ LIMIT 1'
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'];
foreach (Db::getRows('select uplevel, exp from levels') as $row) {
$telvl[$row['uplevel']] = $row['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>';
}
}
[$lvl, $lvln] = Db::getRows('select * from levels where uplevel >= ? order by uplevel limit 2', [$this->info['upLevel']]);
$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 {
@@ -6282,6 +6214,7 @@ LIMIT 1'
$rt++;
}
}
if ($ult == 1) {
$chat = new Chat();
$cmsg = new ChatMessage();
@@ -6476,10 +6409,10 @@ LIMIT 1'
if ($u['hpNow'] < $st['hpAll'] || $u['mpNow'] < $st['mpAll']) {
Db::sql(
'update stats set
regHP = unix_timestamp(),
regMP = unix_timestamp(),
hpNow = ?,
mpNow = ?
reghp = unix_timestamp(),
regmp = unix_timestamp(),
hpnow = ?,
mpnow = ?
where id = ?', [$st['hpNow'], $st['mpNow'], $u['id']]
);
}