aboutsummaryrefslogtreecommitdiff
path: root/internal/game/casino_machine_address_test.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/casino_machine_address_test.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/casino_machine_address_test.go')
-rw-r--r--internal/game/casino_machine_address_test.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/internal/game/casino_machine_address_test.go b/internal/game/casino_machine_address_test.go
new file mode 100644
index 0000000..3a0280c
--- /dev/null
+++ b/internal/game/casino_machine_address_test.go
@@ -0,0 +1,31 @@
+package game
+
+import (
+ "os"
+ "path/filepath"
+ "testing"
+
+ "thehouseoficarus/internal/casino"
+ "thehouseoficarus/internal/world"
+)
+
+// TestCasinoMachineAddressableByID: a slot cabinet's authored id must be a
+// usable address. The shipped room declares `id: huff_puff_01` with a variant,
+// and matching only the variant/game left the cabinet unreachable as
+// `play huff_puff_01`.
+func TestCasinoMachineAddressableByID(t *testing.T) {
+ dir := t.TempDir()
+ if err := os.MkdirAll(filepath.Join(dir, "rooms"), 0755); err != nil {
+ t.Fatal(err)
+ }
+ room := "name: Casino\ncasino_machines:\n - id: huff_puff_01\n game: slots\n variant: huff_and_even_more_puff\n"
+ if err := os.WriteFile(filepath.Join(dir, "rooms", "1.yaml"), []byte(room), 0644); err != nil {
+ t.Fatal(err)
+ }
+ g := &Game{Deps: Deps{World: world.New(dir)}, Casino: casino.NewManager(1)}
+
+ machine, ok := g.casinoMachine(1, "huff_puff_01")
+ if !ok || machine == nil {
+ t.Fatal("machine id huff_puff_01 is not addressable")
+ }
+}