Отвязались от статой и тяжёлой функции showinf_pers()! Прочие мелкие правки.
This commit is contained in:
parent
5ef6696614
commit
f4d51b69af
171
classes/User.php
171
classes/User.php
@ -24,14 +24,11 @@ class User
|
||||
public $enter_game;
|
||||
public $room;
|
||||
public $block;
|
||||
|
||||
public $shadow;
|
||||
// Пока несуществующие, для совместимости.
|
||||
public $married;
|
||||
public $stats;
|
||||
public $shadow;
|
||||
public $experience;
|
||||
public $stat_points;
|
||||
|
||||
//Статусы того, кто смотрит на информацию.
|
||||
public $watcher_id;
|
||||
protected $watcherIsAdmin;
|
||||
@ -49,33 +46,16 @@ class User
|
||||
}
|
||||
}
|
||||
|
||||
protected function showItem($item)
|
||||
private function UserInfoDoll($isBattle = 0)
|
||||
{
|
||||
$itemSlot = $item['dressed_slot'] ?? 0;
|
||||
$itemName = $item['name'] ?? '';
|
||||
$itemImage = $item['image'] ?? '';
|
||||
if ($itemSlot) {
|
||||
echo <<<SLOT
|
||||
<img src="/i/sh/{$itemImage}" class="item-wrap-normal tip" alt="{$itemName}">
|
||||
<span class="tiptext"><strong>{$itemName}</strong></span>
|
||||
SLOT;
|
||||
} else {
|
||||
echo <<<EMPTY_SLOT
|
||||
<img src="/i/sh/noitem.png" class="item-wrap-normal" title="Пустой слот [{$item}]" alt="Пустой слот [{$item}]">
|
||||
EMPTY_SLOT;
|
||||
}
|
||||
}
|
||||
|
||||
private function UserInfoDoll() {
|
||||
//https://jsfiddle.net/ngx0yvhc
|
||||
$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;
|
||||
}
|
||||
echo '<div class="user-info-container">';
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
echo sprintf('<div class="slot-%s">', $i);
|
||||
if (isset($dressed_item[$i])) {
|
||||
//$this->showItem($dressed_item[$i]);
|
||||
$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 {
|
||||
@ -84,112 +64,46 @@ EMPTY_SLOT;
|
||||
echo sprintf('</div><!-- slot-%s -->', $i);
|
||||
}
|
||||
echo '<div class="slot-image">';
|
||||
echo sprintf('<img src="/i/shadow/%s" alt="%s">', $this->shadow, $this->login);
|
||||
if ($isBattle) {
|
||||
$sh = '<img src="/i/shadow/%s" alt="%s" class="tip"><span class="tiptext"><b>%s</b>Уровень: %s<br>Сила: %s<br>Ловкость: %s<br>Интуиция: %s<br>Выносливость: %s<br>Интеллект: %s<br>Мудрость: %s</span>';
|
||||
echo sprintf($sh, $this->shadow, $this->login, $this->login, $this->level, $this->strength, $this->dexterity, $this->intuition, $this->endurance, $this->intelligence, $this->wisdom);
|
||||
unset($sh);
|
||||
} else {
|
||||
echo '<img src="/i/shadow/' . $this->shadow . '" alt="' . $this->login . '">';
|
||||
}
|
||||
echo '</div><!-- slot-image -->';
|
||||
echo '</div><!-- user-info-container -->';
|
||||
}
|
||||
|
||||
private function UserInfoStats()
|
||||
{
|
||||
$captions = 'Уровень:<br>Сила:<br>Ловкость:<br>Интуиция:<br>Выносливость:<br>Интеллект:<br>Мудрость:<br>Местонахождение:';
|
||||
$variables = $this->level . '<br>' . $this->strength . '<br>' . $this->dexterity . '<br>' . $this->intuition . '<br>' . $this->endurance . '<br>' . $this->intelligence . '<br>' . $this->wisdom . '<br>' . $this->getRoomName($this->room);
|
||||
echo '<div class="user-info">';
|
||||
echo '<div class="stats-container">';
|
||||
echo '<div class="column">';
|
||||
echo $captions;
|
||||
echo '</div><!-- column -->';
|
||||
echo '<div class="column">';
|
||||
echo $variables;
|
||||
echo '</div><!-- column -->';
|
||||
echo '</div><!-- stats-container -->';
|
||||
echo '<div class="debug">TODO: Сделать отображение имени. Сделать рассчёт здоровья и модификаторов. Вывести полоску здоровья когда будет от чего отталкиваться.</div>';
|
||||
echo '</div><!-- user-info -->';
|
||||
}
|
||||
|
||||
private function UserInfo()
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
echo '<div class="user-info-container">';
|
||||
echo '<div class="slot-1">';
|
||||
if (isset($dressed_item[1])) {
|
||||
$this->showItem($dressed_item[1]);
|
||||
} else {
|
||||
$this->showItem(1);
|
||||
}
|
||||
echo '</div><!-- slot-1 -->';
|
||||
echo '<div class="slot-2">';
|
||||
if (isset($dressed_item[2])) {
|
||||
$this->showItem($dressed_item[2]);
|
||||
} else {
|
||||
$this->showItem(2);
|
||||
}
|
||||
echo '</div><!-- slot-2 -->';
|
||||
echo '<div class="slot-3">';
|
||||
if (isset($dressed_item[3])) {
|
||||
$this->showItem($dressed_item[3]);
|
||||
} else {
|
||||
$this->showItem(3);
|
||||
}
|
||||
echo '</div><!-- slot-3 -->';
|
||||
echo '<div class="slot-4">';
|
||||
if (isset($dressed_item[4])) {
|
||||
$this->showItem($dressed_item[4]);
|
||||
} else {
|
||||
$this->showItem(4);
|
||||
}
|
||||
echo '</div><!-- slot-4 -->';
|
||||
echo '<div class="slot-5">';
|
||||
if (isset($dressed_item[5])) {
|
||||
$this->showItem($dressed_item[5]);
|
||||
} else {
|
||||
$this->showItem(5);
|
||||
}
|
||||
echo '</div><!-- slot-5 -->';
|
||||
echo '<div class="slot-6">';
|
||||
if (isset($dressed_item[6])) {
|
||||
$this->showItem($dressed_item[6]);
|
||||
} else {
|
||||
$this->showItem(6);
|
||||
}
|
||||
echo '</div><!-- slot-6 -->';
|
||||
echo '<div class="slot-7">';
|
||||
if (isset($dressed_item[7])) {
|
||||
$this->showItem($dressed_item[7]);
|
||||
} else {
|
||||
$this->showItem(7);
|
||||
}
|
||||
echo '</div><!-- slot-7 -->';
|
||||
echo '<div class="slot-8">';
|
||||
if (isset($dressed_item[8])) {
|
||||
$this->showItem($dressed_item[8]);
|
||||
} else {
|
||||
$this->showItem(8);
|
||||
}
|
||||
echo '</div><!-- slot-8 -->';
|
||||
$this->UserInfoDoll();
|
||||
$this->UserInfoStats();
|
||||
echo '<div class="slot-lower">';
|
||||
if (isset($dressed_item[9])) {
|
||||
$this->showItem($dressed_item[9]);
|
||||
} else {
|
||||
$this->showItem(9);
|
||||
}
|
||||
if (isset($dressed_item[10])) {
|
||||
$this->showItem($dressed_item[10]);
|
||||
} else {
|
||||
$this->showItem(10);
|
||||
}
|
||||
if (isset($dressed_item[11])) {
|
||||
$this->showItem($dressed_item[11]);
|
||||
} else {
|
||||
$this->showItem(11);
|
||||
}
|
||||
echo '</div><!-- slot-lower -->';
|
||||
echo '<div class="slot-image">';
|
||||
echo sprintf('<img src="/i/shadow/%s" alt="%s">', $this->shadow, $this->login);
|
||||
echo '</div><!-- slot-image -->';
|
||||
echo '<div class="user-signs">';
|
||||
echo sprintf('<img src="i/zodiac/%s.png" alt="Родовой знак">', $this->showStarSign());
|
||||
echo '</div><!-- user-signs -->';
|
||||
echo '<div class="user-info">';
|
||||
echo '<div class="stats-container">';
|
||||
echo '<div class="column">';
|
||||
echo 'Уровень:<br>Сила:<br>Ловкость:<br>Интуиция:<br>Выносливость:<br>Интеллект:<br>Мудрость:<br>Местонахождение:';
|
||||
echo '</div><!-- column -->';
|
||||
echo '<div class="column">';
|
||||
echo $this->level . '<br>' . $this->strength . '<br>' . $this->dexterity . '<br>' . $this->intuition . '<br>' . $this->endurance . '<br>' . $this->intelligence . '<br>' . $this->wisdom . '<br>' . $this->getRoomName($this->room);
|
||||
echo '</div><!-- column -->';
|
||||
echo '</div><!-- stats-container -->';
|
||||
if ($this->married) {
|
||||
echo sprintf('<a href = "inf.php?%s" target = _blank ><img alt = "В браке с %s" src = "i/married.gif" title = "В браке с %s"></a >', $this->married, $this->married, $this->married);
|
||||
}
|
||||
echo '<div class="debug">TODO: Сделать отображение имени. Сделать рассчёт здоровья и модификаторов. Вывести полоску здоровья когда будет от чего отталкиваться.</div>';
|
||||
echo '</div><!-- user-info -->';
|
||||
echo '</div><!-- slot-lower -->';
|
||||
echo '<div class="user-signs">';
|
||||
echo sprintf('<img src="i/zodiac/%s.png" alt="Родовой знак">', $this->showStarSign());
|
||||
echo '</div><!-- user-signs -->';
|
||||
echo '</div><!-- user-info-container -->';
|
||||
echo '<hr><!-- Нижняя часть -->';
|
||||
echo '<div class="user-info-container-lower">';
|
||||
@ -204,15 +118,15 @@ EMPTY_SLOT;
|
||||
|
||||
if ($this->watcherIsAdmin || $this->watcherIsModerator) {
|
||||
echo '<div class="secret-info">';
|
||||
$infoString = '<b>Личное дело</b><br>E-Mail: %s<br> ДР Игрока: %s<br> IP Регистрации: %s';
|
||||
$infoString = 'E-Mail: %s<br> ДР Игрока: %s<br> IP Регистрации: %s';
|
||||
echo sprintf($infoString, $this->email, date('d.m.Y', strtotime($this->borndate)), $this->ip);
|
||||
if ($this->watcherIsAdmin) {
|
||||
$this->Bank = new Bank($this->id);
|
||||
$infoString = '<br><span>ИД Игрока: %s<br> ИД Комнаты: %s<br> Деньги: %s<br> Деньги в банке: %s<br> Опыт: %s<br> Нераспределённые очки: %s<br> Текущая сессия: %s</span>';
|
||||
echo sprintf($infoString, $this->id, $this->room, $this->money, $this->Bank->money, $this->experience, $this->stat_points, $this->email, $this->session_id);
|
||||
echo sprintf($infoString, $this->id, $this->room, $this->money, $this->Bank->money, $this->experience, $this->stat_points, $this->session_id);
|
||||
}
|
||||
$this->UserLogs = new UserLogModel($this->id);
|
||||
echo '<div class="secret-info-user-log">';
|
||||
echo '<div class="secret-info-user-log"><b>Личное дело</b><br>';
|
||||
while ($userLogRow = $this->UserLogs->getUserLog()->fetch_object()) {
|
||||
echo sprintf('<code>%s</code><br>', date("d.m.Y H:i ", strtotime($userLogRow->date)) . $userLogRow->text);
|
||||
}
|
||||
@ -221,7 +135,8 @@ EMPTY_SLOT;
|
||||
}
|
||||
}
|
||||
|
||||
private function WatcherStatus() {
|
||||
private function WatcherStatus()
|
||||
{
|
||||
$query = db::c()->query('SELECT `align`,`admin` FROM `users` WHERE `id` = ?i', $this->watcher_id)->fetch_assoc();
|
||||
if ($query['admin']) {
|
||||
$this->watcherIsAdmin = 1;
|
||||
@ -246,10 +161,17 @@ EMPTY_SLOT;
|
||||
}
|
||||
throw new Exception('<span class="error">Персонаж ' . $this->login . ' обезличен ' . $date . '.</span>');
|
||||
} else {
|
||||
$this->UserInfoDoll();
|
||||
$this->UserInfo();
|
||||
}
|
||||
}
|
||||
|
||||
public function showUserInfoInBattle()
|
||||
{
|
||||
echo '<div class="user-info-container">';
|
||||
$this->UserInfoDoll(1);
|
||||
echo '</div><!-- user-info-container -->';
|
||||
}
|
||||
|
||||
public function showStarSign()
|
||||
{
|
||||
/*
|
||||
@ -291,5 +213,4 @@ EMPTY_SLOT;
|
||||
}
|
||||
return $sign ?? null;
|
||||
}
|
||||
|
||||
}
|
@ -416,12 +416,14 @@ div.debug {
|
||||
border:1px dashed #faf;
|
||||
border-radius:5px;
|
||||
padding:5px;
|
||||
margin: 3px;
|
||||
}
|
||||
div.secret-info {
|
||||
background:#fee;
|
||||
border:1px dashed #faa;
|
||||
border-radius:5px;
|
||||
padding:5px;
|
||||
margin: 3px;
|
||||
}
|
||||
div.secret-info > span {
|
||||
color: #966;
|
||||
|
@ -150,7 +150,10 @@ $fbattle = new fbattle($user['battle']);
|
||||
<table width=250 cellspacing=0 cellpadding=0>
|
||||
<tr>
|
||||
<td valign=top width=250 nowrap>
|
||||
<?php echo showinf_pers($user['id'], 1, 1); ?>
|
||||
<?php
|
||||
$myinfo = new User($_SESSION['uid']);
|
||||
$myinfo->showUserInfoInBattle();
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -484,7 +487,8 @@ $fbattle = new fbattle($user['battle']);
|
||||
<?php
|
||||
|
||||
if ($fbattle->return == 1) {
|
||||
echo showinf_pers($fbattle->enemy, 1);
|
||||
$enemyInfo = new User($fbattle->enemy);
|
||||
$enemyInfo->showUserInfoInBattle();
|
||||
} else {
|
||||
if ($fbattle->battle_data['type'] == 4 || $fbattle->battle_data['type'] == 5) {
|
||||
$a = [6, 16];
|
||||
|
Loading…
Reference in New Issue
Block a user