aboutsummaryrefslogtreecommitdiff
path: root/internal/object/item.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/object/item.go')
-rw-r--r--internal/object/item.go31
1 files changed, 7 insertions, 24 deletions
diff --git a/internal/object/item.go b/internal/object/item.go
index 009f10e..18fd034 100644
--- a/internal/object/item.go
+++ b/internal/object/item.go
@@ -1,6 +1,10 @@
package object
-import "strings"
+import (
+ "strings"
+
+ "thirdcollapse/internal/world"
+)
type EquipSlot string
@@ -67,34 +71,13 @@ func (d *ItemDef) MatchesName(input string) bool {
return true
}
}
- if wordPrefixMatch(lower, d.Name) {
+ if world.WordPrefixMatch(lower, d.Name) {
return true
}
for _, alias := range d.Aliases {
- if wordPrefixMatch(lower, alias) {
+ if world.WordPrefixMatch(lower, alias) {
return true
}
}
return false
}
-
-func wordPrefixMatch(input, name string) bool {
- inputWords := strings.Fields(input)
- if len(inputWords) == 0 {
- return false
- }
- nameWords := strings.Fields(strings.ToLower(name))
- for _, iw := range inputWords {
- found := false
- for _, nw := range nameWords {
- if strings.HasPrefix(nw, iw) || strings.HasPrefix(iw, nw) {
- found = true
- break
- }
- }
- if !found {
- return false
- }
- }
- return true
-}