From 9d4b799db4868bcab291b83599ff088763cd4ed6 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Wed, 24 Jun 2026 20:58:25 -0400 Subject: feat: new type of non-violent 'combat': work --- internal/world/objects.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'internal/world/objects.go') diff --git a/internal/world/objects.go b/internal/world/objects.go index bf4b592..a7e0605 100644 --- a/internal/world/objects.go +++ b/internal/world/objects.go @@ -14,6 +14,7 @@ type ObjState struct { DepleteTimer float64 DefID string Name string + Aliases []string Index int RoomID int JustRespawned bool @@ -160,12 +161,13 @@ func (w *World) FindObjInstances(roomID int, name string) []ObjState { if st.RoomID != roomID { continue } - if !wordMatchesObj(lower, st.DefID, st.Name) { + if !wordMatchesObj(lower, st.DefID, st.Name, st.Aliases) { continue } out = append(out, ObjState{ DefID: st.DefID, Name: st.Name, + Aliases: st.Aliases, Index: st.Index, RoomID: st.RoomID, Depleted: st.Depleted, @@ -184,10 +186,15 @@ func (w *World) FindObjInstances(roomID int, name string) []ObjState { return out } -func wordMatchesObj(lower, defID, objName string) bool { +func wordMatchesObj(lower, defID, objName string, aliases []string) bool { if object.WordPrefixMatch(lower, objName) { return true } + for _, alias := range aliases { + if object.WordPrefixMatch(lower, alias) { + return true + } + } inputWords := strings.Fields(strings.ToLower(lower)) if strings.HasPrefix(strings.ToLower(defID), lower) || strings.HasPrefix(lower, strings.ToLower(defID)) { @@ -214,6 +221,16 @@ func (w *World) SetObjName(roomID int, defID string, name string) { } } +func (w *World) SetObjAliases(roomID int, defID string, aliases []string) { + w.mu.Lock() + defer w.mu.Unlock() + for _, st := range w.objStates { + if st.RoomID == roomID && st.DefID == defID { + st.Aliases = aliases + } + } +} + func (w *World) SetObjWander(roomID int, defID string, rooms []int, interval float64) { w.mu.Lock() defer w.mu.Unlock() -- cgit v1.2.3