refactor
This commit is contained in:
+96
-98
@@ -11,6 +11,8 @@ use User\InfoBox;
|
||||
use User\ItemsModel;
|
||||
use User\Reputation;
|
||||
use User\Stats;
|
||||
use User\UserCalculatedStats;
|
||||
use User\UserStats;
|
||||
|
||||
class User
|
||||
{
|
||||
@@ -1099,12 +1101,8 @@ class User
|
||||
where users.' . $cell . ' = ?';
|
||||
$result = Db::getRow($query, [$user]);
|
||||
|
||||
$temp = Conversion::dataStringToArray($result['stats']);
|
||||
|
||||
$result['testStats'] = new User\UserStats(
|
||||
$temp
|
||||
);
|
||||
$result['testStats2'] = new \User\UserCalculatedStats($result['testStats']);
|
||||
$result['testStats2'] = new UserCalculatedStats(new UserStats(Conversion::dataStringToArray($result['stats'])));
|
||||
|
||||
return $result ?: [];
|
||||
}
|
||||
@@ -5174,103 +5172,103 @@ class User
|
||||
[$u['id']]);
|
||||
|
||||
|
||||
$t = $this->items['tr'];
|
||||
$x = 0;
|
||||
$notr = 0;
|
||||
$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) {
|
||||
if (empty($itm['data'])) {
|
||||
if ($this->info['twink'] > 0) {
|
||||
//Не дороже 100 екр.
|
||||
if ($itm['price2'] > 1 || $itm['2price'] > 1) {
|
||||
$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 ($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) {
|
||||
|
||||
Reference in New Issue
Block a user