diff --git a/classes/Battles/DressedItems.php b/classes/Battles/DressedItems.php index f1acfa0..c1053d7 100644 --- a/classes/Battles/DressedItems.php +++ b/classes/Battles/DressedItems.php @@ -5,6 +5,9 @@ * Time: 22:41 */ namespace Battles; +use db; +use Krugozor\Database\Mysql\Exception; + class DressedItems { private $DB; @@ -25,15 +28,20 @@ class DressedItems private function getDressedItems() { try { - $this->DB = \db::c()->query('SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot > 0', $this->USERID); + $this->DB = db::c()->query('SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot > 0', $this->USERID); } catch (\Exception $e) { echo '
Не прогрузилась таблица inventory (*) для класса DressedItems.
'; } } - private function getDressedItemById($item_id) + private static function getDressedItemById($item_id) { - return \db::c()->query('SELECT * FROM inventory WHERE item_id = ?i AND dressed_slot > 0', $item_id)->fetch_assoc(); + return db::c()->query('SELECT * FROM inventory WHERE item_id = ?i AND dressed_slot > 0', $item_id)->fetch_assoc(); + } + + public static function getDressedItemBySlot($itemSlot, $ownerId) + { + return db::c()->query('SELECT * FROM battles.inventory WHERE owner_id = ?i AND dressed_slot = ?i', $ownerId, $itemSlot)->fetch_assoc(); } private function getBonusesFromDressedItems() @@ -53,7 +61,7 @@ SELECT SUM(add_strength) as sum_strength, SUM(add_max_physical_damage) as sum_max_phys_damage FROM inventory WHERE owner_id = ?i AND dressed_slot > 0 SQL; - $this->DBSUM = \db::c()->query($query, $this->USERID)->fetch_assoc(); + $this->DBSUM = db::c()->query($query, $this->USERID)->fetch_assoc(); } catch (\Exception $e) { echo '
Не прогрузилась таблица inventory (SUM) для класса DressedItems:' . $e . '
'; } @@ -127,14 +135,14 @@ SQL; * Снимает с предмета статус одетого на персонажа в определённом слоте персонажа. * @param $slot_id - номер слота. * - * @throws \Krugozor\Database\Mysql\Exception + * @throws Exception */ public function undressItem($slot_id) { self::getItemsInSlots(); // Проверяем, что используется один из 12 слотов и наличие предмета в слоте. if (in_array($slot_id, Item::ITEM_TYPES_ALLOWED_IN_SLOTS) && $this->dressedItem[$slot_id]) { - \db::c()->query('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = ?i AND owner_id = ?i', $slot_id, $this->USERID); + db::c()->query('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = ?i AND owner_id = ?i', $slot_id, $this->USERID); } }