battles/classes/Battles/UserInfo.php

196 lines
9.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace Battles;
class UserInfo extends User
{
use Rooms;
//Статусы того, кто смотрит на информацию.
public $watcher_id;
private $watcherIsAdmin;
private $watcherIsModerator;
/**
* Отображает куклу персонажа (образ и слоты).
*
* @param int $isBattle - установить 1, если куклу нужно отобразить в поединке (показывает параметры при наведении
* на образ).
* @param int $isMain - установить 1, если куклу надо показать на странице игрока (по клику на предмет снимает
* его).
*
* @throws \Krugozor\Database\Mysql\Exception
*/
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) {
$itemString = '<a href="?edit=%s&drop=%s"><img src="/i/sh/%s" class="item-wrap-normal" alt="%s" title="%s"></a>';
echo sprintf($itemString, mt_rand(), $i, $dressedItems[$i]['image'], $dressedItems[$i]['name'], $dressedItems[$i]['name']);
} else {
$itemString = '<img src="/i/sh/%s" class="item-wrap-normal tip" alt="%s"><span class="tiptext"><strong>%s</strong></span>';
echo sprintf($itemString, $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) {
$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 -->';
}
private function UserInfoStats($isMainWindow = 0)
{
$captions = 'Уровень:<br>Сила:<br>Ловкость:<br>Интуиция:<br>Выносливость:<br>Интеллект:<br>Мудрость:<br>Местонахождение:';
$variables =
$this->level . '<br>' .
parent::getStat('strength') . '<br>' .
parent::getStat('dexterity') . '<br>' .
parent::getStat('intuition') . '<br>' .
parent::getStat('endurance') . '<br>' .
parent::getStat('intelligence') . '<br>' .
parent::getStat('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 = '';
if ($this->align) {
$nameString = sprintf('<img src="/i/align_%s.png" alt="Склонность">', $this->align);
}
if ($this->block) {
$nameString .= '<span class="private"><s>' . $this->login . '</s></span>';
} else {
$nameString .= ' <b>' . $this->login . '</b> ';
}
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 -->';
}
private function Info()
{
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><!-- 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>';
if ($this->realname) {
echo sprintf('Имя: %s<br>', $this->realname);
}
if ($this->info) {
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 = new \Battles\Models\UserLogModel($this->id);
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);
}
echo '</div><!-- secret-info-user-log -->';
echo '</div><!-- secret-info -->';
}
}
public function showUserInfo()
{
$this->effects = new \Battles\Models\EffectsModel($this->id);
$this->WatcherStatus();
if ($this->block && (!$this->watcherIsAdmin || !$this->watcherIsModerator)) {
throw new \Exceptions\GameException('<span class="error">Персонаж ' . $this->login . ' заблокирован!</span>');
} elseif ($this->effects->getHideUserInfoStatus() && (!$this->watcherIsAdmin || !$this->watcherIsModerator)) {
if ($this->effects->getHideUserInfoStatus() == -1) {
$date = 'навсегда';
} else {
$date = 'до' . date('d.m.Y', strtotime($this->effects->getHideUserInfoStatus()));
}
throw new \Exceptions\GameException('<span class="error">Персонаж ' . $this->login . ' обезличен ' . $date . '.</span>');
} else {
$this->Info();
}
}
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;
}
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 -->';
}
}