aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_room_mob.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-19 03:15:59 -0400
committerhistoria <[not public]>2026-09-19 03:15:59 -0400
commit0e60567a7a0addb9421769ee7be7853bfa8788cb (patch)
tree7645112db0e4eae95b8a83c1e4f9aab38bede655 /internal/game/cmd_room_mob.go
parentcc33072eced3d5460512c09c42ec4531c807d7af (diff)
downloadthehouseoficarus-0e60567a7a0addb9421769ee7be7853bfa8788cb.tar.gz
refactor: simplifcation, change how rooms are stored in player yaml, remove legacy code
Diffstat (limited to 'internal/game/cmd_room_mob.go')
-rw-r--r--internal/game/cmd_room_mob.go11
1 files changed, 2 insertions, 9 deletions
diff --git a/internal/game/cmd_room_mob.go b/internal/game/cmd_room_mob.go
index ce729d4..5adc4b2 100644
--- a/internal/game/cmd_room_mob.go
+++ b/internal/game/cmd_room_mob.go
@@ -3,7 +3,6 @@ package game
import (
"fmt"
- "gopkg.in/yaml.v3"
"thehouseoficarus/internal/net"
"thehouseoficarus/internal/world"
)
@@ -41,10 +40,7 @@ func (g *Game) roomAddMob(sess *net.Session, args []string) {
}
room.Mobs = append(room.Mobs, world.RoomMob{ID: mobID})
- path, _ := g.World.GetRoomPath(p.RoomID)
- data, _ := yaml.Marshal(room)
- if err := writeRoomFile(path, data); err != nil {
- sess.WriteLine(fmt.Sprintf("Error saving room: %v", err))
+ if !g.mutateRoom(sess, func(r *world.Room) { *r = *room }) {
return
}
sess.WriteLine(fmt.Sprintf("Added mob '%s' to room.", mobID))
@@ -77,10 +73,7 @@ func (g *Game) roomRemMob(sess *net.Session, args []string) {
}
room.Mobs = filtered
- path, _ := g.World.GetRoomPath(p.RoomID)
- data, _ := yaml.Marshal(room)
- if err := writeRoomFile(path, data); err != nil {
- sess.WriteLine(fmt.Sprintf("Error saving room: %v", err))
+ if !g.mutateRoom(sess, func(r *world.Room) { *r = *room }) {
return
}
sess.WriteLine(fmt.Sprintf("Removed mob '%s' from room.", mobID))