From afd6fd8bc3f0ef628876588403124d8e04dc68eb Mon Sep 17 00:00:00 2001 From: lopar Date: Wed, 16 Sep 2020 18:15:37 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=BE=D0=B2=D0=B0=D1=8F=20=D1=83=D0=BD?= =?UTF-8?q?=D0=B8=D0=B2=D0=B5=D1=80=D1=81=D0=B0=D0=BB=D1=8C=D0=BD=D0=B0?= =?UTF-8?q?=D1=8F=20=D0=BC=D0=B0=D0=B3=D0=B8=D1=8F=20=D0=BB=D0=B5=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=82=D1=80=D0=B0=D0=B2=D0=BC.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- magic/CureInjury.php | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 magic/CureInjury.php diff --git a/magic/CureInjury.php b/magic/CureInjury.php new file mode 100644 index 0000000..e4279de --- /dev/null +++ b/magic/CureInjury.php @@ -0,0 +1,51 @@ +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', $this->target->id)->fetch_object(); + 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); + $targetName = $this->target->login; + if (empty($injury->name) || $injury->name == 'Неизвестный эффект') { + $injuryName = self::$effectName[$injury->type]; + } else { + $injuryName = $injury->name; + } + return "Вы вылечили повреждение ${injuryName} персонажу ${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)); + } +} \ No newline at end of file