filter by location type

This commit is contained in:
Héctor Giménez
2024-05-19 20:45:43 +09:00
parent e4b4f8e1b5
commit 079df7a6ac

View File

@@ -14,7 +14,7 @@ type Inventory struct {
StashedGold [4]int StashedGold [4]int
} }
func (i Inventory) Find(name item.Name, locations ...item.Location) (Item, bool) { func (i Inventory) Find(name item.Name, locations ...item.LocationType) (Item, bool) {
for _, it := range i.AllItems { for _, it := range i.AllItems {
if strings.EqualFold(string(it.Name), string(name)) { if strings.EqualFold(string(it.Name), string(name)) {
// If no locations are specified, return the first item found // If no locations are specified, return the first item found
@@ -23,7 +23,7 @@ func (i Inventory) Find(name item.Name, locations ...item.Location) (Item, bool)
} }
for _, l := range locations { for _, l := range locations {
if it.Location == l { if it.Location.LocationType == l {
return it, true return it, true
} }
} }