diff options
| author | historia <[not public]> | 2026-06-11 04:46:27 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-11 08:58:37 +0000 |
| commit | 1b9e2da3b3c438d8dc53d3489725dd5ba0022777 (patch) | |
| tree | 62264f24420bf4cfaa734942c65cc8dd45ba3d3b /internal/world/mob.go | |
| parent | 06c02a697e5daf8832a462de5970dd4c0e13a02c (diff) | |
| download | thehouseoficarus-1b9e2da3b3c438d8dc53d3489725dd5ba0022777.tar.gz | |
feat: web client, get/drop updates and fixes
Diffstat (limited to 'internal/world/mob.go')
| -rw-r--r-- | internal/world/mob.go | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/internal/world/mob.go b/internal/world/mob.go index 9dfec59..59c8a20 100644 --- a/internal/world/mob.go +++ b/internal/world/mob.go @@ -33,8 +33,6 @@ type MobDef struct { Protected bool `yaml:"protected"` Unique bool `yaml:"unique"` RespawnTicks int `yaml:"respawn_ticks"` - WanderRooms []int `yaml:"wander_rooms"` - WanderInterval int `yaml:"wander_interval"` Drops DropTable `yaml:"drops"` } @@ -70,13 +68,24 @@ const ( ) func WordPrefixMatch(input, name string) bool { - lower := strings.ToLower(input) - for _, word := range strings.Fields(name) { - if strings.HasPrefix(strings.ToLower(word), lower) { - return true + inputWords := strings.Fields(strings.ToLower(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 false + return true } func (m *MobInstance) MatchQuality(input string) int { @@ -198,20 +207,19 @@ func (s *MobStore) RollIdleDescription(inst *MobInstance) { return } inst.IdleDescription = pickIdleDescription(def.IdleDescriptions) - inst.WanderRooms = def.WanderRooms - inst.WanderInterval = def.WanderInterval inst.WanderTickCounter = 0 } -func (s *MobStore) SeedMobs(roomID int, mobIDs []string) { +func (s *MobStore) SeedMobs(roomID int, entries []RoomMob) { type defWrapper struct { def *MobDef err error + rm RoomMob } - defs := make([]defWrapper, len(mobIDs)) - for i, defID := range mobIDs { - d, err := s.LoadDef(defID) - defs[i] = defWrapper{d, err} + defs := make([]defWrapper, len(entries)) + for i, rm := range entries { + d, err := s.LoadDef(rm.ID) + defs[i] = defWrapper{d, err, rm} } s.mu.Lock() @@ -220,11 +228,9 @@ func (s *MobStore) SeedMobs(roomID int, mobIDs []string) { if dw.err != nil { continue } - defID := mobIDs[i] + defID := dw.rm.ID instID := fmt.Sprintf("%s_%d_%d", defID, roomID, i) - if inst, exists := s.instances[instID]; exists { - // Already exists — skip (respawn is handled by timers) - _ = inst + if _, exists := s.instances[instID]; exists { continue } inst := &MobInstance{ @@ -242,8 +248,8 @@ func (s *MobStore) SeedMobs(roomID int, mobIDs []string) { Protected: dw.def.Protected, Unique: dw.def.Unique, RespawnTicks: dw.def.RespawnTicks, - WanderRooms: dw.def.WanderRooms, - WanderInterval: dw.def.WanderInterval, + WanderRooms: dw.rm.WanderRooms, + WanderInterval: dw.rm.WanderInterval, RoomID: roomID, HomeRoomID: roomID, Drops: dw.def.Drops, |
