Рефакторинг, очистка, работа над ошибками, связанными с базой, отказ от глобальной переменной $user во многих файлах.
Singleton в некоторых местах вместо решения #42. Новые шаги для решения #16 и #52. Closes #42. Closes #32. Closes #31.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
// Магия восстановления здоровья
|
||||
use Battles\Magic\Magic;
|
||||
use Battles\User;
|
||||
use Battles\Database\DBPDO;
|
||||
use Battles\Database\Db;
|
||||
|
||||
class Healing extends Magic
|
||||
{
|
||||
@@ -30,7 +30,7 @@ class Healing extends Magic
|
||||
if ($healHealthAmount > $this->target->maxHealth) {
|
||||
$healHealthAmount = $this->target->maxHealth;
|
||||
}
|
||||
DBPDO::INIT()->execute('UPDATE users SET health = ? WHERE id = ?', [$healHealthAmount, $this->target->id]);
|
||||
Db::getInstance()->execute('UPDATE users SET health = ? WHERE id = ?', [$healHealthAmount, $this->target->id]);
|
||||
$targetName = $this->target->login;
|
||||
return "Вы восстановили ${healHealthAmount} здоровья персонажу ${targetName}.";
|
||||
}
|
||||
@@ -41,12 +41,7 @@ class Healing extends Magic
|
||||
*/
|
||||
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);
|
||||
$this->target = $this->target == $_SESSION['uid'] ? User::getInstance() : User::getInstance($this->target);
|
||||
return $this->isVisible(User::getInstance(), $this->target) && $this->isNotDead(User::getInstance()) && $this->enoughMana(User::getInstance()) && $this->isSuccess(User::getInstance());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user