Основные классы переехали на обёртку PDO. Плановое №16.
This commit is contained in:
+10
-11
@@ -1,27 +1,26 @@
|
||||
<?php
|
||||
namespace Battles;
|
||||
use db;
|
||||
/**
|
||||
* Разные способы отображения строки с логином персонажа.
|
||||
*/
|
||||
|
||||
const INVIS = '<i>невидимка</i>';
|
||||
class Nick extends User
|
||||
{
|
||||
private function getInvisibilityStatus()
|
||||
{
|
||||
return db::c()->query('SELECT 1 FROM users_effects WHERE type = 1022 AND owner_id = ?i', $this->id);
|
||||
return self::$db->fetch('SELECT 1 FROM users_effects WHERE type = 1022 AND owner_id = ?', $this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Отображение иконки склонности.
|
||||
* @return string
|
||||
*/
|
||||
private function getAlign():string
|
||||
private function getAlign():?string
|
||||
{
|
||||
if (isset($this->align)) {
|
||||
return sprintf('<img src="i/align_%s.gif">', $this->align);
|
||||
} else {
|
||||
return '';
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,12 +28,12 @@ class Nick extends User
|
||||
* Отображение иконки клана.
|
||||
* @return string
|
||||
*/
|
||||
private function getClan():string
|
||||
private function getClan():?string
|
||||
{
|
||||
if (isset($this->clan)) {
|
||||
return sprintf('<img src="i/clan/%s.png">', $this->clan);
|
||||
} else {
|
||||
return '';
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +43,7 @@ class Nick extends User
|
||||
*
|
||||
* @return Nick
|
||||
*/
|
||||
public static function id($playerId)
|
||||
public static function id($playerId): Nick
|
||||
{
|
||||
return new self($playerId);
|
||||
}
|
||||
@@ -59,7 +58,7 @@ class Nick extends User
|
||||
public function full($showInvisibility = 0):string
|
||||
{
|
||||
if ($showInvisibility && $this->getInvisibilityStatus()) {
|
||||
return '<i>невидимка</i>';
|
||||
return INVIS;
|
||||
}
|
||||
return $this->getAlign().$this->getClan().sprintf('<b>%s</b> [%s] <a href="inf.php?%s" target="_blank"><img src="i/inf.gif" style="width:12px;height:11px"></a>', $this->login, $this->level, $this->login);
|
||||
}
|
||||
@@ -72,7 +71,7 @@ class Nick extends User
|
||||
public function short($showInvisibility = 0):string
|
||||
{
|
||||
if ($showInvisibility && $this->getInvisibilityStatus()) {
|
||||
return '<i>невидимка</i>';
|
||||
return INVIS;
|
||||
} else {
|
||||
return htmlspecialchars($this->login);
|
||||
}
|
||||
@@ -96,7 +95,7 @@ class Nick extends User
|
||||
public function battleShort($textstyle):string
|
||||
{
|
||||
if ($this->getInvisibilityStatus()) {
|
||||
return '<i>невидимка</i>';
|
||||
return INVIS;
|
||||
}
|
||||
else {
|
||||
return sprintf('<span style="%s">%s</span> [_hp_/_maxhp_]', $textstyle, $this->login);
|
||||
|
||||
Reference in New Issue
Block a user