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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
package game
import (
"strings"
"testing"
"thehouseoficarus/internal/casino"
"thehouseoficarus/internal/net"
"thehouseoficarus/internal/player"
)
func TestCasinoHelpTopics(t *testing.T) {
g := &Game{Deps: Deps{DataDir: "../../data"}}
conn := &casinoTestConn{}
sess := &net.Session{Player: player.New("alice"), Conn: conn}
for topic, want := range map[string]string{
"casino": "Profit odds", "play": "Casino quick guide",
"blackjack": "3:2", "baccarat": "0.95:1", "slots": "243",
"roulette": "35:1", "racetrack": "17/37", "zero": "Jeu Zero",
} {
conn.data = nil
g.doHelp(sess, topic)
if !strings.Contains(string(conn.data), want) {
t.Errorf("help %s: %s", topic, conn.data)
}
}
}
func TestTableHelpTeachesCurrentGame(t *testing.T) {
for _, game := range []casino.GameName{casino.GameBlackjack, casino.GameBaccarat, casino.GameRoulette} {
g, sess, conn := uxCasinoGame(t)
g.DataDir = "../../data"
g.Casino.Join(1, casino.TableConfig{ID: "test", Game: game}, "alice")
conn.data = nil
g.executeTableStatus(sess, []string{"help"}, "table help")
text := stripANSI(string(conn.data))
if strings.Contains(text, "No help") || !strings.Contains(text, "Table controls") || !strings.Contains(text, "pays") && !strings.Contains(text, "35:1") {
t.Fatalf("help %s: %s", game, text)
}
if game != casino.GameBlackjack && strings.Contains(text, "insurance / decline") {
t.Fatalf("blackjack-only controls shown for %s", game)
}
}
g, sess, conn := uxCasinoGame(t)
g.DataDir = "../../data"
g.executeTableStatus(sess, []string{"help"}, "table help")
if !strings.Contains(string(conn.data), "Casino quick guide") {
t.Fatal("unseated players cannot learn the games")
}
}
func TestTableHelpAtSlotMachine(t *testing.T) {
g, sess, conn := uxCasinoGame(t)
g.DataDir = "../../data"
g.Casino.JoinMachine(1, casino.MachineConfig{ID: "slots", Game: casino.GameSlots}, "alice")
g.executeTableStatus(sess, []string{"help"}, "table help")
if !strings.Contains(string(conn.data), "Slots quick guide") {
t.Fatal("machine player did not get the slots guide")
}
}
|