From 0049b2d6017b67115fe60b2b64327657ec2ebd2e Mon Sep 17 00:00:00 2001 From: "Igor Barkov (iwork)" Date: Thu, 27 Aug 2020 15:31:35 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8F=20ni?= =?UTF-8?q?ck4()=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B5=D1=85=D0=B0=D0=BB=D0=B0?= =?UTF-8?q?=20=D0=B2=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=20Nick.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Nick.php | 16 ++++++++++++++++ fbattle.php | 4 ++-- functions.php | 17 ----------------- logs.php | 4 ++-- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/classes/Nick.php b/classes/Nick.php index 58c5acb..db5f95c 100644 --- a/classes/Nick.php +++ b/classes/Nick.php @@ -90,4 +90,20 @@ class Nick extends User { return $this->getAlign().$this->getClan().sprintf('%s [%s] HP _hp_/_maxhp_', $this->login, $this->level, $this->login); } + + /** + * Возвращает строку с логином и здоровьем, выделяя строку определённым стилем. + * @param $textstyle - Название стиля отображения логина персонажа (main.css) для цветового разделения команд. + * + * @return string + */ + public function battleShort($textstyle) + { + if ($this->getInvisibilityStatus()) { + return 'невидимка'; + } + else { + return sprintf('%s [_hp_/_maxhp_]', $textstyle, $this->login); + } + } } \ No newline at end of file diff --git a/fbattle.php b/fbattle.php index bab2987..5080eb1 100644 --- a/fbattle.php +++ b/fbattle.php @@ -376,7 +376,7 @@ $fbattle = new fbattle($user['battle']); } else { $cc = ''; } - $ffs .= $cc . nick4($v, "B1"); + $ffs .= $cc . Nick::id($v)->battleShort('B1'); $zz .= "private [" . Nick::id($v)->short() . "] "; } } @@ -398,7 +398,7 @@ $fbattle = new fbattle($user['battle']); } else { $cc = ''; } - $ffs .= $cc . nick4($v, "B2"); + $ffs .= $cc . Nick::id($v)->battleShort('B2'); $zz .= "private [" . Nick::id($v)->short() . "] "; } } diff --git a/functions.php b/functions.php index 7b760b9..bfabde0 100644 --- a/functions.php +++ b/functions.php @@ -211,23 +211,6 @@ function topsethp() return "top.setHP($user[hp], $user[maxhp], $delay);"; } -function nick4($id, $st) -{ - $user = db::c()->query('SELECT * FROM `users` WHERE `id` = ?i', $id)->fetch_assoc(); - - if ($user[0]) { - $effect = db::c()->query('SELECT time FROM effects WHERE type = 1022 and owner = ?i', $id)->fetch_assoc_array(); - if ($effect) { - $user['level'] = '??'; - $user['login'] = 'невидимка'; - $user['hp'] = '??'; - $user['maxhp'] = '??'; - } - return "" . $user['login'] . " [" . $user['hp'] . "/" . $user['maxhp'] . "]"; - } - return false; -} - function check_proc($u) { $r = 100; diff --git a/logs.php b/logs.php index 256242a..438527f 100644 --- a/logs.php +++ b/logs.php @@ -50,7 +50,7 @@ if($_GET['stat'] != '1') { if(in_array($v, array_keys($battle))) { ++$i; if($i > 1) { $cc = ', '; } else { $cc = ''; } - $ffs .= $cc.nick4($v, "B1"); + $ffs .= $cc.Nick::id($v)->battleShort('B1'); } } @@ -61,7 +61,7 @@ if($_GET['stat'] != '1') { if(in_array($v, array_keys($battle))) { ++$i; if($i > 1) { $cc = ', '; } else { $cc = ''; } - $ffs .= $cc.nick4($v, "B2"); + $ffs .= $cc.Nick::id($v)->battleShort('B1'); } } $i = 0;