aboutsummaryrefslogtreecommitdiff
path: root/internal/game/roulette_test.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-29 13:28:06 -0400
committerhistoria <[not public]>2026-09-29 13:28:06 -0400
commit9803facd4368420a5dce3af59c835e13cb015cf5 (patch)
tree4ecb75f9c88b16ae72d3573bef026d760eb8d7a8 /internal/game/roulette_test.go
parent13db3e50cb6e29eedbf25416e5284bf08b0adefb (diff)
downloadthehouseoficarus-9803facd4368420a5dce3af59c835e13cb015cf5.tar.gz
feat: roulette in domita casino
Diffstat (limited to 'internal/game/roulette_test.go')
-rw-r--r--internal/game/roulette_test.go78
1 files changed, 78 insertions, 0 deletions
diff --git a/internal/game/roulette_test.go b/internal/game/roulette_test.go
new file mode 100644
index 0000000..0487b0b
--- /dev/null
+++ b/internal/game/roulette_test.go
@@ -0,0 +1,78 @@
+package game
+
+import (
+ "strings"
+ "testing"
+
+ "thehouseoficarus/internal/casino"
+ "thehouseoficarus/internal/net"
+ "thehouseoficarus/internal/player"
+)
+
+func TestRouletteNumericTargetsAndRendering(t *testing.T) {
+ for _, double := range []bool{false, true} {
+ g := &Game{Casino: casino.NewManager(1)}
+ cfg := casino.TableConfig{ID: "roulette", Game: casino.GameRoulette, Roulette: casino.RouletteConfig{DoubleZero: double}}
+ g.Casino.Join(1, cfg, "alice")
+ conn := &casinoTestConn{}
+ sess := &net.Session{Player: player.New("alice"), Conn: conn}
+ g.loggedInChars = map[string]*net.Session{"alice": sess}
+ for _, target := range []string{"0", "17", "00", "red", "column2"} {
+ conn.data = nil
+ g.executeBet(sess, []string{"10", "on", target}, "bet 10 on "+target)
+ expected := "You don't have enough chips and credits"
+ if target == "00" && !double {
+ expected = "Unknown roulette target"
+ }
+ if !strings.Contains(string(conn.data), expected) {
+ t.Fatalf("target=%s double=%v: %s", target, double, conn.data)
+ }
+ }
+ conn.data = nil
+ g.executeTableStatus(sess, []string{"rules"}, "table rules")
+ if !strings.Contains(string(conn.data), "Straight numbers pay 35:1") || strings.Contains(string(conn.data), "Blackjack") {
+ t.Fatal("wrong rules", string(conn.data))
+ }
+ snapshot := &casino.RouletteSnapshot{DoubleZero: double, Phase: "playing", Players: []string{"alice"}}
+ if got := g.renderCasinoSnapshot(sess, snapshot); got != snapshot.ASCII() {
+ t.Fatal("snapshot not rendered", got)
+ }
+ if !g.seesCasinoDetails(sess, casino.Event{RoomID: 1, TableID: "roulette", Snapshot: snapshot}) {
+ t.Fatal("player cannot see wheel")
+ }
+ }
+}
+
+func TestCasinoTestPortalAuthoredContract(t *testing.T) {
+ g, rooms, _ := loadVesta(t)
+ found := false
+ for _, obj := range rooms[1001].Objects {
+ found = found || obj.ID == "casino_test_portal"
+ }
+ if !found {
+ t.Fatal("portal missing from starting room")
+ }
+ obj, err := g.ObjectStore.Load("casino_test_portal")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(obj.OnUse) != 1 || len(obj.OnUse[0].Steps) != 2 {
+ t.Fatal("unexpected portal sequence")
+ }
+ steps := obj.OnUse[0].Steps
+ if len(steps[0].DropTable) != 1 || steps[0].DropTable[0].ItemID != "chips" || steps[0].DropTable[0].Quantity != 1000 {
+ t.Fatal("portal does not grant 1000 chips")
+ }
+ if steps[1].Teleport != 6100 || rooms[6100] == nil {
+ t.Fatal("wrong casino destination")
+ }
+ for _, id := range []int{6182, 6183} {
+ cfg := rooms[id].CasinoTables[0]
+ if err := cfg.Validate(); err != nil {
+ t.Fatal(err)
+ }
+ if cfg.Game != casino.GameRoulette || cfg.Roulette.DoubleZero != (id == 6183) {
+ t.Fatal("wrong roulette rules", id)
+ }
+ }
+}