battles/classes/nick.php
2018-03-03 21:17:22 +02:00

54 lines
1.6 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`, `align`, (SELECT `short` FROM `clans` WHERE `clans`.`id` = `klan`) AS `klan`, `hp`, `maxhp` FROM `users` WHERE `id` = ?i', $playerId)->fetch_assoc();
$this->user_data = $user;
}
}
public static function search($playerId)
{
return new self($playerId);
}
/**
* @param int $showInvisibility
*/
public function geninf($showInvisibility = 0)
{
$n ='';
if ($showInvisibility) {
// db::c()->query('SELECT `time` FROM `effects` WHERE `owner` = ?i AND `type` = ?i', $id, 1022)->fetch_assoc();
$this->user_data['login'] = '<i>невидимка</i>';
$this->user_data['level'] = '??';
} else {
if ($this->user_data['align']) {
$n .= sprintf('<img src="i/align_%s.gif">', $this->user_data['align']);
}
if ($this->user_data['klan']) {
$n .= sprintf('<img src="i/klan/%s.gif">', $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>', $this->user_data['login'], $this->user_data['level'], $this->user_data['login']);
return $n;
}
}