2018-03-01 14:51:01 +00:00
< ? php
/**
* Copyright ( c ) 2018.
* Author : Igor Barkov < lopar . 4 ever @ 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-03 17:16:13 +00:00
$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 ();
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-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-03 20:51:37 +00:00
public function full ( $showInvisibility = 0 )
2018-03-03 17:16:13 +00:00
{
$n = '' ;
2018-03-03 00:34:12 +00:00
if ( $showInvisibility ) {
2018-03-03 18:52:22 +00:00
// db::c()->query('SELECT `time` FROM `effects` WHERE `owner` = ?i AND `type` = ?i', $id, 1022)->fetch_assoc();
2018-03-03 17:16:13 +00:00
$this -> user_data [ 'login' ] = '<i>невидимка</i>' ;
2018-03-03 00:34:12 +00:00
$this -> user_data [ 'level' ] = '??' ;
2018-03-03 19:17:22 +00:00
2018-03-03 17:16:13 +00:00
} 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' ]);
}
2018-03-03 00:34:12 +00:00
}
2018-03-03 17:16:13 +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>' , $this -> user_data [ 'login' ], $this -> user_data [ 'level' ], $this -> user_data [ 'login' ]);
2018-03-03 18:52:22 +00:00
2018-03-03 21:34:13 +00:00
return htmlspecialchars ( $n );
2018-03-01 14:51:01 +00:00
}
2018-03-03 20:51:37 +00:00
public function short ()
{
2018-03-03 21:34:13 +00:00
return htmlspecialchars ( $this -> user_data [ 'login' ]);
2018-03-03 20:51:37 +00:00
}
2018-03-01 14:51:01 +00:00
}