aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md4
-rw-r--r--data/rooms/intro/1017.yaml2
-rw-r--r--internal/game/cmd_undig.go8
-rw-r--r--internal/game/render_map.go97
4 files changed, 86 insertions, 25 deletions
diff --git a/README.md b/README.md
index 2444c4c..cb23503 100644
--- a/README.md
+++ b/README.md
@@ -48,12 +48,12 @@ There is not much here yet.
# Building
-Install make and Go then
+Install Go then
```
git clone https://codeberg.org/historia/thehouseoficarus
cd thehouseoficarus
-make
+go build -o thoi ./cmd/mud
./thoi
```
diff --git a/data/rooms/intro/1017.yaml b/data/rooms/intro/1017.yaml
index 358ba9e..14585ae 100644
--- a/data/rooms/intro/1017.yaml
+++ b/data/rooms/intro/1017.yaml
@@ -1,4 +1,4 @@
-id: 0
+id: 1017
name: New Room
color: ""
description:
diff --git a/internal/game/cmd_undig.go b/internal/game/cmd_undig.go
index 1fc70c1..2215c51 100644
--- a/internal/game/cmd_undig.go
+++ b/internal/game/cmd_undig.go
@@ -58,10 +58,9 @@ func (g *Game) executeUndig(sess *net.Session, args []string, rawInput string) {
sess.State = net.StateUndigConfirm
sess.WriteLine(fmt.Sprintf("You are about to DELETE Room #%d (%s) and all exits leading to it.", targetID, targetRoom.Name))
- sess.WriteLine("")
g.listUndigOrphans(sess, targetID)
sess.WriteLine("")
- sess.WriteLine(fmt.Sprintf("Type UNDIG %s to confirm, or anything else to cancel.", strings.ToUpper(string(dir))))
+ sess.WriteLine("Undig? [y/N]")
}
func (g *Game) listUndigOrphans(sess *net.Session, targetID int) {
@@ -131,7 +130,7 @@ func (g *Game) handleUndigConfirm(sess *net.Session, input string) {
return
}
- choice := strings.TrimSpace(input)
+ choice := strings.ToLower(strings.TrimSpace(input))
dir := sess.PendingUndigDir
targetID := sess.PendingUndigRoom
sess.PendingUndigDir = ""
@@ -143,8 +142,7 @@ func (g *Game) handleUndigConfirm(sess *net.Session, input string) {
return
}
- expected := "UNDIG " + strings.ToUpper(dir)
- if strings.ToUpper(choice) != expected {
+ if choice != "y" && choice != "yes" {
sess.WriteLine("Undig cancelled.")
g.writePrompt(sess)
return
diff --git a/internal/game/render_map.go b/internal/game/render_map.go
index b210e77..b4b8c93 100644
--- a/internal/game/render_map.go
+++ b/internal/game/render_map.go
@@ -206,30 +206,46 @@ func buildTinyMap(g *Game, sess *net.Session, roomID int, mg mapGlyphs) []string
cur, _ := loadRoom(g, roomID)
if cur != nil {
- if upTarget, hasUp := exitTarget(cur, world.Up); hasUp {
+ _, hasUp := exitTarget(cur, world.Up)
+ _, hasDown := exitTarget(cur, world.Down)
+
+ upCorners := [][2]int{
+ {1, 3}, // NE
+ {1, 1}, // NW
+ {3, 3}, // SE
+ {3, 1}, // SW
+ }
+ downCorners := [][2]int{
+ {3, 1}, // SW
+ {3, 3}, // SE
+ {1, 3}, // NE
+ {1, 1}, // NW
+ }
+
+ placeArrow := func(corners [][2]int, glyph rune, blockedSpec color.ColorSpec) {
+ for _, c := range corners {
+ if grid[c[0]][c[1]].char == ' ' {
+ grid[c[0]][c[1]] = mapCell{char: glyph, spec: blockedSpec}
+ return
+ }
+ }
+ }
+
+ if hasUp {
spec := color.NoColor()
- if exitStateTo(g, sess, roomID, world.Up, upTarget) == exitBlocked {
+ if upTarget, _ := exitTarget(cur, world.Up); upTarget != 0 &&
+ exitStateTo(g, sess, roomID, world.Up, upTarget) == exitBlocked {
spec = ctx.blockedSpec
}
- switch {
- case grid[1][3].char == ' ':
- grid[1][3] = mapCell{char: mg.upArrow, spec: spec}
- case grid[1][1].char == ' ':
- grid[1][1] = mapCell{char: mg.upArrow, spec: spec}
- case grid[1][2].char == ' ':
- grid[1][2] = mapCell{char: mg.upArrow, spec: spec}
- }
+ placeArrow(upCorners, mg.upArrow, spec)
}
- if downTarget, hasDown := exitTarget(cur, world.Down); hasDown {
+ if hasDown {
spec := color.NoColor()
- if exitStateTo(g, sess, roomID, world.Down, downTarget) == exitBlocked {
+ if downTarget, _ := exitTarget(cur, world.Down); downTarget != 0 &&
+ exitStateTo(g, sess, roomID, world.Down, downTarget) == exitBlocked {
spec = ctx.blockedSpec
}
- if grid[3][1].char == ' ' {
- grid[3][1] = mapCell{char: mg.downArrow, spec: spec}
- } else if grid[3][3].char == ' ' {
- grid[3][3] = mapCell{char: mg.downArrow, spec: spec}
- }
+ placeArrow(downCorners, mg.downArrow, spec)
}
}
@@ -333,6 +349,53 @@ func buildFullMap(g *Game, sess *net.Session, roomID, mapWidth, mapHeight int, m
}
}
+ cur, _ := loadRoom(g, roomID)
+ if cur != nil {
+ _, hasUp := exitTarget(cur, world.Up)
+ _, hasDown := exitTarget(cur, world.Down)
+
+ upCorners := [][2]int{
+ {cy - 1, cx + 1}, // NE
+ {cy - 1, cx - 1}, // NW
+ {cy + 1, cx + 1}, // SE
+ {cy + 1, cx - 1}, // SW
+ }
+ downCorners := [][2]int{
+ {cy + 1, cx - 1}, // SW
+ {cy + 1, cx + 1}, // SE
+ {cy - 1, cx + 1}, // NE
+ {cy - 1, cx - 1}, // NW
+ }
+
+ placeArrow := func(corners [][2]int, glyph rune, blockedSpec color.ColorSpec) {
+ for _, c := range corners {
+ r, col := c[0], c[1]
+ if r >= 0 && r < mapHeight && col >= 0 && col < mapWidth &&
+ grid[r][col].char == ' ' {
+ grid[r][col] = mapCell{char: glyph, spec: blockedSpec}
+ return
+ }
+ }
+ }
+
+ if hasUp {
+ spec := color.NoColor()
+ if upTarget, _ := exitTarget(cur, world.Up); upTarget != 0 &&
+ exitStateTo(g, sess, roomID, world.Up, upTarget) == exitBlocked {
+ spec = ctx.blockedSpec
+ }
+ placeArrow(upCorners, mg.upArrow, spec)
+ }
+ if hasDown {
+ spec := color.NoColor()
+ if downTarget, _ := exitTarget(cur, world.Down); downTarget != 0 &&
+ exitStateTo(g, sess, roomID, world.Down, downTarget) == exitBlocked {
+ spec = ctx.blockedSpec
+ }
+ placeArrow(downCorners, mg.downArrow, spec)
+ }
+ }
+
return renderMapCells(grid, colorMode, 0, mapHeight, 0)
}