battles/classes/Item.php

276 lines
9.8 KiB
PHP
Raw Normal View History

2019-01-11 16:02:57 +00:00
<?php
2019-01-11 19:16:39 +00:00
abstract class Item
2019-01-11 16:02:57 +00:00
{
2019-01-14 14:31:42 +00:00
public $id;
2019-01-11 16:02:57 +00:00
public $name;
public $nalign;
2019-01-14 14:31:42 +00:00
public $massa;
2019-01-11 16:02:57 +00:00
public $maxdur;
public $img;
2019-01-14 14:31:42 +00:00
public $count;
public $razdel;
public $cost;
public $ecost;
2019-01-14 14:40:12 +00:00
public $artefact;
2019-01-11 16:02:57 +00:00
2019-01-12 09:34:24 +00:00
public $type; # эти. что есть что нет...
2019-01-11 22:18:18 +00:00
2019-01-11 16:02:57 +00:00
public $nlevel;
public $nsila;
public $nlovk;
public $ninta;
public $nvinos;
public $nintel;
public $nmudra;
public $nnoj;
public $ntopor;
public $ndubina;
public $nmech;
public $nfire;
public $nwater;
public $nair;
public $nearth;
public $nlight;
public $ngray;
public $ndark;
public $minu;
public $maxu;
public $gsila;
public $glovk;
public $ginta;
public $gintel;
public $gnoj;
public $gtopor;
public $gdubina;
public $gmech;
public $gfire;
public $gwater;
public $gair;
public $gearth;
public $glight;
public $ggray;
public $gdark;
public $ghp;
public $bron1;
public $bron2;
public $bron3;
public $bron4;
public $mfkrit;
public $mfakrit;
public $mfuvorot;
public $mfauvorot;
2019-01-14 14:31:42 +00:00
public $shshop;
public $dategoden;
public $goden;
public $needident;
2019-01-14 13:46:20 +00:00
public $magic;
2019-01-14 14:18:04 +00:00
public $magic_name;
2019-01-14 13:46:20 +00:00
public $magic_img;
2019-01-14 14:31:42 +00:00
public $isrep;
public $gmp;
public $zeton;
public $encicl;
public $onlyone;
public $koll;
public $prof;
public $prof1;
2019-01-14 13:46:20 +00:00
2019-01-11 16:26:33 +00:00
/**
* Item constructor.
*
* @param $row
*/
2019-01-11 16:02:57 +00:00
public function __construct($row)
{
2019-01-14 14:31:42 +00:00
foreach ($this as $key => $value) {
2019-01-14 14:42:05 +00:00
if (!empty($key)) {
$this->$key = $row[$key];
}
2019-01-14 14:31:42 +00:00
2019-01-14 13:46:20 +00:00
}
2019-01-14 14:18:04 +00:00
2019-01-14 13:46:20 +00:00
// ТА ЛААААДНО?!
// $this->name = $row['name'];
// $this->massa = $row['massa'];
// $this->maxdur = $row['maxdur'];
// $this->img = $row['img'];
//
// $this->type = $row['type'];
//
// $this->nlevel = $row['nlevel'];
// $this->nalign = $row['nalign'];
// $this->nsila = $row['nsila'];
// $this->nlovk = $row['nlovk'];
// $this->ninta = $row['ninta'];
// $this->nvinos = $row['nvinos'];
// $this->nintel = $row['nintel'];
// $this->nmudra = $row['nmudra'];
// $this->nnoj = $row['nnoj'];
// $this->ntopor = $row['ntopor'];
// $this->ndubina = $row['ndubina'];
// $this->nmech = $row['nmech'];
// $this->nfire = $row['nfire'];
// $this->nwater = $row['nwater'];
// $this->nair = $row['nair'];
// $this->nearth = $row['nearth'];
// $this->nlight = $row['nlight'];
// $this->ngray = $row['ngray'];
// $this->ndark = $row['ndark'];
//
// $this->minu = $row['minu'];
// $this->maxu = $row['maxu'];
//
// $this->gsila = $row['gsila'];
// $this->glovk = $row['glovk'];
// $this->ginta = $row['ginta'];
// $this->gintel = $row['gintel'];
// $this->gnoj = $row['gnoj'];
// $this->gtopor = $row['gtopor'];
// $this->gdubina = $row['gdubina'];
// $this->gmech = $row['gmech'];
// $this->gfire = $row['gfire'];
// $this->gwater = $row['gwater'];
// $this->gair = $row['gair'];
// $this->gearth = $row['gearth'];
// $this->glight = $row['glight'];
// $this->ggray = $row['ggray'];
// $this->gdark = $row['gdark'];
// $this->ghp = $row['ghp'];
//
// $this->bron1 = $row['bron1'];
// $this->bron2 = $row['bron2'];
// $this->bron3 = $row['bron3'];
// $this->bron4 = $row['bron4'];
//
// $this->mfkrit = $row['mfkrit'];
// $this->mfakrit = $row['mfakrit'];
// $this->mfuvorot = $row['mfuvorot'];
// $this->mfauvorot = $row['mfauvorot'];
2019-01-11 22:50:10 +00:00
switch ($this->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 8:
$this->typename = 'Шлем';
break;
case 9:
$this->typename = 'Перчатки';
break;
case 10:
$this->typename = 'Щит';
break;
case 11:
$this->typename = 'Обувь';
break;
case 12:
$this->typename = 'Магический свиток';
break;
case 22:
$this->typename = 'Рубашка';
break;
case 50:
$this->typename = 'Волшебное зелье';
break;
case 200:
$this->typename = 'Сувенир';
break;
default:
$this->typename = 'Хлам';
2019-01-11 22:50:10 +00:00
}
2019-01-11 16:02:57 +00:00
}
2019-01-11 19:39:37 +00:00
2019-01-12 10:17:20 +00:00
abstract public function printInfo();
2019-01-12 20:02:08 +00:00
public function printImage()
2019-01-11 19:39:37 +00:00
{
2019-01-12 19:51:08 +00:00
echo <<<IMG
2019-01-12 20:02:08 +00:00
<img src="//{$_SERVER['SERVER_NAME']}/i/sh/{$this->img}" class="item-wrap-normal">
2019-01-12 19:51:08 +00:00
IMG;
2019-01-11 19:39:37 +00:00
}
2019-01-11 19:49:00 +00:00
2019-01-11 20:05:09 +00:00
protected function wrap($number)
{
if ($number > 0) return ": <b>" . $number . "</b>";
else return ": <b style='color: maroon;'>" . $number . "</b>";
}
2019-01-11 19:49:00 +00:00
protected function printBaseInfo()
{
2019-01-12 10:12:02 +00:00
echo "<b>" . $this->name . "</b> (Масса: " . $this->massa . ")";
2019-01-11 19:49:00 +00:00
if ($this->nalign) echo " <img src=i/align_{$this->nalign}.gif title='Этот предмет могут использовать только игроки с определённой склонностью.'> ";
if ($this->maxdur > 0) echo "<br>Долговечность: {$this->maxdur}";
if ($this->maxdur == -1) echo "<br>Долговечность: <i>неразрушимо</i>";
2019-01-12 09:36:26 +00:00
echo "<br><i>{$this->typename}</i>";
2019-01-11 19:49:00 +00:00
}
2019-01-11 20:05:09 +00:00
protected function printRequirements()
{
if ($this->nlevel > 0) echo "<br>Требуется уровень" . $this->wrap($this->nlevel);
if ($this->nnoj > 0) echo "<br>Требуется владение колющим оружиием" . $this->wrap($this->nnoj);
if ($this->ndubina > 0) echo "<br>Требуется владение дробящим оружием" . $this->wrap($this->ndubina);
if ($this->ntopor > 0) echo "<br>Требуется владение рубящим оружием" . $this->wrap($this->ntopor);
if ($this->nmech > 0) echo "<br>Требуется владение режущим оружием" . $this->wrap($this->nmech);
if ($this->nsila > 0) echo "<br>Требуется сила" . $this->wrap($this->nsila);
if ($this->nlovk > 0) echo "<br>Требуется ловкость" . $this->wrap($this->nlovk);
if ($this->ninta > 0) echo "<br>Требуется интуиция" . $this->wrap($this->ninta);
if ($this->nvinos > 0) echo "<br>Требуется выносливость" . $this->wrap($this->nvinos);
if ($this->nintel > 0) echo "<br>Требуется интеллект" . $this->wrap($this->nintel);
}
protected function printBonuses()
{
if ($this->gsila) echo "<br>Сила" . $this->wrap($this->gsila);
if ($this->glovk) echo "<br>Ловкость" . $this->wrap($this->glovk);
if ($this->ginta) echo "<br>Интуиция" . $this->wrap($this->ginta);
if ($this->gintel) echo "<br>Интеллект" . $this->wrap($this->gintel);
if ($this->minu AND $this->maxu) echo "<br>Урон: {$this->minu} - {$this->maxu}";
if ($this->ghp) echo "<br>Здоровье" . $this->wrap($this->ghp);
if ($this->gnoj) echo "<br>Владение колющим оружиием" . $this->wrap($this->gnoj);
if ($this->gdubina) echo "<br>Владение дробящим оружием" . $this->wrap($this->gdubina);
if ($this->gtopor) echo "<br>Владение рубящим оружием" . $this->wrap($this->gtopor);
if ($this->gmech) echo "<br>Владение режущим оружием" . $this->wrap($this->gmech);
if ($this->gfire) echo "<br>Владение магией огня" . $this->wrap($this->gfire);
if ($this->gwater) echo "<br>Владение магией воды" . $this->wrap($this->gwater);
if ($this->gair) echo "<br>Владение магией воздуха" . $this->wrap($this->gair);
if ($this->gearth) echo "<br>Владение магией земли" . $this->wrap($this->gearth);
if ($this->glight) echo "<br>Владение магией света" . $this->wrap($this->glight);
if ($this->ggray) echo "<br>Владение магией серости" . $this->wrap($this->ggray);
if ($this->gdark) echo "<br>Владение магией тьмы" . $this->wrap($this->gdark);
if ($this->bron1) echo "<br>Броня головы" . $this->wrap($this->bron1);
if ($this->bron2) echo "<br>Броня корпуса" . $this->wrap($this->bron2);
if ($this->bron3) echo "<br>Броня пояса" . $this->wrap($this->bron3);
if ($this->bron4) echo "<br>Броня ног" . $this->wrap($this->bron4);
2019-01-11 20:05:09 +00:00
}
2019-01-14 13:46:20 +00:00
protected function printMagic()
{
2019-01-14 14:31:42 +00:00
if ($this->magic AND $this->type != 12) {
2019-01-14 13:46:20 +00:00
echo "<br>Магические свойства:";
if ($this->magic_name) echo "<br><i style='color: dimgray;'>{$this->magic_name}</i>";
2019-01-14 14:18:04 +00:00
else echo "<br><i style='color: dimgray;'>Неопознанная магия</i>";
2019-01-14 14:31:42 +00:00
if ($this->magic_img AND $this->type != 50) echo <<<IMG
2019-01-14 14:18:04 +00:00
<br><img src="//{$_SERVER['SERVER_NAME']}/i/sh/{$this->magic_img}" class="item-wrap-normal">
2019-01-14 13:46:20 +00:00
IMG;
}
}
2019-01-11 16:02:57 +00:00
}