1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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")
}
}
|