diff options
| author | historia <[not public]> | 2026-10-03 07:11:58 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-10-03 07:11:58 -0400 |
| commit | 0fb83bdf433b9b48240f4ac7a5d4c912f6b808cc (patch) | |
| tree | ac0af51cc2513b1ddd8a280f360af820d1f097af /internal/game/casino_ux_test.go | |
| parent | 6232d41e5639f9c38e47b2bb65266e343ca26e8f (diff) | |
| download | thehouseoficarus-0fb83bdf433b9b48240f4ac7a5d4c912f6b808cc.tar.gz | |
feat: added big 6 wheel to the casino
Diffstat (limited to 'internal/game/casino_ux_test.go')
| -rw-r--r-- | internal/game/casino_ux_test.go | 51 |
1 files changed, 46 insertions, 5 deletions
diff --git a/internal/game/casino_ux_test.go b/internal/game/casino_ux_test.go index c83db27..423469c 100644 --- a/internal/game/casino_ux_test.go +++ b/internal/game/casino_ux_test.go @@ -93,23 +93,64 @@ func TestCasinoCommandAbbreviations(t *testing.T) { } 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", + "b": "bet", "be": "bet", "spl": "split", "sp": "split", "su": "surrender", + "ins": "insurance", "wa": "watch", "ta": "table", + "li": "list", "ga": "game", "sto": "stop", "ru": "rules", + // The terse aliases resolve only because their verb is a blackjack verb. + "h": "hit", "st": "stand", "dd": "double", } { 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"} { + // No other game's verbs leak into a blackjack table. + for _, input := range []string{"ro", "rol", "ra", "au", "dr", "pa", "ha", "ho"} { + if got, ok := g.casinoAbbreviation(sess, input); ok { + t.Fatalf("blackjack %q unexpectedly abbreviated to %q", input, got) + } + } + // Exact commands keep their meaning: movement, info, and whole words that + // are already real commands. + for _, input := range []string{"n", "s", "e", "w", "i", "l", "hit"} { if got, ok := g.casinoAbbreviation(sess, input); ok { t.Fatalf("%q unexpectedly abbreviated to %q", input, got) } } } +func TestCasinoAbbreviationsAreGameScoped(t *testing.T) { + // Baccarat has neither split nor spin, so "sp" matches nothing there. + g, sess, _ := uxCasinoGame(t) + g.executePlay(sess, []string{"bac"}, "play bac") + for _, input := range []string{"sp", "spl", "ro", "au"} { + if got, ok := g.casinoAbbreviation(sess, input); ok { + t.Fatalf("baccarat %q unexpectedly abbreviated to %q", input, got) + } + } + if got, ok := g.casinoAbbreviation(sess, "be"); !ok || got != "bet" { + t.Fatalf("baccarat be resolved to %q (ok=%v), want bet", got, ok) + } + + // Craps owns roll/autoroll; a blackjack table must not resolve them. + g2, sess2, _ := casinoCrapsGame(t, "name: Pit\ncasino_tables:\n - id: cr\n game: craps\n") + g2.executePlay(sess2, []string{"craps"}, "play craps") + if got, ok := g2.casinoAbbreviation(sess2, "ro"); !ok || got != "roll" { + t.Fatalf("craps ro resolved to %q (ok=%v), want roll", got, ok) + } + if got, ok := g2.casinoAbbreviation(sess2, "rol"); !ok || got != "roll" { + t.Fatalf("craps rol resolved to %q (ok=%v), want roll", got, ok) + } + if got, ok := g2.casinoAbbreviation(sess2, "au"); !ok || got != "autoroll" { + t.Fatalf("craps au resolved to %q (ok=%v), want autoroll", got, ok) + } + for _, input := range []string{"sp", "spl", "ins", "su"} { + if got, ok := g2.casinoAbbreviation(sess2, input); ok { + t.Fatalf("craps %q unexpectedly abbreviated to %q", input, got) + } + } +} + func TestAbbreviatedCasinoCommandReachesQueue(t *testing.T) { g, sess, _ := uxCasinoGame(t) g.queue = NewCommandQueue() |
