remove item from inventory by id

This commit is contained in:
jake 2020-12-03 15:01:00 -07:00
parent 5345939b1b
commit d263bf4caa

View File

@ -655,6 +655,14 @@ impl CharacterInventory {
self.items = sorted_items;
}
pub fn remove_by_id(&mut self, id: ClientItemId) -> Option<InventoryItem> {
self.items.iter()
.position(|i| i.item_id() == id)
.map(|position| {
self.items.remove(position)
})
}
pub fn equip(&mut self, id: &ClientItemId, equip_slot: u8) {
for item in &self.items {
if let InventoryItem::Individual(inventory_item) = item {