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

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()
{
if (in_array($this->item_type, range(1,12))) {
echo "<a href=/main.php?edit=1&dress={$this->item_id} title='Надеть'>";
parent::printImage();
echo "</a>";
if (in_array($this->item_type, range(1, 12))) {
echo <<<HTML
<a href=/main.php?edit=1&dress={$this->item_id} title='Надеть'>
<img src="/i/sh/{$this->image}" class="item-wrap-normal" alt="">
</a>
HTML;
} else {
parent::printImage();
echo <<<IMG
<img src="/i/sh/{$this->image}" class="item-wrap-normal" alt="">
IMG;
}
}

View File

@ -1,6 +1,6 @@
<?php
namespace Battles;
abstract class Item
class Item
{
protected $item_id;
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
{

View File

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