target = $target; if (!$this->isUsable()) { return $this->status; } $ok = null; $injury = $db->ofetch('SELECT effect_id, type, name FROM users_effects WHERE type IN (11,12,13,14) AND owner_id = ? ORDER BY type DESC LIMIT 1', $target); if (in_array($injury->type, [11, 12, 13, 14]) && $injuryType >= $injury->type && UserEffect::remove($target, $injury->effect_id)) { if (empty($injury->name) || $injury->name === 'Неизвестный эффект') { $injuryName = UserEffect::$effectName[$injury->type]; } else { $injuryName = $injury->name; } $ok = "Вы вылечили повреждение ${injuryName} персонажу $this->login."; } elseif ($injury->effect_id && $injuryType === 15 && UserEffect::massRemove($target, [11,12,13,14])) { $ok = "Вы вылечили все повреждения персонажу $this->login."; } return $ok; } /** * Проверки на успех. * @return bool */ private function isUsable(): bool { $this->target = $this->target == $_SESSION['uid'] ? User::getInstance() : User::getInstance($this->target); $this->login = $this->target->getLogin(); return ( $this->isVisible(User::getInstance(), $this->target) && $this->isNotDead(User::getInstance()) && $this->enoughMana(User::getInstance()) && $this->isNotInBattle(User::getInstance()) ); } public static function cast($target, $type): self { return new self($target, $type); } }