refactor and errors

This commit is contained in:
2023-11-05 04:46:07 +02:00
parent def933dca4
commit 3e753c8b93
125 changed files with 1353 additions and 1435 deletions
+89 -71
View File
@@ -5132,7 +5132,7 @@ class User
$snIt = 0;
//Проверяем одетые вещи и вещи с сроком годности
$cl = Db::getRow("select
$itm = Db::getRow("select
items_main.id,
items_users.id as iduid,
data,
@@ -5164,86 +5164,104 @@ class User
) and uid = ?",
[$u['id']]);
foreach ($cl as $itm) {
$po = Conversion::dataStringToArray($itm['data']);
$po['lvl'] = $u['level'];
//проверяем требования
$t = $this->items['tr'];
$x = 0;
$notr = 0;
$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;
if (empty($itm['data'])) {
if ($this->info['twink'] > 0) {
//Не дороже 100 екр.
if ($itm['price2'] > 1 || $itm['2price'] > 1) {
$notr++;
}
}
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) {
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['item_id'] == 4704) {
$po['musor2'] = 4708;
} 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']);
}
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) {