battles/classes/User.php

86 lines
2.4 KiB
PHP
Raw Normal View History

<?php
class User
{
public $id;
public $login;
public $email;
public $realname;
public $borndate;
public $info;
public $level;
public $align;
public $clan;
public $money;
public $strength;
public $dexterity;
public $intuition;
public $endurance;
public $intelligence;
public $wisdom;
public $ip;
public $session_id;
public $admin;
public $enter_game;
public $room;
public $block;
// Пока несуществующие, для совместимости.
public $married;
public $exp;
public $stats;
public $shadow;
2020-07-04 10:49:43 +00:00
use Rooms;
2020-07-03 13:33:34 +00:00
public function __construct($user)
{
$user_query = db::c()->query('SELECT * FROM users WHERE id = "?s" OR login = "?s"', $user, $user)->fetch_assoc();
foreach ($this as $key => $value) {
if (isset($user_query[$key])) {
$this->$key = $user_query[$key];
}
}
}
protected function showItem(array $item)
{
if ($item) {
echo sprintf('<img src="/i/sh/%s" class="item-wrap-normal tip"><span class="tiptext"><strong>%s</strong></span>', $item['image'], $item['name']);
} else {
echo "<img src='/i/sh/noitem.png' class='item-wrap-normal' title='Пустой слот'>";
}
}
2020-07-04 10:49:43 +00:00
public function showUserInfo() {
$dressed_item = [];
$dressed_items = db::c()->query('SELECT * FROM inventory WHERE owner_id = ?i AND dressed_slot > 0', $this->id);
while ($row = $dressed_items->fetch_assoc()) {
$dressed_item[$row['dressed_slot']] = $row;
}
include_once 'views/user-info-doll.php';
echo <<<USERINFO
Имя {$this->login} <br>
Сила {$this->strength} <br>
Ловкость {$this->dexterity} <br>
Интуиция {$this->intuition} <br>
Выносливость {$this->endurance} <br>
Интеллект {$this->intelligence} <br>
Мудрость {$this->wisdom} <br>
Находится в {$this->getRoomName($this->room)}<br>
Предметы на тушке: <br>
USERINFO;
// if (isset($dressed_item[1])) {
// $this->showItem($dressed_item[1]);
// }
// if (isset($dressed_item[2])) {
// $this->showItem($dressed_item[2]);
// }
// if (isset($dressed_item[4])) {
// $this->showItem($dressed_item[4]);
// }
2020-07-04 10:49:43 +00:00
}
}