diff options
| author | historia <[not public]> | 2026-10-01 05:05:11 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-10-01 05:05:11 -0400 |
| commit | d4eae333a8d8a96452bbf3617aa85b50466c11a7 (patch) | |
| tree | 90d4cf075fe5467b35e5cc53ff3ee30fc4ee1feb /internal/game/casino_ux_test.go | |
| parent | 299b5b67aa80ba2539d7a91c60943060b0426b45 (diff) | |
| download | thehouseoficarus-d4eae333a8d8a96452bbf3617aa85b50466c11a7.tar.gz | |
feat: concise table/machine names, casino command shortcuts, remove payout video poker command
Diffstat (limited to 'internal/game/casino_ux_test.go')
| -rw-r--r-- | internal/game/casino_ux_test.go | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/internal/game/casino_ux_test.go b/internal/game/casino_ux_test.go index aa98c87..89363b0 100644 --- a/internal/game/casino_ux_test.go +++ b/internal/game/casino_ux_test.go @@ -47,6 +47,80 @@ func uxCasinoGame(t *testing.T) (*Game, *net.Session, *casinoTestConn) { return g, sess, sess.Conn.(*casinoTestConn) } +func TestPayoutCommandRemoved(t *testing.T) { + if class := classifyCommand("payout"); class != ClassUnknown { + t.Fatalf("payout is still registered as %v", class) + } +} + +func TestPlaySoleChoiceNeedsNoName(t *testing.T) { + g, sess, _ := casinoCrapsGame(t, "name: Solo\ncasino_tables:\n - id: solo\n game: blackjack\n min_bet: 1\n max_bet: 100\n") + g.executePlay(sess, nil, "play") + table, ok := g.Casino.Participation("alice") + if !ok || table == nil || table.Config.ID != "solo" { + t.Fatal("play with a sole choice did not seat the player") + } +} + +func TestVideoPokerConciseAliases(t *testing.T) { + room := "name: Parlor\ncasino_tables:\n" + + "- id: vp\n game: video_poker\n max_players: 1\n video_poker: {cabinet: classic, payout: low}\n" + + "- id: ux\n game: video_poker\n max_players: 1\n video_poker: {cabinet: ultimate_x_single, payout: low}\n" + + "- id: uxm\n game: video_poker\n max_players: 1\n video_poker: {cabinet: ultimate_x_multi, payout: low}\n" + + "- id: stp\n game: video_poker\n max_players: 1\n video_poker: {cabinet: super_times_pay, payout: low}\n" + + "- id: hr\n game: video_poker\n max_players: 1\n video_poker: {cabinet: hot_roll, payout: low}\n" + g, _, _ := casinoCrapsGame(t, room) + choices := g.casinoChoices(1) + for input, want := range map[string]string{ + "vp": "vp", "poker": "vp", "classic": "vp", "video_poker": "vp", + "ux": "ux", "ultimate_x": "ux", "ultimate_x_single": "ux", + "uxm": "uxm", "ultimate_x_multi": "uxm", "ultimate_x_multi_hand": "uxm", + "stp": "stp", "super_times": "stp", "super_times_pay": "stp", + "hr": "hr", "hot_roll": "hr", + } { + choice, ok := resolveCasinoChoice(choices, input) + if !ok || choice.address != want { + t.Fatalf("play %s resolved to %q (ok=%v), want %q", input, choice.address, ok, want) + } + } +} + +func TestCasinoCommandAbbreviations(t *testing.T) { + g, sess, _ := uxCasinoGame(t) + // Unseated players get no casino shortcuts. + if got, ok := g.casinoAbbreviation(sess, "b"); ok { + t.Fatalf("unseated abbreviation resolved to %q", got) + } + g.executePlay(sess, []string{"bj"}, "play bj") + for input, want := range map[string]string{ + "b": "bet", "be": "bet", "spl": "split", "su": "surrender", + "ins": "insurance", "ro": "roll", "wa": "watch", "ta": "table", + "li": "list", "ga": "game", + } { + got, ok := g.casinoAbbreviation(sess, input) + if !ok || got != want { + t.Fatalf("%q resolved to %q (ok=%v), want %q", input, got, ok, want) + } + } + // stop and rules are full-word only, and movement keeps its own keys. + for _, input := range []string{"sto", "r", "ru", "n", "s"} { + if got, ok := g.casinoAbbreviation(sess, input); ok { + t.Fatalf("%q unexpectedly abbreviated to %q", input, got) + } + } +} + +func TestAbbreviatedCasinoCommandReachesQueue(t *testing.T) { + g, sess, _ := uxCasinoGame(t) + g.queue = NewCommandQueue() + g.executePlay(sess, []string{"bj", "10"}, "play bj 10") + g.handleGameCommand(sess, "b 25") + qc, ok := g.queue.PeekActive("alice") + if !ok || qc.Command != "bet" || qc.Args != "25" { + t.Fatalf("b 25 queued %+v (ok=%v), want bet 25", qc, ok) + } +} + func TestPlayAliasesJoinGames(t *testing.T) { for input, game := range map[string]string{"bj": "blackjack", "black": "blackjack", "bac": "baccarat", "baccarat": "baccarat"} { g, sess, conn := uxCasinoGame(t) |
