$value) { if (isset($row[$key])) { $this->$key = $row[$key]; } } } elseif (is_object($row)) { foreach ($this as $name => $value) { if (isset($row->$name)) { $this->$name = $row->$name; } } } switch ($this->item_type) { case self::ITEM_TYPE_HELMET: $this->typename = 'Шлем'; break; case self::ITEM_TYPE_ARMOR: $this->typename = 'Броня'; break; case self::ITEM_TYPE_LEGS: $this->typename = 'Поножи'; break; case self::ITEM_TYPE_BOOTS: $this->typename = 'Сапоги'; break; case self::ITEM_TYPE_GLOVES: $this->typename = 'Перчатки'; break; case self::ITEM_TYPE_WEAPON: $this->typename = 'Оружие'; break; case self::ITEM_TYPE_SHIELD: $this->typename = 'Щит'; break; case self::ITEM_TYPE_BELT: $this->typename = 'Пояс'; break; case self::ITEM_TYPE_RING: $this->typename = 'Кольцо'; break; case self::ITEM_TYPE_AMULET: $this->typename = 'Амулет'; break; case self::ITEM_TYPE_CONSUMABLE: $this->typename = 'Расходуемый предмет'; break; default: $this->typename = 'Хлам'; } } protected function wrap(int $number):string { if ($number > 0) { return ": " . $number . ""; } else { return ": " . $number . ""; } } protected function printAllInfo() { $needsLines = [ "сила" => $this->need_strength, "ловкость" =>$this->need_dexterity, "интуиция" =>$this->need_intuition, "выносливость" =>$this->need_endurance, "интеллект" =>$this->need_intelligence, "мудрость" =>$this->need_wisdom, ]; $addsLines = [ "Сила" => $this->add_strength, "Ловкость" => $this->add_dexterity, "Интуиция" => $this->add_intuition, "Выносливость" => $this->add_endurance, "Интеллект" => $this->add_intelligence, "Мудрость" => $this->add_wisdom, "Точность" => $this->add_accuracy, "Увёртливость" => $this->add_evasion, "Шанс крита" => $this->add_criticals, ]; echo "$this->name (Масса: $this->weight)"; echo "
Долговечность: " . $this->durability; echo "
$this->typename
"; foreach ($needsLines as $stat => $value) { if ($value > 0) { echo "
Требуется $stat" . $this->wrap($value); } } foreach ($addsLines as $stat => $value) { if ($value) { echo "
$stat" . $this->wrap($value); } } if ($this->add_min_physical_damage && !$this->add_max_physical_damage) { $damage = $this->add_min_physical_damage . " - " . $this->add_min_physical_damage; } elseif (!$this->add_min_physical_damage && $this->add_max_physical_damage) { $damage = $this->add_max_physical_damage . " - " . $this->add_max_physical_damage; } elseif ($this->add_min_physical_damage && $this->add_max_physical_damage) { $damage = $this->add_min_physical_damage . " - " . $this->add_max_physical_damage; } if (isset($damage)) { echo "
Урон: " . $damage; } } }