From 3d3df2628999f4d20868e4c009ef2e1c8266a64f Mon Sep 17 00:00:00 2001 From: lopar Date: Sat, 29 Aug 2020 16:59:22 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9A=D0=BE=D0=BB=D1=8C=D1=86=D0=B0=20=D1=81?= =?UTF-8?q?=D1=82=D0=B0=D0=BA=D0=B0=D0=BB=D0=B8=D1=81=D1=8C=20=D0=B2=20?= =?UTF-8?q?=D0=BE=D0=B4=D0=BD=D0=BE=D0=BC=20=D1=81=D0=BB=D0=BE=D1=82=D0=B5?= =?UTF-8?q?=20=D0=BF=D0=BE=D1=82=D0=BE=D0=BC=D1=83=20=D1=87=D1=82=D0=BE=20?= =?UTF-8?q?=D1=83=20=D0=BD=D0=B8=D1=85=20=D0=BE=D0=B4=D0=B8=D0=BD=20=D1=82?= =?UTF-8?q?=D0=B8=D0=BF.=20=D0=A7=D1=91=D1=80=D1=82=D0=BE=D0=B2=D0=B0=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BB=D0=B0=D0=B4=D0=BA=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.php | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/main.php b/main.php index 7560c30..7381a00 100644 --- a/main.php +++ b/main.php @@ -308,18 +308,16 @@ function dressitem($id) define('ERROR_TOO_MANY_ITEMS_IN_SLOTS', 'Критическая ошибка: Переполнение слота!'); define('ERROR_UNKNOWN_ITEM_TYPE', 'Неизвестный тип предмета!'); 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']); if ($selectedItemRow->getNumRows()) { $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); $itemInSlotQuantity = $itemInSlotRow->getNumRows(); if ($itemInSlotQuantity) { - //$itemInSlot = $itemInSlotRow->fetch_assoc(); - while ($row = $itemInSlotRow->fetch_assoc()) { - $itemInSlot[] = $row['dressed_slot']; + while ($row = $itemInSlotRow->fetch_object()) { + $itemInSlot[] = $row->dressed_slot; } - print_r($itemInSlot).'
'; } 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) { // работаем с кольцами - if (!$itemInSlotQuantity) { - // просто одеваем предмет в слот 9 - db::c()->query('UPDATE inventory SET dressed_slot = 9 WHERE item_id = ?i', $id); - } elseif ($itemInSlotQuantity > 0 && $itemInSlotQuantity < 3) { + if ($itemInSlotQuantity < 3) { // Сравниваем массив колец и массив слотов для колец. - //FIXME Два кольца стакаются в среднем слоте! $emptyRingSlots = array_diff([9,10,11], $itemInSlot); // Сортируем массив свободных слотов по возрастанию. sort($emptyRingSlots);