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