Не передавался target в функции.

This commit is contained in:
lopar 2020-09-16 18:38:18 +03:00
parent afd6fd8bc3
commit df35ebe524
2 changed files with 8 additions and 3 deletions

View File

@ -15,17 +15,21 @@ class CureInjury extends Magic
*/
public function __construct($target, $injuryType)
{
$this->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', $this->target->id)->fetch_object();
if (in_array($injury->effect_id, [11,12,13,14]) && $injuryType >= $injury->type) {
$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);
$targetName = $this->target->login;
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;
}

View File

@ -15,6 +15,7 @@ class Healing extends Magic
public function __construct($target, $power, $isPercentage = null)
{
$this->magicPower = $power;
$this->target = $target;
if ($target && $this->isUsable()) {
//TODO: Проверка на то, что магу хватает навыка владения школой магии.
//IDEA: Можно добавить проверку на интеллект, где при определённом интеллекте шанс на успех становится 95-100%.