Кольца стакались в одном слоте потому что у них один тип. Чёртова отладка.
This commit is contained in:
parent
96542c02d5
commit
3d3df26289
14
main.php
14
main.php
@ -308,18 +308,16 @@ function dressitem($id)
|
|||||||
define('ERROR_TOO_MANY_ITEMS_IN_SLOTS', 'Критическая ошибка: Переполнение слота!');
|
define('ERROR_TOO_MANY_ITEMS_IN_SLOTS', 'Критическая ошибка: Переполнение слота!');
|
||||||
define('ERROR_UNKNOWN_ITEM_TYPE', 'Неизвестный тип предмета!');
|
define('ERROR_UNKNOWN_ITEM_TYPE', 'Неизвестный тип предмета!');
|
||||||
define('ERROR_ITEM_NOT_FOUND', 'Предмет не найден!');
|
define('ERROR_ITEM_NOT_FOUND', 'Предмет не найден!');
|
||||||
|
$itemInSlot = [];
|
||||||
$selectedItemRow = db::c()->query('SELECT item_type FROM `inventory` WHERE item_id = ?i AND owner_id = ?i AND `dressed_slot` = 0', $id, $_SESSION['uid']);
|
$selectedItemRow = db::c()->query('SELECT item_type FROM `inventory` WHERE item_id = ?i AND owner_id = ?i AND `dressed_slot` = 0', $id, $_SESSION['uid']);
|
||||||
if ($selectedItemRow->getNumRows()) {
|
if ($selectedItemRow->getNumRows()) {
|
||||||
$selectedItem = $selectedItemRow->fetch_object();
|
$selectedItem = $selectedItemRow->fetch_object();
|
||||||
$itemInSlotRow = db::c()->query('SELECT dressed_slot FROM inventory WHERE owner_id = ?i AND dressed_slot > 0 AND item_type = ?i', $_SESSION['uid'], $selectedItem->item_type);
|
$itemInSlotRow = db::c()->query('SELECT dressed_slot FROM inventory WHERE owner_id = ?i AND dressed_slot > 0 AND item_type = ?i', $_SESSION['uid'], $selectedItem->item_type);
|
||||||
$itemInSlotQuantity = $itemInSlotRow->getNumRows();
|
$itemInSlotQuantity = $itemInSlotRow->getNumRows();
|
||||||
if ($itemInSlotQuantity) {
|
if ($itemInSlotQuantity) {
|
||||||
//$itemInSlot = $itemInSlotRow->fetch_assoc();
|
while ($row = $itemInSlotRow->fetch_object()) {
|
||||||
while ($row = $itemInSlotRow->fetch_assoc()) {
|
$itemInSlot[] = $row->dressed_slot;
|
||||||
$itemInSlot[] = $row['dressed_slot'];
|
|
||||||
}
|
}
|
||||||
print_r($itemInSlot).'<br>';
|
|
||||||
}
|
}
|
||||||
if (in_array($selectedItem->item_type,[HELMET,ARMOR,LEGS,BOOTS,GLOVES,WEAPON,SHIELD,BELT,AMULET])) {
|
if (in_array($selectedItem->item_type,[HELMET,ARMOR,LEGS,BOOTS,GLOVES,WEAPON,SHIELD,BELT,AMULET])) {
|
||||||
//работаем с нормальными слотами
|
//работаем с нормальными слотами
|
||||||
@ -337,12 +335,8 @@ function dressitem($id)
|
|||||||
}
|
}
|
||||||
} elseif ($selectedItem->item_type == RING) {
|
} elseif ($selectedItem->item_type == RING) {
|
||||||
// работаем с кольцами
|
// работаем с кольцами
|
||||||
if (!$itemInSlotQuantity) {
|
if ($itemInSlotQuantity < 3) {
|
||||||
// просто одеваем предмет в слот 9
|
|
||||||
db::c()->query('UPDATE inventory SET dressed_slot = 9 WHERE item_id = ?i', $id);
|
|
||||||
} elseif ($itemInSlotQuantity > 0 && $itemInSlotQuantity < 3) {
|
|
||||||
// Сравниваем массив колец и массив слотов для колец.
|
// Сравниваем массив колец и массив слотов для колец.
|
||||||
//FIXME Два кольца стакаются в среднем слоте!
|
|
||||||
$emptyRingSlots = array_diff([9,10,11], $itemInSlot);
|
$emptyRingSlots = array_diff([9,10,11], $itemInSlot);
|
||||||
// Сортируем массив свободных слотов по возрастанию.
|
// Сортируем массив свободных слотов по возрастанию.
|
||||||
sort($emptyRingSlots);
|
sort($emptyRingSlots);
|
||||||
|
Loading…
Reference in New Issue
Block a user