magicPower = $power; $this->target = $target; if (!$this->isUsable()) { return $this->status; } 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; } DBPDO::INIT()->execute('UPDATE users SET health = ? WHERE id = ?', [$healHealthAmount, $this->target->id]); $targetName = $this->target->login; return "Вы восстановили ${healHealthAmount} здоровья персонажу ${targetName}."; } /** * Проверки на успех. * @return bool */ private function isUsable(): bool { $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->isSuccess($caster); } }