aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_room_mob.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-28 02:40:30 -0400
committerhistoria <[not public]>2026-06-28 02:40:30 -0400
commita1b6613c6c6a2f8d6e1ecd47e766bd40f92ac295 (patch)
tree4ff8fefb029c93f2aa3db7361658b0b4e9805b66 /internal/game/cmd_room_mob.go
parent87dacfbb3dd16e7f55a82361eace98f9a39d75c8 (diff)
downloadthehouseoficarus-a1b6613c6c6a2f8d6e1ecd47e766bd40f92ac295.tar.gz
feat: admin accounts, god mode, OLC commands like dig/room, 'inline' objects changed to 'local' objects
Diffstat (limited to 'internal/game/cmd_room_mob.go')
-rw-r--r--internal/game/cmd_room_mob.go82
1 files changed, 82 insertions, 0 deletions
diff --git a/internal/game/cmd_room_mob.go b/internal/game/cmd_room_mob.go
new file mode 100644
index 0000000..ced170f
--- /dev/null
+++ b/internal/game/cmd_room_mob.go
@@ -0,0 +1,82 @@
+package game
+
+import (
+ "fmt"
+ "os"
+
+ "gopkg.in/yaml.v3"
+ "thehouseoficarus/internal/net"
+ "thehouseoficarus/internal/world"
+)
+
+func (g *Game) roomMob(sess *net.Session, action string, args []string) {
+ switch action {
+ case "addmob":
+ g.roomAddMob(sess, args)
+ case "remmob":
+ g.roomRemMob(sess, args)
+ }
+}
+
+func (g *Game) roomAddMob(sess *net.Session, args []string) {
+ if len(args) == 0 {
+ sess.WriteLine("Usage: room addmob <mob_id>")
+ return
+ }
+ mobID := args[0]
+ if _, err := g.MobStore.LoadDef(mobID); err != nil {
+ sess.WriteLine(fmt.Sprintf("Mob '%s' not found in data/mobs/.", mobID))
+ return
+ }
+ p := sess.Player
+ room, _, err := g.loadRoomWrite(p)
+ if err != nil {
+ sess.WriteLine(fmt.Sprintf("Error loading room: %v", err))
+ return
+ }
+ for _, m := range room.Mobs {
+ if m.ID == mobID {
+ sess.WriteLine(fmt.Sprintf("Mob '%s' is already in this room.", mobID))
+ return
+ }
+ }
+ room.Mobs = append(room.Mobs, world.RoomMob{ID: mobID})
+
+ path, _ := g.World.GetRoomPath(p.RoomID)
+ data, _ := yaml.Marshal(room)
+ os.WriteFile(path, data, 0644)
+ sess.WriteLine(fmt.Sprintf("Added mob '%s' to room.", mobID))
+}
+
+func (g *Game) roomRemMob(sess *net.Session, args []string) {
+ if len(args) == 0 {
+ sess.WriteLine("Usage: room remmob <mob_id>")
+ return
+ }
+ mobID := args[0]
+ p := sess.Player
+ room, _, err := g.loadRoomWrite(p)
+ if err != nil {
+ sess.WriteLine(fmt.Sprintf("Error loading room: %v", err))
+ return
+ }
+ found := false
+ filtered := room.Mobs[:0]
+ for _, m := range room.Mobs {
+ if m.ID == mobID {
+ found = true
+ } else {
+ filtered = append(filtered, m)
+ }
+ }
+ if !found {
+ sess.WriteLine(fmt.Sprintf("Mob '%s' not found in this room.", mobID))
+ return
+ }
+ room.Mobs = filtered
+
+ path, _ := g.World.GetRoomPath(p.RoomID)
+ data, _ := yaml.Marshal(room)
+ os.WriteFile(path, data, 0644)
+ sess.WriteLine(fmt.Sprintf("Removed mob '%s' from room.", mobID))
+}