From 1b9e2da3b3c438d8dc53d3489725dd5ba0022777 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Thu, 11 Jun 2026 04:46:27 -0400 Subject: feat: web client, get/drop updates and fixes --- internal/game/action_room.go | 47 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 internal/game/action_room.go (limited to 'internal/game/action_room.go') diff --git a/internal/game/action_room.go b/internal/game/action_room.go new file mode 100644 index 0000000..426b512 --- /dev/null +++ b/internal/game/action_room.go @@ -0,0 +1,47 @@ +package game + +import ( + "fmt" + "strings" + + "thirdcollapse/internal/net" +) + +func (g *Game) RunEnterSteps(sess *net.Session, roomID int) { + room, err := g.World.LoadRoom(roomID) + if err != nil || len(room.OnEnter) == 0 { + return + } + for _, step := range room.OnEnter { + if step.Condition != nil && !g.checkCondition(sess, step.Condition) { + continue + } + if step.Message != "" { + sess.WriteLine(fmt.Sprintf("\n%s", step.Message)) + } + } +} + +func (g *Game) BroadcastRespawns() { + respawns := g.World.FlushObjRespawns() + for _, st := range respawns { + def, err := g.ObjectStore.Load(st.DefID) + if err != nil || def.BehaviorID == "" { + continue + } + cfg, err := g.BehaviorStore.LoadGather(def.BehaviorID) + if err != nil || cfg.RespawnBroadcast == "" { + continue + } + name := def.Name + if idx := st.Index + 1; len(g.World.FindObjInstances(st.RoomID, st.DefID)) > 1 { + name += fmt.Sprintf(" [%d]", idx) + } + msg := strings.ReplaceAll(cfg.RespawnBroadcast, "{name}", name) + if g.Hub != nil { + for _, sess := range g.Hub.PlayersInRoom(st.RoomID) { + sess.WriteLine(fmt.Sprintf("\n%s", msg)) + } + } + } +} -- cgit v1.2.3