$value) {
if (isset($row[$key])) {
$this->$key = $row[$key];
}
}
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 = 'Хлам';
}
}
abstract public function printInfo();
public function printImage()
{
echo <<
IMG;
}
protected function wrap(int $number):string
{
if ($number > 0) {
return ": " . $number . "";
} else {
return ": " . $number . "";
}
}
protected function printAllInfo()
{
$lines = [
"Долговечность" => $this->durability,
];
echo "" . $this->name . " (Масса: " . $this->weight . ")";
if ($this->durability) {
echo "
Долговечность: " . $this->durability;
}
echo "
{$this->typename}
";
if ($this->need_strength > 0) {
echo "
Требуется сила" . $this->wrap($this->need_strength);
}
if ($this->need_dexterity > 0) {
echo "
Требуется ловкость" . $this->wrap($this->need_dexterity);
}
if ($this->need_intuition > 0) {
echo "
Требуется интуиция" . $this->wrap($this->need_intuition);
}
if ($this->need_endurance > 0) {
echo "
Требуется выносливость" . $this->wrap($this->need_endurance);
}
if ($this->need_intelligence > 0) {
echo "
Требуется интеллект" . $this->wrap($this->need_intelligence);
}
if ($this->need_wisdom > 0) {
echo "
Требуется мудрость" . $this->wrap($this->need_wisdom);
}
if ($this->add_strength) {
echo "
Сила" . $this->wrap($this->add_strength);
}
if ($this->add_dexterity) {
echo "
Ловкость" . $this->wrap($this->add_dexterity);
}
if ($this->add_intuition) {
echo "
Интуиция" . $this->wrap($this->add_intuition);
}
if ($this->add_endurance) {
echo "
Выносливость" . $this->wrap($this->add_endurance);
}
if ($this->add_intelligence) {
echo "
Интеллект" . $this->wrap($this->add_intelligence);
}
if ($this->add_wisdom) {
echo "
Мудрость" . $this->wrap($this->add_wisdom);
}
if ($this->add_accuracy) {
echo "
Точность" . $this->wrap($this->add_accuracy);
}
if ($this->add_evasion) {
echo "
Увёртливость" . $this->wrap($this->add_evasion);
}
if ($this->add_criticals) {
echo "
Шанс крита" . $this->wrap($this->add_criticals);
}
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;
}
}
}