aboutsummaryrefslogtreecommitdiff
path: root/internal/casino/video_poker.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/casino/video_poker.go')
-rw-r--r--internal/casino/video_poker.go22
1 files changed, 15 insertions, 7 deletions
diff --git a/internal/casino/video_poker.go b/internal/casino/video_poker.go
index 7e79b58..d2578b8 100644
--- a/internal/casino/video_poker.go
+++ b/internal/casino/video_poker.go
@@ -63,6 +63,15 @@ type pokerPlayer struct {
result, bankKey string
}
+// clearResult clears the previous hand's presentation when preparing a new
+// wager. Loaded coins and the cabinet's earned multiplier banks are unchanged.
+func (p *pokerPlayer) clearResult() {
+ p.lines, p.remaining, p.current, p.next = nil, nil, nil, nil
+ p.result, p.payout, p.drawn = "", 0, false
+ p.held = [5]bool{}
+ p.multiplier, p.dice = 1, [2]int{}
+}
+
// cost is the full currency price of dealing the loaded wager.
func (p *pokerPlayer) cost() int {
coins := p.loaded
@@ -378,8 +387,7 @@ func (t *videoPokerTable) action(name, action string) []Event {
return []Event{t.private(name, "Nothing to take back.")}
}
p.loaded = 0
- p.lines, p.remaining, p.result, p.current, p.next = nil, nil, "", nil, nil
- p.multiplier, p.dice = 1, [2]int{}
+ p.clearResult()
return t.statusLocked(name, true)
case "coins":
if len(fields) > 2 {
@@ -403,8 +411,7 @@ func (t *videoPokerTable) action(name, action string) []Event {
n = min(5, p.loaded+add)
}
p.loaded, p.lastBet = n, n
- p.lines, p.remaining, p.result, p.current, p.next = nil, nil, "", nil, nil
- p.multiplier, p.dice = 1, [2]int{}
+ p.clearResult()
return t.statusLocked(name, len(fields) > 1)
case "denom", "denomination":
if len(fields) != 2 {
@@ -415,7 +422,7 @@ func (t *videoPokerTable) action(name, action string) []Event {
break
}
p.denomination = n
- p.next, p.current, p.lines, p.remaining, p.result = nil, nil, nil, nil, ""
+ p.clearResult()
return t.statusLocked(name, true)
case "hands":
if len(fields) != 2 {
@@ -428,7 +435,7 @@ func (t *videoPokerTable) action(name, action string) []Event {
for _, allowed := range CabinetHandCounts(t.settings.Cabinet, p.variant) {
if n == allowed {
p.hands = n
- p.next, p.current, p.lines, p.remaining, p.result = nil, nil, nil, nil, ""
+ p.clearResult()
return t.statusLocked(name, true)
}
}
@@ -445,13 +452,14 @@ func (t *videoPokerTable) action(name, action string) []Event {
return []Event{t.private(name, "That game is not available on this cabinet. Games: "+t.settings.GameChoices())}
}
p.config, p.variant, p.hands = cfg, variant, CabinetHandCounts(cfg.Cabinet, variant)[0]
- p.next, p.current, p.lines, p.remaining, p.result = nil, nil, nil, nil, ""
+ p.clearResult()
return t.statusLocked(name, true)
case "feature":
if len(fields) != 2 || cabinetFeature(t.settings.Cabinet) == "" || fields[1] != "on" && fields[1] != "off" {
break
}
p.featureOn = fields[1] == "on"
+ p.clearResult()
return t.statusLocked(name, false)
}
return []Event{t.private(name, "Use bet [1-4|max], unbet, deal, game <name>, denom 1|10|50, hands <count>, paytable, or feature on|off on a bonus cabinet.")}