Перенос специализированных методов из глобального класса в более узкий.

This commit is contained in:
lopar 2021-03-10 23:43:48 +02:00
parent 0a07d53be7
commit c99e54af1a
3 changed files with 72 additions and 58 deletions

View File

@ -22,12 +22,16 @@ class InventoryItem extends Item
public function printImage() public function printImage()
{ {
if (in_array($this->item_type, range(1,12))) { if (in_array($this->item_type, range(1, 12))) {
echo "<a href=/main.php?edit=1&dress={$this->item_id} title='Надеть'>"; echo <<<HTML
parent::printImage(); <a href=/main.php?edit=1&dress={$this->item_id} title='Надеть'>
echo "</a>"; <img src="/i/sh/{$this->image}" class="item-wrap-normal" alt="">
</a>
HTML;
} else { } else {
parent::printImage(); echo <<<IMG
<img src="/i/sh/{$this->image}" class="item-wrap-normal" alt="">
IMG;
} }
} }

View File

@ -1,6 +1,6 @@
<?php <?php
namespace Battles; namespace Battles;
abstract class Item class Item
{ {
protected $item_id; protected $item_id;
protected $name; protected $name;
@ -102,14 +102,7 @@ abstract class Item
} }
} }
abstract public function printInfo();
public function printImage()
{
echo <<<IMG
<img src="/i/sh/{$this->image}" class="item-wrap-normal" alt="">
IMG;
}
protected function wrap(int $number):string protected function wrap(int $number):string
{ {

View File

@ -78,31 +78,68 @@ class UserInfo extends UserStats
$this->money . '<br>' . $this->money . '<br>' .
$this->Bank->getMoney(); $this->Bank->getMoney();
} }
$nameString = ''; $nameString = null;
if ($this->align) { $nameString .= $this->align ? "<img src='/i/align_$this->align.png' alt='Склонность'>" : "";
$nameString = sprintf('<img src="/i/align_%s.png" alt="Склонность">', $this->align); $nameString .= $this->block ? "<span class='private' style='text-decoration: line-through;'>$this->login</span>" : "<b>$this->login</b>";
$nameString .= $this->clan ? "<img src='/i/clan/$this->clan.png' alt='Клан'>" : "";
echo <<<HTML
<div class="user-info">
<div class="info"><b>$nameString</b></div><!-- info -->
<div class="stats-container">
<div class="column">$captions</div><!-- column -->
<div class="column">$variables</div><!-- column -->
</div><!-- stats-container -->
</div><!-- user-info -->
HTML;
} }
if ($this->block) {
$nameString .= '<span class="private"><s>' . $this->login . '</s></span>'; /**
} else { * О персонаже для модераторов.
$nameString .= ' <b>' . $this->login . '</b> '; * @return string|null
*/
private function showPrivateData(): ?string
{
if (!$this->watcherIsAdmin || !$this->watcherIsModerator) {
return null;
} }
if ($this->clan) { $birthday = date('d.m.Y', strtotime($this->borndate));
$nameString .= sprintf('<img src="/i/clan/%s.png" alt="Клан">', $this->clan); $userLogs = GameLogs::getUserLogs($this->id);
$log = null;
while ($userLogRow = $userLogs->fetchArray(SQLITE3_ASSOC)) {
$log .= sprintf('<code>%s</code><br>', date('d.m.Y H:i ', strtotime($userLogRow['date'])) . $userLogRow['text']);
} }
echo '<div class="user-info">'; $adminData = $this->watcherIsAdmin ? $this->showAdminOnlyData() : null;
echo '<div class="info">'; return <<<INFO
echo '<b>' . $nameString . '</b>'; <div class="secret-info">
echo '</div><!-- info -->'; E-Mail: $this->email<br>
echo '<div class="stats-container">'; ДР Игрока: $birthday<br>
echo '<div class="column">'; IP Регистрации: $this->ip<br>
echo $captions; $adminData<br>
echo '</div><!-- column -->'; <div class="secret-info-user-log"><b>Личное дело</b><br>
echo '<div class="column">'; $log
echo $variables; </div><!-- secret-info-user-log -->
echo '</div><!-- column -->'; </div><!-- secret-info -->
echo '</div><!-- stats-container -->'; INFO;
echo '</div><!-- user-info -->'; }
/**
* О персонаже для администраторов.
* @return string|null
*/
private function showAdminOnlyData(): ?string
{
$this->Bank = new Bank($this->id);
$bankMoney = $this->Bank->getMoney();
return <<<INFO
ИД Игрока: $this->id<br>
ИД Комнаты: $this->room<br>
Деньги: $this->money<br>
Деньги в банке: $bankMoney<br>
Опыт: $this->experience<br>
Нераспределённые очки: $this->free_stat_points<br>
INFO;
} }
private function Info() private function Info()
@ -110,10 +147,7 @@ class UserInfo extends UserStats
echo '<div class="user-info-container">'; echo '<div class="user-info-container">';
$this->UserInfoDoll(); $this->UserInfoDoll();
$this->UserInfoStats(); $this->UserInfoStats();
echo '<div class="slot-lower">'; echo '<div class="slot-lower"> <!-- statuses! -->';
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><!-- slot-lower -->'; echo '</div><!-- slot-lower -->';
echo '<div class="user-signs">'; echo '<div class="user-signs">';
echo sprintf('<img src="i/zodiac/%s.png" alt="Родовой знак">', $this->showStarSign()); echo sprintf('<img src="i/zodiac/%s.png" alt="Родовой знак">', $this->showStarSign());
@ -129,24 +163,7 @@ class UserInfo extends UserStats
echo nl2br($this->info); echo nl2br($this->info);
} }
echo '</div><!-- user-info-container-lower -->'; echo '</div><!-- user-info-container-lower -->';
echo $this->showPrivateData();
if ($this->watcherIsAdmin || $this->watcherIsModerator) {
echo '<div class="secret-info">';
$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->getMoney(), $this->experience, $this->free_stat_points, $this->session_id);
}
$this->UserLogs = GameLogs::getUserLogs($this->id);
echo '<div class="secret-info-user-log"><b>Личное дело</b><br>';
while ($userLogRow = $this->UserLogs->fetchArray(SQLITE3_ASSOC)) {
echo sprintf('<code>%s</code><br>', date("d.m.Y H:i ", strtotime($userLogRow['date'])) . $userLogRow['text']);
}
echo '</div><!-- secret-info-user-log -->';
echo '</div><!-- secret-info -->';
}
} }
public function showUserInfo() public function showUserInfo()