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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
package game
import (
"strings"
"testing"
"thehouseoficarus/internal/item"
"thehouseoficarus/internal/player"
)
func TestEdgeListAllTableGames(t *testing.T) {
for _, game := range []string{"blackjack", "baccarat", "roulette", "craps", "paigow", "video_poker"} {
t.Run(game, func(t *testing.T) {
g, sess, conn := houseEdgeGame(t, "name: Casino\ncasino_tables:\n - id: test\n game: "+game+"\n")
writeHouseEdgeManual(t, g, sess, 2)
g.executePlay(sess, []string{game}, "play "+game)
if strings.Contains(stripANSI(string(conn.data)), "RTP") {
t.Fatal("readout on join")
}
conn.data = nil
g.executeList(sess, nil, "list")
text := stripANSI(string(conn.data))
if !strings.Contains(text, "RTP") {
t.Fatalf("no RTP column for %s: %s", game, text)
}
assertRTPColumn(t, text)
sess.Player.Inventory = nil
conn.data = nil
g.executeList(sess, nil, "list")
if strings.Contains(stripANSI(string(conn.data)), "RTP") {
t.Fatal("readout after reference removed")
}
})
}
}
func TestEdgeListBlackjackActionsOmitRTP(t *testing.T) {
g, sess, conn := houseEdgeGame(t, "name: BJ\ncasino_tables:\n - id: bj\n game: blackjack\n")
writeHouseEdgeManual(t, g, sess, 2)
g.executePlay(sess, []string{"bj"}, "play bj")
table, _ := g.Casino.Participation(sess.Player.Name)
for i := 0; i < 10 && len(table.Wagers(sess.Player.Name)) == 0; i++ {
g.executeBet(sess, []string{"1"}, "bet 1")
}
rows := table.Wagers(sess.Player.Name)
if len(rows) == 0 {
t.Skip("no action rows this deal")
}
insurance := false
for _, r := range rows {
if r.Bet == "insurance" {
insurance = true
}
}
conn.data = nil
g.executeList(sess, nil, "list")
text := stripANSI(string(conn.data))
if insurance {
// Insurance is a real wager and carries an RTP.
if !strings.Contains(text, "RTP") {
t.Fatalf("insurance list lost its RTP:\n%s", text)
}
return
}
if strings.Contains(text, "RTP") {
t.Fatalf("action-only list showed an RTP column:\n%s", text)
}
}
func TestEdgeListRealInstruments(t *testing.T) {
g, sess, conn := houseEdgeGame(t, roomRoulette)
g.ItemStore = item.NewItemStore("../../data")
sess.Player.Inventory = map[int]*player.InventorySlot{
0: {ItemID: "house_edge_tile", Quantity: 1},
1: {ItemID: "house_edge_computus", Quantity: 1},
}
g.executePlay(sess, []string{"roulette"}, "play roulette")
conn.data = nil
g.executeList(sess, nil, "list")
text := stripANSI(string(conn.data))
if strings.Count(text, "97.30%") != 12 {
t.Fatalf("best instrument not used: %s", text)
}
sess.Player.Inventory[1].Quantity = 0
conn.data = nil
g.executeList(sess, nil, "list")
text = stripANSI(string(conn.data))
if strings.Count(text, "97%") != 12 {
t.Fatalf("tile not used: %s", text)
}
sess.Player.Inventory[0].Quantity = 0
conn.data = nil
g.executeList(sess, nil, "list")
if strings.Contains(stripANSI(string(conn.data)), "RTP") {
t.Fatal("zero-quantity item activated")
}
}
|