aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/casino_review_regression_test.go
blob: c66dee6c3db3ca0efb2daed6a752c1fd749c939d (plain)
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
package casino

import (
	"reflect"
	"strings"
	"testing"
)

func TestCrapsRoundedOddsRespectTableMaximum(t *testing.T) {
	for _, kind := range []string{"pass", "dontpass"} {
		t.Run(kind, func(t *testing.T) {
			table := crapsFixture()
			table.Config.MaxBet = 11
			table.join("a")
			w := &testWallet{chips: 100}
			table.bet("a", kind, 10, w)
			table.resolveRoll(3, 3)
			// Eleven rounds to 15 for pass odds, or 12 for don't odds.
			events := table.bet("a", "odds "+kind, 11, w)
			if !hasMessage(events, "above the table maximum") || len(w.open) != 1 || table.players.get("a").bets[0].odds.Total != 0 {
				t.Fatalf("rounded odds bypassed maximum: %+v", events)
			}
		})
	}
}

func TestCrapsFailedUnbetPreservesAllLiveWagers(t *testing.T) {
	for _, retry := range []bool{false, true} {
		t.Run(map[bool]string{false: "roll", true: "retry"}[retry], func(t *testing.T) {
			table := crapsFixture()
			table.join("a")
			w := &pokerTestWallet{testWallet: testWallet{chips: 1000}}
			table.bet("a", "pass", 10, w)
			table.resolveRoll(3, 3)
			table.bet("a", "odds pass", 10, w)
			table.bet("a", "place 8", 12, w)
			before := table.view().Bets
			w.fail = true
			events := table.action("a", "unbet")
			if !hasMessage(events, "All wagers remain live") || !reflect.DeepEqual(before, table.view().Bets) || len(w.open) != 3 || !table.players.get("a").HasBet {
				t.Fatalf("failed refund changed live wagers: %+v", events)
			}
			w.fail = false
			if retry {
				table.action("a", "unbet")
				table.action("a", "unbet")
				if w.chips != 990 || len(w.open) != 1 || table.players.get("a").bets[0].odds.Total != 0 {
					t.Fatalf("refund retry was not exact: %+v", w)
				}
			} else {
				table.resolveRoll(3, 3)
				if w.paid != 42 || len(w.open) != 1 {
					t.Fatalf("preserved pass/odds failed to settle: %+v", w)
				}
			}
		})
	}
}

func TestPokerPreparationClearsPreviousBonusPresentation(t *testing.T) {
	for _, command := range []string{"coins", "coins 1", "unbet", "denom 10", "hands 5", "game ddb", "feature off"} {
		t.Run(command, func(t *testing.T) {
			table, w, _ := pokerTestCabinet(t, VideoPokerConfig{Cabinet: CabinetHotRoll})
			pokerDeal(t, table, w)
			table.action("alice", "draw")
			p := table.players["alice"]
			p.multiplier, p.dice = 12, [2]int{6, 6}
			p.loaded = 5
			events := table.action("alice", command)
			snap, ok := events[0].Snapshot.(*VideoPokerSnapshot)
			if !ok {
				t.Fatalf("command rejected: %+v", events)
			}
			if snap.Multiplier != 1 || snap.Dice != [2]int{} || snap.NoWin || snap.Held != [5]bool{} || len(snap.Cards) != 0 || len(snap.Lines) != 0 || len(snap.Current) != 0 {
				t.Fatalf("stale result after %s: %+v", command, snap)
			}
			if len(w.open) != 0 {
				t.Fatal("preparation created a wager")
			}
		})
	}
}

func TestBonusPokerDeluxeRuleDescribesFlatQuadAward(t *testing.T) {
	cfg := (VideoPokerConfig{Variant: "bonus_poker_deluxe"}).Normalize()
	if rule := cfg.PairRule(); !strings.Contains(rule, "80 per coin") || strings.Contains(rule, "by rank") {
		t.Fatalf("incorrect Deluxe rule: %s", rule)
	}
}