Отказ от старой дублирующей destructitem() в пользу классовой InventoryItem::destroyItem().

This commit is contained in:
lopar
2021-05-12 22:02:05 +03:00
parent cb3887b773
commit 2f4dfd84cf
5 changed files with 22 additions and 25 deletions

View File

@@ -468,21 +468,6 @@ function ref_drop()
}
}
/**
* Уничтожить предмет, принадлежащий игроку, вызывающего функцию.
* @param $id - ID предмета игрока.
* @throws \Krugozor\Database\Mysql\Exception
*/
function destructitem($id)
{
global $user;
$item = db::c()->query('SELECT 1 FROM inventory WHERE owner_id = ?i AND item_id = ?i', $user->getId(), $id);
if ($item->getNumRows()) {
db::c()->query('DELETE FROM `inventory` WHERE `id` = ?i', $id);
}
}
// использовать магию
function usemagic($id, $target)
{
@@ -543,7 +528,7 @@ function usemagic($id, $target)
}
if ($bat) {
if ($row['maxdur'] <= ($row['duration'] + 1)) {
destructitem($row['id']);
\Battles\InventoryItem::destroyItem($row['id']);
} else {
if (!$row['magic']) {
db::c()->query('UPDATE `inventory` SET `includemagicdex` =`includemagicdex` - ?i WHERE id = ?i', $bat, $row['id']);