package game import ( "strings" "testing" "thehouseoficarus/internal/casino" ) // A room with one table of each kind, so look targets and aliases resolve. const lookCasinoRoom = `name: Look Room casino_tables: - id: bjtable game: blackjack blackjack: decks: 2 blackjack_payout: 2 - id: crock game: craps craps: variant: simplified - id: wheel game: roulette - id: pgtable game: paigow pai_gow: variant: classic envy: true ` func TestLookCasinoTableDetailsAndBoards(t *testing.T) { g, sess, conn := casinoCrapsGame(t, lookCasinoRoom) // Craps: details only. The graphical felt and the full rule dump are gone. conn.data = nil if !g.lookCrapsTable(sess, "craps") { t.Fatal("look craps did not match") } text := stripANSI(string(conn.data)) for _, want := range []string{"Craps", "Limits", "Seats", "State", "Rules", "Simplified Craps", "Seated"} { if !strings.Contains(text, want) { t.Fatalf("look craps missing %q: %s", want, text) } } for _, gone := range []string{"PASS ONLY", "bet on pass", "HOUSE EDITION"} { if strings.Contains(text, gone) { t.Fatalf("look craps showed invariant content %q: %s", gone, text) } } // Roulette: details plus the live wheel (tracker, layout, and history). conn.data = nil if !g.lookRouletteTable(sess, "roulette") { t.Fatal("look roulette did not match") } text = stripANSI(string(conn.data)) if !strings.Contains(text, "Roulette / Single zero") || !strings.Contains(text, "single-zero wheel") { t.Fatalf("look roulette missing variant summary: %s", text) } if !strings.Contains(text, "History: last") { t.Fatalf("look roulette missing the live board: %s", text) } if strings.Contains(text, "Roulette payouts") { t.Fatalf("look roulette still dumps the payout reference: %s", text) } } func TestLookCasinoTableAliasesAndFeltGames(t *testing.T) { g, sess, conn := casinoCrapsGame(t, lookCasinoRoom) // Play shortcuts resolve through look too, and the felt games keep their // per-table rule card. for target, want := range map[string]string{"bj": "BLACKJACK PAYS 2 TO 1", "paigow": "FORTUNE", "pai": "FORTUNE"} { conn.data = nil g.doLookTarget(sess, target) text := stripANSI(string(conn.data)) if !strings.Contains(text, want) { t.Fatalf("look %s missing %q: %s", target, want, text) } } if g.lookCrapsTable(sess, "bj") { t.Fatal("look craps matched a blackjack target") } } func TestLookCasinoUsesLiveNormalizedConfig(t *testing.T) { // The room fixture omits max_players and limits; look must report the // defaults EnsureTable fills in, not zero values. g, sess, conn := casinoCrapsGame(t, "name: Bare\ncasino_tables:\n - id: wheel\n game: roulette\n") conn.data = nil if !g.lookRouletteTable(sess, "wheel") { t.Fatal("look by fixture id did not match") } text := stripANSI(string(conn.data)) if !strings.Contains(text, "Seats 0/8") || !strings.Contains(text, "Limits 1-") { t.Fatalf("look missed normalized config: %s", text) } } func TestPaigowGameNameAndRoomListing(t *testing.T) { g, sess, _ := casinoCrapsGame(t, "name: Pai Gow\ncasino_tables:\n - id: fortune\n game: paigow\n pai_gow:\n envy: true\n") g.executePlay(sess, []string{"paigow"}, "play paigow") table, ok := g.Casino.Participation(sess.Player.Name) if !ok || table == nil || table.Config.Game != casino.GamePaiGow { t.Fatalf("play paigow did not join: %v %v", ok, table) } if string(table.Config.Game) != "paigow" { t.Fatalf("game name = %q, want paigow", table.Config.Game) } // The room listing advertises the short name and no longer leaks limits. room, err := g.World.LoadRoom(sess.Player.RoomID) if err != nil { t.Fatal(err) } text := stripANSI(strings.Join(g.showRoomCasinos(sess, room), "\n")) if !strings.Contains(text, "play paigow") || !strings.Contains(text, "Pai Gow Poker | 1/6 seated") { t.Fatalf("room listing wrong: %s", text) } if strings.Contains(text, "Limits") { t.Fatalf("room listing still shows limits: %s", text) } }