2018-03-01 14:51:01 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Copyright (c) 2018.
|
|
|
|
* Author: Igor Barkov <lopar.4ever@gmail.com>
|
|
|
|
* Project name: Battles-Game
|
|
|
|
*/
|
2018-03-03 18:24:19 +00:00
|
|
|
|
2018-03-01 14:51:01 +00:00
|
|
|
class nick
|
|
|
|
{
|
2018-03-02 23:49:16 +00:00
|
|
|
private $user_data;
|
2018-03-03 17:16:13 +00:00
|
|
|
|
2018-03-03 00:07:27 +00:00
|
|
|
/**
|
|
|
|
* nick constructor.
|
2018-03-03 00:34:12 +00:00
|
|
|
* @param int $playerId
|
2018-03-03 00:07:27 +00:00
|
|
|
*/
|
2018-03-03 18:11:48 +00:00
|
|
|
private function __construct($playerId)
|
2018-03-03 17:16:13 +00:00
|
|
|
{
|
2018-03-02 23:49:16 +00:00
|
|
|
if (!$this->user_data) {
|
2018-03-04 00:09:58 +00:00
|
|
|
$user = db::c()->query('
|
2018-03-30 22:44:40 +00:00
|
|
|
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();
|
2018-03-02 23:49:16 +00:00
|
|
|
$this->user_data = $user;
|
|
|
|
}
|
2018-03-01 16:56:17 +00:00
|
|
|
|
2018-03-01 14:51:01 +00:00
|
|
|
}
|
|
|
|
|
2018-03-04 00:09:58 +00:00
|
|
|
/**
|
|
|
|
* @param $playerId
|
|
|
|
* @return nick
|
|
|
|
*/
|
2018-03-03 20:51:37 +00:00
|
|
|
public static function id($playerId)
|
2018-03-03 18:11:48 +00:00
|
|
|
{
|
|
|
|
return new self($playerId);
|
|
|
|
}
|
2018-03-03 17:16:13 +00:00
|
|
|
|
2018-03-03 00:34:12 +00:00
|
|
|
/**
|
|
|
|
* @param int $showInvisibility
|
2018-03-04 00:09:58 +00:00
|
|
|
* @return string
|
2018-03-03 00:34:12 +00:00
|
|
|
*/
|
2018-03-03 20:51:37 +00:00
|
|
|
public function full($showInvisibility = 0)
|
2018-03-03 17:16:13 +00:00
|
|
|
{
|
2018-03-30 22:44:40 +00:00
|
|
|
$n = '';
|
2018-03-04 00:09:58 +00:00
|
|
|
if ($showInvisibility && $this->user_data['invis']) {
|
|
|
|
return '<i>невидимка</i>';
|
2018-03-03 17:16:13 +00:00
|
|
|
} else {
|
|
|
|
if ($this->user_data['align']) {
|
2018-03-30 22:44:40 +00:00
|
|
|
$n .= sprintf('<img src="i/align_%s.gif">', intval($this->user_data['align']));
|
2018-03-03 17:16:13 +00:00
|
|
|
}
|
|
|
|
if ($this->user_data['klan']) {
|
2018-03-04 00:24:24 +00:00
|
|
|
$n .= sprintf('<img src="i/klan/%s.gif">', htmlspecialchars($this->user_data['klan']));
|
2018-03-03 17:16:13 +00:00
|
|
|
}
|
2018-03-03 00:34:12 +00:00
|
|
|
}
|
2018-03-04 00:29:14 +00:00
|
|
|
$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']));
|
2018-03-03 18:52:22 +00:00
|
|
|
|
2018-03-04 00:24:24 +00:00
|
|
|
return $n;
|
2018-03-01 14:51:01 +00:00
|
|
|
}
|
2018-03-03 20:51:37 +00:00
|
|
|
|
2018-03-04 00:09:58 +00:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-03-03 20:51:37 +00:00
|
|
|
public function short()
|
|
|
|
{
|
2018-03-04 00:09:58 +00:00
|
|
|
if ($this->user_data['invis']) {
|
|
|
|
return '<i>невидимка</i>';
|
|
|
|
} else return htmlspecialchars($this->user_data['login']);
|
2018-03-03 20:51:37 +00:00
|
|
|
}
|
2018-03-01 14:51:01 +00:00
|
|
|
}
|