Code smell.
This commit is contained in:
@@ -25,16 +25,16 @@ class Sharpen extends Magic
|
||||
if (!$this->isUsable()) {
|
||||
return $this->status;
|
||||
}
|
||||
$item = DressedItems::getDressedItemBySlot(Item::ITEM_TYPE_WEAPON, $_SESSION['uid']);
|
||||
$item = DressedItems::getDressedItemBySlot(Item::TYPE_WEAPON, $_SESSION['uid']);
|
||||
// Проверяем, что в названии предмета нет цифр и плюсов.
|
||||
if (preg_match('/[\W\S]+\+\[?[\d]]?/', $item->name)) {
|
||||
if (preg_match('/\+\d/', $item->name)) {
|
||||
return 'Этот предмет точить нельзя!';
|
||||
}
|
||||
$newMinPhysicalDamage = $item->add_min_physical_damage + $sharpenStrength;
|
||||
$newMaxPhysicalDamage = $item->add_max_physical_damage + $sharpenStrength;
|
||||
$newItemName = $item->name . " [+$sharpenStrength]";
|
||||
|
||||
Db::getInstance()->execute('UPDATE battles.inventory SET name = ?, add_min_physical_damage = ?, add_max_physical_damage = ? WHERE item_id = ? ', [$newItemName, $newMinPhysicalDamage, $newMaxPhysicalDamage, $item->item_id]);
|
||||
Db::getInstance()->execute('UPDATE inventory SET name = ?, add_min_physical_damage = ?, add_max_physical_damage = ? WHERE item_id = ? ', [$newItemName, $newMinPhysicalDamage, $newMaxPhysicalDamage, $item->item_id]);
|
||||
return "У вас получилось изготовить предмет $newItemName!";
|
||||
}
|
||||
|
||||
@@ -42,4 +42,4 @@ class Sharpen extends Magic
|
||||
{
|
||||
return $this->isNotInBattle(User::getInstance()) && $this->isSuccess(User::getInstance(), $this->magicDifficulty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user