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
|
package casino
import (
"testing"
)
func TestCrapsLargestStakeAndOddsLimit(t *testing.T) {
tb := crapsFixture()
tb.Config.MaxBet = MaxCredits / 1000
tb.Config.Craps.Odds = 1000000
tb.join("a")
w := &testWallet{chips: MaxCredits}
amount := tb.Config.MaxBet
tb.bet("a", "pass", amount, w)
tb.resolveRoll(2, 2)
tb.bet("a", "odds pass", amount, w)
if len(w.open) != 2 {
t.Fatal("valid large odds rejected")
}
}
func TestCrapsHopIsUnordered(t *testing.T) {
tb := crapsFixture()
tb.join("a")
w := &testWallet{chips: 100}
tb.bet("a", "hop 3 2", 10, w)
tb.bet("a", "hop 2 3", 10, w)
if len(w.open) != 1 || w.chips != 90 {
t.Fatal("duplicate unordered hop accepted")
}
tb.action("a", "unbet")
if len(w.open) != 0 || w.paid != 0 || w.chips != 100 {
t.Fatal("reverse-order removal failed")
}
}
func TestCrapsMixedPairPreviewCombinesAllBets(t *testing.T) {
tb := crapsFixture()
tb.join("a")
w := &testWallet{chips: 1000}
tb.point = 8
tb.bet("a", "hard 8", 10, w)
tb.bet("a", "hop 2 3", 10, w)
tb.bet("a", "field", 10, w)
for _, row := range tb.projectionFor(tb.players.get("a")) {
if row.Rolls == "4+4" && row.Net != 70 {
t.Fatal("hard win minus hop and field losses", row)
}
if row.Rolls == "2+3" && row.Net != 140 {
t.Fatal("hop win minus field loss", row)
}
}
}
|