diff options
| author | historia <[not public]> | 2026-06-24 20:58:25 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-24 20:58:25 -0400 |
| commit | 9d4b799db4868bcab291b83599ff088763cd4ed6 (patch) | |
| tree | 252f0fcc779acf35243983d643d6399ee2e0cd0b /internal/world/objects.go | |
| parent | d25638d98fe63efdeab570ef77e6a6a97f2d7a60 (diff) | |
| download | thehouseoficarus-9d4b799db4868bcab291b83599ff088763cd4ed6.tar.gz | |
feat: new type of non-violent 'combat': work
Diffstat (limited to 'internal/world/objects.go')
| -rw-r--r-- | internal/world/objects.go | 21 |
1 files changed, 19 insertions, 2 deletions
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() |
