inventory and use item

This commit is contained in:
Yunfan Li
2023-05-28 00:00:13 +08:00
parent 09463feb8f
commit 3432a9b37d
3 changed files with 8 additions and 18 deletions

View File

@@ -282,10 +282,12 @@ std::vector<Item*> InventoryAction::parseItems(std::string const text, IterateIt
IterateItems(&visitor, ITERATE_ITEMS_IN_BAGS);
found.insert(visitor.GetResult().begin(), visitor.GetResult().end());
}
FindUsableNamedItemVisitor visitor(bot);
IterateItems(&visitor, ITERATE_ITEMS_IN_BAGS);
found.insert(visitor.GetResult().begin(), visitor.GetResult().end());
if (text == "")
{
FindUsableNamedItemVisitor visitor(bot);
IterateItems(&visitor, ITERATE_ITEMS_IN_BAGS);
found.insert(visitor.GetResult().begin(), visitor.GetResult().end());
}
uint32 quality = chat->parseItemQuality(text);
if (quality != MAX_ITEM_QUALITY)

View File

@@ -19,19 +19,7 @@ bool UseItemAction::Execute(Event event)
if (gos.empty())
{
if (items.size() > 1)
{
std::vector<Item*>::iterator i = items.begin();
Item* item = *i++;
Item* itemTarget = *i;
if (item->IsPotion() || item->GetTemplate()->Class == ITEM_CLASS_CONSUMABLE)
return UseItemAuto(item);
else
return UseItemOnItem(item, itemTarget);
}
else if (!items.empty())
return UseItemAuto(*items.begin());
return UseItemAuto(*items.begin());
}
else
{

View File

@@ -73,7 +73,7 @@ class UseRandomRecipe : public UseItemAction
bool isUseful() override;
bool isPossible() override;
bool Execute(Event event);
bool Execute(Event event) override;
};
class UseRandomQuestItem : public UseItemAction