aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/video_poker_bonus_test.go
blob: 6fd06b2c6684d834c0e99db2e35f62f7e62bffa6 (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package casino

import "testing"

func TestPokerUltimateXPerLineAndMachineBanks(t *testing.T) {
	table, w, bank := pokerTestCabinet(t, VideoPokerConfig{Cabinet: CabinetUXMulti})
	save := bank
	table.action("alice", "hands 3")
	p := table.players["alice"]
	key := table.multiplierKey(p)
	table.banks[key] = []int{2, 3, 4}
	// A bank at denomination 1 does not carry into denomination 10.
	table.action("alice", "denom 10")
	pokerDeal(t, table, w)
	for _, m := range p.current {
		if m != 1 {
			t.Fatal("denomination imported a saved multiplier")
		}
	}
	table.action("alice", "draw")
	// Restore denomination 1: the saved bank applies again.
	table.action("alice", "denom 1")
	pokerDeal(t, table, w)
	for i, m := range []int{2, 3, 4} {
		if p.current[i] != m {
			t.Fatal("same-denomination bank lost")
		}
	}
	p.cards = pokerHand("Ah 3h 6h 9h Jh")
	table.action("alice", "12345")
	before := w.paid
	table.action("alice", "draw")
	if w.paid-before != 270 {
		t.Fatalf("expected 5 coins * 6 flush * (2+3+4), got %d", w.paid-before)
	}
	for i, line := range p.lines {
		if line.Multiplier != i+2 || p.next[i] != 11 || table.banks[key][i] != 11 {
			t.Fatal("current multiplier compounded into the next award")
		}
	}
	if save.writes == 0 {
		t.Fatal("the engine bank sink was never invoked")
	}
	// Feature off: no fee, no new multipliers, saved ones still pay.
	table.action("alice", "feature off")
	pokerDeal(t, table, w)
	if p.wager.Total != 15 {
		t.Fatal("cashout charged the feature")
	}
	p.cards = pokerHand("Ah Kh Qh Jh 10h")
	table.action("alice", "12345")
	before = w.paid
	table.action("alice", "draw")
	if w.paid-before != 132000 {
		t.Fatalf("cashout returned %d", w.paid-before)
	}
	// A five-coin hand consumes the multipliers it paid with: the new bank
	// is 1x because the feature is off.
	for _, m := range table.banks[key] {
		if m != 1 {
			t.Fatal("spent bank was not cleared")
		}
	}
	// The next five-coin hand plays at plain rates.
	pokerDeal(t, table, w)
	for _, m := range p.current {
		if m != 1 {
			t.Fatal("consumed bank applied twice")
		}
	}
	p.cards = pokerHand("Ah Kh Qh Jh 10h")
	table.action("alice", "12345")
	before = w.paid
	table.action("alice", "draw")
	if w.paid-before != 12000 {
		t.Fatalf("plain royal returned %d", w.paid-before)
	}
}
func TestPokerRandomFeaturePayoutExcludesFee(t *testing.T) {
	for _, feature := range []string{PokerSuperTimesPay, PokerHotRoll} {
		cabinet := CabinetSuperTimesPay
		if feature == PokerHotRoll {
			cabinet = CabinetHotRoll
		}
		table, w, _ := pokerTestCabinet(t, VideoPokerConfig{Cabinet: cabinet})
		table.action("alice", "hands 3")
		table.action("alice", "denom 10")
		pokerDeal(t, table, w)
		p := table.players["alice"]
		p.multiplier = 8 // pin the rolled bonus
		p.cards = pokerHand("Ah Kh Qh Jh 10h")
		table.action("alice", "12345")
		table.action("alice", "draw")
		if w.paid != 3*4000*8*10 {
			t.Fatalf("%s multiplied the feature fee into the payout: %d", feature, w.paid)
		}
		for _, line := range p.lines {
			if line.Multiplier != 8 || line.Coins != 32000 {
				t.Fatal("the bonus was not shared across all lines")
			}
		}
	}
}
func TestPokerDisconnectedFailedSettlementRetriesWithoutRedraw(t *testing.T) {
	table, w, _ := pokerTestCabinet(t, VideoPokerConfig{Cabinet: CabinetClassic})
	pokerDeal(t, table, w)
	p := table.players["alice"]
	w.fail = true
	table.markDisconnected("alice")
	if !table.hasParticipant("alice") || !p.drawn || !p.active {
		t.Fatal("failed disconnected stake was dropped")
	}
	final := p.lines[0].Cards
	table.tick()
	for i, c := range final {
		if p.lines[0].Cards[i] != c {
			t.Fatal("retry redrew cards")
		}
	}
	w.fail = false
	table.tick()
	paid := w.paid
	table.tick()
	if !table.idle() || len(w.open) != 0 || w.paid != paid {
		t.Fatal("retry did not settle exactly once")
	}
}