USERID = $user_id; } public static function getDressedItemBySlot($itemSlot, $ownerId) { return self::$db->fetch('SELECT * FROM inventory WHERE owner_id = ? AND dressed_slot = ?', [$ownerId, $itemSlot]); } public function getItemsInSlots() { $items = self::$db->fetchALL('SELECT * FROM inventory WHERE owner_id = ? AND dressed_slot > 0', $this->USERID); $i = 0; while ($i < count($items)) { $this->dressedItem[$items['dressed_slot']] = $items; $i++; } return $this->dressedItem; } private function getBonuses(): array { $query = << 0 SQL; return self::$db->fetch($query, $this->USERID); } public function getStrengthBonus(): ?int { return self::getBonuses()['sum_strength']; } public function getDexterityBonus(): ?int { return self::getBonuses()['sum_dexterity']; } public function getIntuitionBonus(): ?int { return self::getBonuses()['sum_intuition']; } public function getEnduranceBonus(): ?int { return self::getBonuses()['sum_endurance']; } public function getIntelliganceBonus(): ?int { return self::getBonuses()['sum_intelligence']; } public function getWisdomBonus(): ?int { return self::getBonuses()['sum_wisdom']; } 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]); } } }