magicPower = $power; if ($target && $this->isUsable()) { //TODO: Проверка на то, что магу хватает навыка владения школой магии. //IDEA: Можно добавить проверку на интеллект, где при определённом интеллекте шанс на успех становится 95-100%. if ($isPercentage) { $healHealthAmount = $this->target->health + $this->target->maxHealth / 100 * $this->magicPower; } else { $healHealthAmount = $this->target->health + $this->magicPower; } if ($healHealthAmount > $this->target->maxHealth) { $healHealthAmount = $this->target->maxHealth; } db::c()->query('UPDATE users SET health = ?i WHERE id = ?i', $healHealthAmount, $this->target->id); $targetName = $this->target->login; return "Вы восстановили ${healHealthAmount} здоровья персонажу ${targetName}."; } 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)); } }