package game import ( "path/filepath" "strings" "testing" "thehouseoficarus/internal/casino" "thehouseoficarus/internal/color" "thehouseoficarus/internal/world" ) func TestCrapsVariantRendering(t *testing.T) { for _, v := range []string{"simplified", "high_point", "crapless", "new_york", "die_rich", "diceless"} { for _, unicode := range []bool{false, true} { for _, mode := range []string{"none", "xterm256"} { for _, style := range []string{"dark", "light"} { dice := [2]int{4, 2} if v == "die_rich" { dice[1] = 0 } text := renderCrapsSnapshot(&casino.CrapsSnapshot{Variant: v, Point: 4, Dice: dice}, mode, unicode, style) plain := plainRoulette(text) if !strings.Contains(plain, strings.ToUpper(strings.ReplaceAll(v, "_", " "))+" CRAPS") { t.Fatal(v, "title") } if v == "diceless" { for _, token := range []string{"PACK A", "PACK B", "Cards total: 6", "FIRE"} { if !strings.Contains(plain, token) { t.Fatal(v, token) } } if strings.Contains(plain, "Total:") { t.Fatal("dice rendered instead of cards") } } else { if strings.Contains(plain, "FIRE") || strings.Contains(plain, "ALL SMALL") { t.Fatal(v, "unsupported bonus display") } } if v == "die_rich" && !strings.Contains(plain, "Total: 4") { t.Fatal("single die absent") } if mode == "xterm256" && (v == "die_rich" || v == "diceless") { bg := 0 if style == "light" { bg = 15 } if !strings.Contains(text, color.BgCode(mode, bg)) { t.Fatal(v, "style") } } } } } } for n := 1; n <= 6; n++ { text := renderCrapsDice([2]int{n, 0}, "none", false, "dark") if strings.Count(text, "+-------+") != 2 { t.Fatal("must render exactly one die", text) } } } func TestShippedCrapsGallery(t *testing.T) { w := world.New(filepath.Join("..", "..", "data")) variants := []string{"bank", "simplified", "high_point", "crapless", "new_york", "die_rich", "diceless"} for i, v := range variants { id := 6185 + i room, err := w.LoadRoom(id) if err != nil { t.Fatal(err) } if len(room.CasinoTables) != 1 { t.Fatal(id, "missing table") } cfg := room.CasinoTables[0] if cfg.Game != casino.GameCraps || cfg.Craps.Variant != v { t.Fatal(id, cfg) } if err := cfg.Validate(); err != nil { t.Fatal(id, err) } if i > 0 && room.Exits["south"].Room != id-1 { t.Fatal(id, "missing return exit") } if i < len(variants)-1 && room.Exits["north"].Room != id+1 { t.Fatal(id, "unreachable next table") } m := casino.NewManager(1) m.Join(id, cfg, "a") if m.Table(id, cfg.ID) == nil { t.Fatal(id, "table registration") } } room, err := w.LoadRoom(6182) if err != nil { t.Fatal(err) } if room.Exits["west"].Room != 6185 { t.Fatal("gallery unreachable from roulette") } }