From 98213698e8591304118fdeb7605c835f0e00860f Mon Sep 17 00:00:00 2001 From: "Igor Barkov [iwork]" Date: Mon, 14 Jan 2019 15:46:20 +0200 Subject: [PATCH] it works?! --- classes/Item.php | 131 +++++++++++++++++++++++++++-------------------- test.php | 11 +++- 2 files changed, 85 insertions(+), 57 deletions(-) diff --git a/classes/Item.php b/classes/Item.php index 2a2a088..e87eb6c 100644 --- a/classes/Item.php +++ b/classes/Item.php @@ -60,6 +60,10 @@ abstract class Item public $mfuvorot; public $mfauvorot; + public $magic; + public $magic_name = 'Неизвестная магия'; + public $magic_img; + /** * Item constructor. * @@ -67,62 +71,66 @@ abstract class Item */ public function __construct($row) { - $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']; + foreach ($this as $key=>$value) { + $this->$key = $row[$key]; + } + // ТА ЛААААДНО?! +// $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']; switch ($this->type) { case 1: @@ -232,4 +240,15 @@ IMG; if ($this->bron3) echo "
Броня пояса" . $this->wrap($this->bron3); if ($this->bron4) echo "
Броня ног" . $this->wrap($this->bron4); } + + protected function printMagic() + { + if ($this->magic) { + echo "
Магические свойства:"; + if ($this->magic_name) echo "
{$this->magic_name}"; + if ($this->magic_img) echo << +IMG; + } + } } \ No newline at end of file diff --git a/test.php b/test.php index 2e9d4c1..b4d3fec 100644 --- a/test.php +++ b/test.php @@ -15,7 +15,16 @@ require_once 'config.php'; # $items = []; foreach(фетч того ебучего массива as $value) {$items[$value['id']] = $value} $iteminfo =[]; -$result = db::c()->query('SELECT * FROM `shop` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE count > 0 LIMIT 25'); +$result = db::c()->query('SELECT `shop`.*, + `magic`.`name` AS `magic_name`, + `magic`.`chanse` AS `magic_chanse`, + `magic`.`time` AS `magic_time`, + `magic`.`file` AS `magic_file`, + `magic`.`targeted` AS `magic_targeted`, + `magic`.`needcharge` AS `magic_needcharge`, + `magic`.`img` AS `magic_img` + +FROM `shop` LEFT JOIN `magic` ON `magic` = `magic`.`id` WHERE count > 0 LIMIT 25'); $result2 = db::c()->query('SELECT * FROM `inventory` WHERE owner = 11263'); while ($row = $result->fetch_assoc()) { $iteminfo[] = new ShopItem($row);