package game import ( "fmt" "thehouseoficarus/internal/net" ) func (g *Game) executeSneak(sess *net.Session, args []string, rawInput string) { g.doSneak(sess) } func (g *Game) doSneak(sess *net.Session) { p := sess.Player p.Sneaking = !p.Sneaking if p.Sneaking { p.SneakNotified = make(map[string]bool) sess.WriteLine("You begin sneaking.") } else { p.SneakNotified = nil sess.WriteLine("You stop sneaking.") } } func (g *Game) SneakTick() { if g.Hub == nil { return } for key := range g.guardWatchTimers { g.guardWatchTimers[key]++ } for _, sess := range g.Hub.AllSessions() { p := sess.Player if p == nil || !p.Sneaking { continue } objs := g.World.AllObjInstances(p.RoomID) for _, st := range objs { objDef, err := g.ObjectStore.Load(st.DefID) if err != nil || objDef.Steal == nil || objDef.Steal.GuardMob == "" { continue } guard := g.findGuardInRoom(p.RoomID, objDef.Steal.GuardMob) if guard == nil { continue } timerKey := fmt.Sprintf("%d:%s", p.RoomID, st.DefID) if _, exists := g.guardWatchTimers[timerKey]; !exists { g.guardWatchTimers[timerKey] = 0 } watching := g.isGuardWatching(p.RoomID, st.DefID) if p.SneakNotified == nil { p.SneakNotified = make(map[string]bool) } lastState, known := p.SneakNotified[timerKey] if !known || lastState != watching { if watching { sess.WriteLine(fmt.Sprintf("The %s is watching the %s.", guard.Name, objDef.Name)) } else { sess.WriteLine(fmt.Sprintf("The %s looks away from the %s.", guard.Name, objDef.Name)) } p.SneakNotified[timerKey] = watching } } } }