add items FindByID

This commit is contained in:
Héctor Giménez
2024-09-03 20:39:32 +09:00
parent 792ff69790
commit 9842199c15

View File

@@ -33,6 +33,16 @@ func (i Inventory) Find(name item.Name, locations ...item.LocationType) (Item, b
return Item{}, false
}
func (i Inventory) FindByID(unitID UnitID) (Item, bool) {
for _, it := range i.AllItems {
if it.UnitID == unitID {
return it, true
}
}
return Item{}, false
}
func (i Inventory) ByLocation(locations ...item.LocationType) []Item {
var items []Item