aboutsummaryrefslogtreecommitdiff
path: root/internal/game/hacking
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-16 19:57:45 -0400
committerhistoria <[not public]>2026-09-16 19:57:45 -0400
commit6ef40a5739f1723ec26cc32dfc48fe764f776dca (patch)
treee215a4dc96ea639bcea07bb589aae3e31c3609bb /internal/game/hacking
parent1dad15698845d370e998f7cc5feb8aece3fab58f (diff)
downloadthehouseoficarus-6ef40a5739f1723ec26cc32dfc48fe764f776dca.tar.gz
fix: durable payouts survive journal failure, cap bank withdrawals, hash passwords off the owner loop.
Diffstat (limited to 'internal/game/hacking')
-rw-r--r--internal/game/hacking/wumpus.go7
-rw-r--r--internal/game/hacking/wumpus_regression_test.go20
2 files changed, 25 insertions, 2 deletions
diff --git a/internal/game/hacking/wumpus.go b/internal/game/hacking/wumpus.go
index 1f0a434..1d4b371 100644
--- a/internal/game/hacking/wumpus.go
+++ b/internal/game/hacking/wumpus.go
@@ -200,9 +200,12 @@ func (w *WumpusGame) checkRoom() (string, bool, bool) {
if cur == i {
sb.WriteString("ICE detected! You're relocated to a random node...\n")
w.player = rand.Intn(20)
- chained, _, _ := w.checkRoom()
+ // The chained check can terminate the game (landing on the
+ // rogue AI or a data trap): propagate its result instead of
+ // discarding the terminal state.
+ chained, done, won := w.checkRoom()
sb.WriteString(chained)
- return sb.String(), false, false
+ return sb.String(), done, won
}
}
sb.WriteString(w.roomDesc())
diff --git a/internal/game/hacking/wumpus_regression_test.go b/internal/game/hacking/wumpus_regression_test.go
new file mode 100644
index 0000000..b27a7f9
--- /dev/null
+++ b/internal/game/hacking/wumpus_regression_test.go
@@ -0,0 +1,20 @@
+package hacking
+
+import "testing"
+
+// A teleport into a terminal hazard (rogue AI or data trap) must end the
+// hacking session: the chained room check's terminal result is propagated
+// instead of discarded.
+func TestICETeleportTerminalResultIsPropagated(t *testing.T) {
+ for i := 0; i < 2000; i++ {
+ w := &WumpusGame{player: 0, wumpus: 19, pits: [2]int{2, 3}, ice: [2]int{1, 4}, probes: 5}
+ text, done, won := w.HandleInput("move 2")
+ if w.gameOver {
+ if !done || won != w.won {
+ t.Fatalf("terminal state not propagated: done=%v won=%v internal gameOver=%v; output=%s", done, won, w.gameOver, text)
+ }
+ return
+ }
+ }
+ t.Fatal("probe never encountered a terminal teleport")
+}