test
This commit is contained in:
30
classes/DressedItems.php
Normal file
30
classes/DressedItems.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: lopiu
|
||||
* Date: 06.07.2020
|
||||
* Time: 22:41
|
||||
*/
|
||||
|
||||
class DressedItems
|
||||
{
|
||||
protected $DB;
|
||||
private $dressedItem;
|
||||
|
||||
public function __construct(int $user_id)
|
||||
{
|
||||
try {
|
||||
$this->DB = db::c()->query('SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot > 0', $user_id);
|
||||
} catch (\Krugozor\Database\Mysql\Exception $exception) {
|
||||
echo '<div class="debug">' . $exception . '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
public function getDressedItems()
|
||||
{
|
||||
while ($row = $this->DB->fetch_assoc()) {
|
||||
$dressed_item[$row['dressed_slot']] = $row;
|
||||
$this->dressedItem[$row['dressed_slot']] = $row;
|
||||
}
|
||||
return $this->dressedItem;
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,11 @@ class User
|
||||
}
|
||||
}
|
||||
|
||||
private function getDressedItems()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Отображает куклу персонажа (образ и слоты).
|
||||
* @param int $isBattle - установить 1, если куклу нужно отобразить в поединке (показывает параметры при наведении на образ).
|
||||
@@ -60,15 +65,32 @@ class User
|
||||
while ($row = $dressed_items->fetch_assoc()) {
|
||||
$dressed_item[$row['dressed_slot']] = $row;
|
||||
}
|
||||
$di = new DressedItems($this->id);
|
||||
$di->getDressedItems();
|
||||
// for ($i = 1; $i <= 12; $i++) {
|
||||
// echo sprintf('<div class="slot-%s">', $i);
|
||||
// if (isset($dressed_item[$i])) {
|
||||
// if (!$isBattle && $isMain) {
|
||||
// $itemString = '<a href="?edit=1&drop=%s"><img src="/i/sh/%s" class="item-wrap-normal" alt="%s" title="%s"></a>';
|
||||
// echo sprintf($itemString, $i, $dressed_item[$i]['image'], $dressed_item[$i]['name'], $dressed_item[$i]['name']);
|
||||
// } else {
|
||||
// $itemString = '<img src="/i/sh/%s" class="item-wrap-normal tip" alt="%s"><span class="tiptext"><strong>%s</strong></span>';
|
||||
// echo sprintf($itemString, $dressed_item[$i]['image'], $dressed_item[$i]['name'], $dressed_item[$i]['name']);
|
||||
// }
|
||||
// } else {
|
||||
// echo sprintf('<img src="/i/sh/noitem.png" class="item-wrap-normal" title="Пустой слот [%s]" alt="Пустой слот [%s]">', $i, $i);
|
||||
// }
|
||||
// echo sprintf('</div><!-- slot-%s -->', $i);
|
||||
// }
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
echo sprintf('<div class="slot-%s">', $i);
|
||||
if (isset($dressed_item[$i])) {
|
||||
if (isset($di->getDressedItems()[$i])) {
|
||||
if (!$isBattle && $isMain) {
|
||||
$itemString = '<a href="?edit=1&drop=%s"><img src="/i/sh/%s" class="item-wrap-normal" alt="%s" title="%s"></a>';
|
||||
echo sprintf($itemString, $i, $dressed_item[$i]['image'], $dressed_item[$i]['name'], $dressed_item[$i]['name']);
|
||||
echo sprintf($itemString, $i, $di->getDressedItems()[$i]['image'], $di->getDressedItems()[$i]['name'], $di->getDressedItems()[$i]['name']);
|
||||
} else {
|
||||
$itemString = '<img src="/i/sh/%s" class="item-wrap-normal tip" alt="%s"><span class="tiptext"><strong>%s</strong></span>';
|
||||
echo sprintf($itemString, $dressed_item[$i]['image'], $dressed_item[$i]['name'], $dressed_item[$i]['name']);
|
||||
echo sprintf($itemString, $di->getDressedItems()[$i]['image'], $di->getDressedItems()[$i]['name'], $di->getDressedItems()[$i]['name']);
|
||||
}
|
||||
} else {
|
||||
echo sprintf('<img src="/i/sh/noitem.png" class="item-wrap-normal" title="Пустой слот [%s]" alt="Пустой слот [%s]">', $i, $i);
|
||||
|
||||
Reference in New Issue
Block a user