aboutsummaryrefslogtreecommitdiff
path: root/internal/game/blackjack_rules_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/blackjack_rules_test.go')
-rw-r--r--internal/game/blackjack_rules_test.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/internal/game/blackjack_rules_test.go b/internal/game/blackjack_rules_test.go
new file mode 100644
index 0000000..33598c3
--- /dev/null
+++ b/internal/game/blackjack_rules_test.go
@@ -0,0 +1,41 @@
+package game
+
+import (
+ "os"
+ "path/filepath"
+ "strings"
+ "testing"
+
+ "thehouseoficarus/internal/casino"
+ "thehouseoficarus/internal/net"
+ "thehouseoficarus/internal/player"
+ "thehouseoficarus/internal/world"
+)
+
+func TestLookBlackjackFixtureWithoutScenery(t *testing.T) {
+ dir := t.TempDir()
+ if err := os.MkdirAll(filepath.Join(dir, "rooms"), 0755); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(filepath.Join(dir, "rooms", "1.yaml"), []byte("name: Anywhere\ncasino_tables:\n- id: test\n game: blackjack\n blackjack:\n decks: 1\n blackjack_payout: 1.2\n"), 0644); err != nil {
+ t.Fatal(err)
+ }
+ g := &Game{Deps: Deps{World: world.New(dir)}, Casino: casino.NewManager(1)}
+ conn := &casinoTestConn{}
+ sess := &net.Session{Player: player.New("alice"), Conn: conn}
+ sess.Player.RoomID = 1
+ for _, target := range []string{"blackjack", "blackjack table", "table", "test", "test table"} {
+ conn.data = nil
+ if !g.lookBlackjackTable(sess, target) {
+ t.Fatalf("did not match %q", target)
+ }
+ for _, want := range []string{"Number of decks: 1", "Blackjack pays 6:5", "Double after split: Yes"} {
+ if !strings.Contains(string(conn.data), want) {
+ t.Fatalf("look %s missing %q: %s", target, want, conn.data)
+ }
+ }
+ }
+ if g.lookBlackjackTable(sess, "other") {
+ t.Fatal("matched unrelated target")
+ }
+}