From 1aba2bdd23aebed4032333e74aa553c40a31fcbd Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Sun, 14 Jun 2026 21:07:26 -0400 Subject: refactor: added docs, split up some components in game package --- internal/object/item.go | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) (limited to 'internal/object/item.go') 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 -} -- cgit v1.2.3