228 lines
9.6 KiB
PHP
228 lines
9.6 KiB
PHP
<?php
|
||
namespace Battles;
|
||
use Battles\Database\DBPDO;
|
||
use Battles\Models\EffectsModel;
|
||
|
||
class UserInfo extends UserStats
|
||
{
|
||
use Rooms;
|
||
//Статусы того, кто смотрит на информацию.
|
||
public $watcher_id;
|
||
private $watcherIsAdmin;
|
||
private $watcherIsModerator;
|
||
|
||
/**
|
||
* Отображает куклу персонажа (образ и слоты).
|
||
*
|
||
* @param int $isBattle установить 1, если куклу нужно отобразить в поединке (показывает параметры при наведении
|
||
* на образ).
|
||
* @param int $isMain установить 1, если куклу надо показать на странице игрока (по клику на предмет снимает
|
||
* его).
|
||
*/
|
||
private function UserInfoDoll($isBattle = 0, $isMain = 0)
|
||
{
|
||
$di = new DressedItems($this->id);
|
||
$dressedItems = $di->getItemsInSlots();
|
||
for ($i = 1; $i <= 12; $i++) {
|
||
echo sprintf('<div class="slot-%s">', $i);
|
||
if (!empty($dressedItems->$i)) {
|
||
if (!$isBattle && $isMain) {
|
||
echo sprintf('<a href="?edit=%s&drop=%s"><img src="/i/sh/%s" class="item-wrap-normal" alt="%s" title="%s"></a>',
|
||
mt_rand(), $i, $dressedItems->$i->image, $dressedItems->$i->name, $dressedItems->$i->name);
|
||
} else {
|
||
echo sprintf('<img src="/i/sh/%s" class="item-wrap-normal tip" alt="%s"><span class="tiptext"><strong>%s</strong></span>',
|
||
$dressedItems->$i->image, $dressedItems->$i->name, $dressedItems->$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);
|
||
}
|
||
echo '<div class="slot-image">';
|
||
if ($isBattle) {
|
||
echo sprintf('<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>',
|
||
$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 -->';
|
||
}
|
||
|
||
private function UserInfoStats($isMainWindow = 0)
|
||
{
|
||
$captions = 'Уровень:<br>Сила:<br>Ловкость:<br>Интуиция:<br>Выносливость:<br>Интеллект:<br>Мудрость:<br>Местонахождение:';
|
||
$variables =
|
||
$this->level . '<br>' .
|
||
parent::getFullStats()->strength . '<br>' .
|
||
parent::getFullStats()->dexterity . '<br>' .
|
||
parent::getFullStats()->intuition . '<br>' .
|
||
parent::getFullStats()->endurance . '<br>' .
|
||
parent::getFullStats()->intelligence . '<br>' .
|
||
parent::getFullStats()->wisdom . '<br>' .
|
||
Rooms::$roomNames[$this->room];
|
||
if ($isMainWindow) {
|
||
$this->Bank = new Bank($this->id);
|
||
$captions = 'Уровень:<br>Здоровье:<br>Сила:<br>Ловкость:<br>Интуиция:<br>Выносливость:<br>Интеллект:<br>Мудрость:<br>Опыт:<br>Очки характеристик:<br>Деньги:<br>Деньги в банке:';
|
||
$variables =
|
||
$this->level . '<br>' .
|
||
$this->health . '<br>' .
|
||
parent::getStat('strength', 1) . '<br>' .
|
||
parent::getStat('dexterity', 1) . '<br>' .
|
||
parent::getStat('intuition', 1) . '<br>' .
|
||
parent::getStat('endurance', 1) . '<br>' .
|
||
parent::getStat('intelligence', 1) . '<br>' .
|
||
parent::getStat('wisdom', 1) . '<br>' .
|
||
$this->experience . '<br>' .
|
||
$this->free_stat_points . '<br>' .
|
||
$this->money . '<br>' .
|
||
$this->Bank->getMoney();
|
||
}
|
||
$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;
|
||
}
|
||
$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']);
|
||
}
|
||
$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()
|
||
{
|
||
echo '<div class="user-info-container">';
|
||
$this->UserInfoDoll();
|
||
$this->UserInfoStats();
|
||
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());
|
||
echo '</div><!-- user-signs -->';
|
||
echo '</div><!-- user-info-container -->';
|
||
echo '<hr><!-- Нижняя часть -->';
|
||
echo '<div class="user-info-container-lower">';
|
||
echo '<h2>Об игроке</h2>';
|
||
echo $this->realname ? "Имя: $this->realname" : "";
|
||
echo $this->info ? "<br>" . nl2br($this->info) : "";
|
||
echo '</div><!-- user-info-container-lower -->';
|
||
echo $this->showPrivateData();
|
||
}
|
||
|
||
public function showUserInfo()
|
||
{
|
||
$this->WatcherStatus();
|
||
$effects = new EffectsModel($this->id);
|
||
|
||
if ($this->block && (!$this->watcherIsAdmin || !$this->watcherIsModerator)) {
|
||
echo "<span class='error'>Персонаж $this->login заблокирован!</span>";
|
||
} elseif ($effects->getHideUserInfoStatus() && (!$this->watcherIsAdmin || !$this->watcherIsModerator)) {
|
||
if ($effects->getHideUserInfoStatus() == -1) {
|
||
$date = 'навсегда';
|
||
} else {
|
||
$date = 'до' . date('d.m.Y', strtotime($effects->getHideUserInfoStatus()));
|
||
}
|
||
echo "<span class='error'>Персонаж $this->login обезличен $date.</span>";
|
||
} else {
|
||
$this->Info();
|
||
}
|
||
}
|
||
|
||
private function WatcherStatus()
|
||
{
|
||
$query = parent::$db->fetch('SELECT align, admin FROM users WHERE id = ?', $this->watcher_id);
|
||
if ($query['admin']) {
|
||
$this->watcherIsAdmin = 1;
|
||
}
|
||
if ($query['align'] == 1) {
|
||
$this->watcherIsModerator = 1;
|
||
}
|
||
}
|
||
|
||
public function showUserDoll($isBattle = 0, $isMain = 0)
|
||
{
|
||
echo '<div class="user-info-container">';
|
||
$this->UserInfoDoll($isBattle, $isMain);
|
||
echo '</div><!-- user-info-container -->';
|
||
}
|
||
|
||
public function showUserInfoMain()
|
||
{
|
||
echo '<div class="user-info-container">';
|
||
$this->UserInfoDoll();
|
||
$this->userInfoStats(1);
|
||
echo '</div><!-- user-info-container -->';
|
||
}
|
||
|
||
public function showUserEffects(): string
|
||
{
|
||
$effs = DBPDO::INIT()->ofetchAll('SELECT * FROM users_effects WHERE owner_id = ?', $this->id);
|
||
$img = UserEffects::$effectImage;
|
||
$r = '';
|
||
foreach ($effs as $effect) {
|
||
$timeleft = timeOut($effect->remaining_time - time());
|
||
$r .= "
|
||
<div>
|
||
<img class='image' src='/i/{$img[$effect->type]}' alt='{$effect->name}'>
|
||
<span class='title'>{$effect->name}</span>
|
||
<div class='timeleft'>$timeleft</div>
|
||
</div>
|
||
";
|
||
}
|
||
return $r;
|
||
}
|
||
|
||
} |