dev-magic-sharpen #29
@ -4,8 +4,10 @@
|
|||||||
namespace Battles\Magic;
|
namespace Battles\Magic;
|
||||||
use Battles\UserEffects;
|
use Battles\UserEffects;
|
||||||
use Battles\User;
|
use Battles\User;
|
||||||
|
use db;
|
||||||
|
use Krugozor\Database\Mysql\Exception;
|
||||||
|
|
||||||
class CureInjury extends magic
|
class CureInjury extends Magic
|
||||||
{
|
{
|
||||||
private $target;
|
private $target;
|
||||||
use UserEffects;
|
use UserEffects;
|
||||||
@ -14,16 +16,16 @@ class CureInjury extends magic
|
|||||||
* Магия лечения травм. Если у персонажа несколько травм, лечится самая тяжёлая.
|
* Магия лечения травм. Если у персонажа несколько травм, лечится самая тяжёлая.
|
||||||
* @param $target - кого лечим.
|
* @param $target - кого лечим.
|
||||||
* @param $injuryType - тип травмы, которую лечим. 11 лёгкая, 12 средняя, 13 тяжёлая, 14 неизлечимая.
|
* @param $injuryType - тип травмы, которую лечим. 11 лёгкая, 12 средняя, 13 тяжёлая, 14 неизлечимая.
|
||||||
* @throws \Krugozor\Database\Mysql\Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function __construct($target, $injuryType)
|
public function __construct($target, $injuryType)
|
||||||
{
|
{
|
||||||
$this->target = $target;
|
$this->target = $target;
|
||||||
if ($target && $this->isUsable()) {
|
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', $target)->fetch_object();
|
$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;
|
$targetName = $this->target->login;
|
||||||
if (in_array($injury->effect_id, [11, 12, 13, 14]) && $injuryType >= $injury->type) {
|
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);
|
db::c()->query('DELETE FROM users_effects WHERE effect_id = ?i', $injury->effect_id);
|
||||||
if (empty($injury->name) || $injury->name == 'Неизвестный эффект') {
|
if (empty($injury->name) || $injury->name == 'Неизвестный эффект') {
|
||||||
$injuryName = self::$effectName[$injury->type];
|
$injuryName = self::$effectName[$injury->type];
|
||||||
} else {
|
} else {
|
||||||
@ -31,7 +33,7 @@ class CureInjury extends magic
|
|||||||
}
|
}
|
||||||
return "Вы вылечили повреждение ${injuryName} персонажу ${targetName}.";
|
return "Вы вылечили повреждение ${injuryName} персонажу ${targetName}.";
|
||||||
} elseif ($injury->effect_id && $injuryType == 15) {
|
} 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);
|
db::c()->query('DELETE FROM users_effects WHERE type IN (11,12,13,14) AND owner_id = ?i', $target);
|
||||||
return "Вы вылечили все повреждения персонажу ${targetName}.";
|
return "Вы вылечили все повреждения персонажу ${targetName}.";
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user