USERID = $user_id; } public static function getDressedItemBySlot($itemSlot, $ownerId) { return self::$db->fetch('SELECT *, COUNT(1) AS count FROM inventory WHERE owner_id = ? AND dressed_slot = ?', [$ownerId, $itemSlot]); } public function getItemsInSlots(): stdClass { $items = self::$db->ofetchALL('SELECT * FROM inventory WHERE owner_id = ? AND dressed_slot > 0', $this->USERID); $this->dressedItem = new stdClass(); foreach ($items as $item) { $i = $item->dressed_slot; $this->dressedItem->$i = $item; } return $this->dressedItem; } private function getBonuses(): array { $query = << 0 SQL; return self::$db->fetch($query, $this->USERID); } public function getAccuracyBonus(): ?int { return self::getBonuses()['sum_accuracy'] ?? 0; } public function getEvasionBonus(): ?int { return self::getBonuses()['sum_evasion'] ?? 0; } public function getCriticalsBonus(): ?int { return self::getBonuses()['sum_criticals'] ?? 0; } public function getMinPhysDamage(): ?int { return self::getBonuses()['sum_min_phys_damage']; } public function getMaxPhysDamage(): ?int { return self::getBonuses()['sum_max_phys_damage']; } /** * Снимает с предмета статус одетого на персонажа в определённом слоте персонажа. * @param $slot_id - номер слота. */ public function undressItem($slot_id) { self::getItemsInSlots(); // Проверяем, что используется один из 12 слотов и наличие предмета в слоте. if (in_array($slot_id, Item::ITEM_TYPES_ALLOWED_IN_SLOTS) && $this->dressedItem->$slot_id) { self::$db->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot = ? AND owner_id = ?', [$slot_id, $this->USERID]); } } public static function undressAllItems($user_id) { return self::$db->execute('UPDATE inventory SET dressed_slot = 0 WHERE dressed_slot BETWEEN 1 AND 12 AND owner_id = ?', $user_id); } }