aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_room.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/cmd_room.go')
-rw-r--r--internal/game/cmd_room.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/internal/game/cmd_room.go b/internal/game/cmd_room.go
index 24763fa..971e298 100644
--- a/internal/game/cmd_room.go
+++ b/internal/game/cmd_room.go
@@ -7,6 +7,7 @@ import (
"gopkg.in/yaml.v3"
"thehouseoficarus/internal/behavior"
+ "thehouseoficarus/internal/color"
"thehouseoficarus/internal/net"
"thehouseoficarus/internal/player"
"thehouseoficarus/internal/world"
@@ -46,6 +47,10 @@ func (g *Game) executeRoom(sess *net.Session, args []string, rawInput string) {
g.roomMob(sess, action, rest)
case "addspawn", "remspawn":
g.roomSpawn(sess, action, rest)
+ case "color":
+ g.roomSetColor(sess, rest)
+ case "insert":
+ g.roomInsert(sess, rest)
default:
sess.WriteLine(fmt.Sprintf("Unknown room action: %s", action))
g.showRoomHelp(sess)
@@ -66,6 +71,8 @@ func (g *Game) showRoomHelp(sess *net.Session) {
sess.WriteLine(" room remmob <mob_id> — remove a mob spawn")
sess.WriteLine(" room addspawn <item_id> [qty] [respawn_ticks] — add an item spawn")
sess.WriteLine(" room remspawn <item_id> — remove an item spawn")
+ sess.WriteLine(" room color <spec|off> — set or clear room map color")
+ sess.WriteLine(" room insert <direction> [name] — insert a new room into the exit, pushing rooms beyond")
}
func (g *Game) roomSetName(sess *net.Session, args []string) {
@@ -92,6 +99,36 @@ func (g *Game) roomSetDesc(sess *net.Session, args []string) {
sess.WriteLine("Room description updated.")
}
+func (g *Game) roomSetColor(sess *net.Session, args []string) {
+ if len(args) == 0 {
+ sess.WriteLine("Usage: room color <spec|off>")
+ sess.WriteLine("Format: <00-FF> [bg:<00-FF>] [bold] [dim] [underline]")
+ sess.WriteLine("Example: D0 bold")
+ return
+ }
+ value := strings.Join(args, " ")
+ if value == "off" {
+ value = ""
+ }
+ if value != "" {
+ spec := color.Parse(value)
+ if spec.Empty() {
+ sess.WriteLine(fmt.Sprintf("Invalid color string: %s", value))
+ sess.WriteLine("Format: <00-FF> [bg:<00-FF>] [bold] [dim] [underline]")
+ sess.WriteLine("Example: D0 bold")
+ return
+ }
+ }
+ g.writeRoom(sess, func(room *world.Room) {
+ room.Color = value
+ })
+ if value == "" {
+ sess.WriteLine("Room color cleared.")
+ } else {
+ sess.WriteLine(fmt.Sprintf("Room color set to: %s", value))
+ }
+}
+
func (g *Game) loadRoomWrite(p *player.Player) (*world.Room, string, error) {
path, ok := g.World.GetRoomPath(p.RoomID)
if !ok {