battles/classes/nick.php

56 lines
1.7 KiB
PHP
Raw Normal View History

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:11:48 +00:00
namespace battles;
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 18:11:48 +00:00
public static function search($playerId)
{
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 17:16:13 +00:00
public function show($showInvisibility = 0)
{
$n ='';
2018-03-03 00:34:12 +00:00
if ($showInvisibility) {
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 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-02 23:49:16 +00:00
// if ($this->invis){
// // db::c()->query('SELECT `time` FROM `effects` WHERE `owner` = ?i AND `type` = ?i', $id, 1022)->fetch_assoc();
// $user['login'] = 'невидимка';
// $user['level'] = 100;
// }
2018-03-03 17:16:13 +00:00
echo $n;
2018-03-01 14:51:01 +00:00
}
}