diff options
| author | historia <[not public]> | 2026-06-14 21:07:26 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-14 21:07:26 -0400 |
| commit | 1aba2bdd23aebed4032333e74aa553c40a31fcbd (patch) | |
| tree | c004f4c2a139df5c3cf4029b2611bdfa09b40f86 /internal/object/item.go | |
| parent | a19e6b6ab01670a5932308c7bd0e0e5eed8cbcad (diff) | |
| download | thehouseoficarus-1aba2bdd23aebed4032333e74aa553c40a31fcbd.tar.gz | |
refactor: added docs, split up some components in game package
Diffstat (limited to 'internal/object/item.go')
| -rw-r--r-- | internal/object/item.go | 31 |
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 -} |
