battles/classes/Item.php

162 lines
5.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
abstract class Item
{
public $item_id;
public $name;
public $item_type;
public $durability;
public $price;
public $need_strength;
public $need_dexterity;
public $need_intuition;
public $need_endurance;
public $need_intelligence;
public $need_wisdom;
public $add_strength;
public $add_dexterity;
public $add_intuition;
public $add_endurance;
public $add_intelligence;
public $add_wisdom;
public $add_accuracy;
public $add_evasion;
public $add_criticals;
public $add_min_physical_damage;
public $add_max_physical_damage;
public $weight;
public $image;
/**
* Item constructor.
*
* @param $row
*/
public function __construct($row)
{
foreach ($this as $key => $value) {
if (isset($row[$key])) {
$this->$key = $row[$key];
}
}
switch ($this->item_type) {
case 1:
$this->typename = 'Шлем';
break;
case 2:
$this->typename = 'Броня';
break;
case 3:
$this->typename = 'Поножи';
break;
case 4:
$this->typename = 'Сапоги';
break;
case 5:
$this->typename = 'Перчатки';
break;
case 6:
$this->typename = 'Оружие';
break;
case 7:
$this->typename = 'Щит';
break;
case 8:
$this->typename = 'Пояс';
break;
case 9:
case 10:
case 11:
$this->typename = 'Кольцо';
break;
case 12:
$this->typename = 'Амулет';
break;
default:
$this->typename = 'Хлам';
}
}
abstract public function printInfo();
public function printImage()
{
echo <<<IMG
<img src="//{$_SERVER['SERVER_NAME']}/i/sh/{$this->image}" class="item-wrap-normal">
IMG;
}
protected function wrap($number)
{
if ($number > 0) {
return ": <b>" . $number . "</b>";
} else {
return ": <b style='color: maroon;'>" . $number . "</b>";
}
}
protected function printAllInfo()
{
echo "<b>" . $this->name . "</b> (Масса: " . $this->weight . ")";
if ($this->durability) {
echo "<br> Долговечность:" . $this->durability;
}
echo "<br><em>{$this->typename}</em><br>";
if ($this->need_strength > 0) {
echo "<br>Требуется сила" . $this->wrap($this->need_strength);
}
if ($this->need_dexterity > 0) {
echo "<br>Требуется ловкость" . $this->wrap($this->need_dexterity);
}
if ($this->need_intuition > 0) {
echo "<br>Требуется интуиция" . $this->wrap($this->need_intuition);
}
if ($this->need_endurance > 0) {
echo "<br>Требуется выносливость" . $this->wrap($this->need_endurance);
}
if ($this->need_intelligence > 0) {
echo "<br>Требуется интеллект" . $this->wrap($this->need_intelligence);
}
if ($this->need_wisdom > 0) {
echo "<br>Требуется мудрость" . $this->wrap($this->need_wisdom);
}
if ($this->add_strength > 0) {
echo "<br>Сила" . $this->wrap($this->add_strength);
}
if ($this->add_dexterity) {
echo "<br>Ловкость" . $this->wrap($this->add_dexterity);
}
if ($this->add_intuition) {
echo "<br>Интуиция" . $this->wrap($this->add_intuition);
}
if ($this->add_endurance) {
echo "<br>Выносливость" . $this->wrap($this->add_endurance);
}
if ($this->add_intelligence) {
echo "<br>Интеллект" . $this->wrap($this->add_intelligence);
}
if ($this->add_wisdom) {
echo "<br>Мудрость" . $this->wrap($this->add_wisdom);
}
if ($this->add_accuracy) {
echo "<br>Точность" . $this->wrap($this->add_accuracy);
}
if ($this->add_evasion) {
echo "<br>Увёртливость" . $this->wrap($this->add_evasion);
}
if ($this->add_criticals) {
echo "<br>Шанс крита" . $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 ($damage) {
echo "Урон: " . $damage;
}
}
}