69 lines
1.9 KiB
PHP
69 lines
1.9 KiB
PHP
<?php
|
|
/**
|
|
* Copyright (c) 2018.
|
|
* Author: Igor Barkov <lopar.4ever@gmail.com>
|
|
* Project name: Battles-Game
|
|
*/
|
|
|
|
class nick
|
|
{
|
|
private $user_data;
|
|
|
|
/**
|
|
* nick constructor.
|
|
* @param int $playerId
|
|
*/
|
|
private function __construct($playerId)
|
|
{
|
|
if (!$this->user_data) {
|
|
$user = db::c()->query('
|
|
SELECT `login`, `level`, U.`align`, `short`, (SELECT 1 FROM `effects` WHERE `owner` = U.`id` AND `type` = 1022) AS `invis`, U.`hp`, `maxhp`
|
|
FROM `users` U
|
|
LEFT JOIN `clans` C ON C.`id` = `klan`
|
|
WHERE U.`id` = ?i', $playerId)->fetch_assoc();
|
|
$this->user_data = $user;
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* @param $playerId
|
|
* @return nick
|
|
*/
|
|
public static function id($playerId)
|
|
{
|
|
return new self($playerId);
|
|
}
|
|
|
|
/**
|
|
* @param int $showInvisibility
|
|
* @return string
|
|
*/
|
|
public function full($showInvisibility = 0)
|
|
{
|
|
$n = '';
|
|
if ($showInvisibility && $this->user_data['invis']) {
|
|
return '<i>невидимка</i>';
|
|
} else {
|
|
if ($this->user_data['align']) {
|
|
$n .= sprintf('<img src="i/align_%s.gif">', intval($this->user_data['align']));
|
|
}
|
|
if ($this->user_data['klan']) {
|
|
$n .= sprintf('<img src="i/klan/%s.gif">', htmlspecialchars($this->user_data['klan']));
|
|
}
|
|
}
|
|
$n .= sprintf('<b>%s</b> [%s] <a href="inf.php?%s" target="_blank"><img src="i/inf.gif" style="width:12px;height:11px"></a>', htmlspecialchars($this->user_data['login']), intval($this->user_data['level']), htmlspecialchars($this->user_data['login']));
|
|
|
|
return $n;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function short()
|
|
{
|
|
if ($this->user_data['invis']) {
|
|
return '<i>невидимка</i>';
|
|
} else return htmlspecialchars($this->user_data['login']);
|
|
}
|
|
} |