commit cbafa3b818ecffc9fb9949d38fff67fc5a0d1f8d
parent 56e50f4f6f1566f9c949b2b936131243c144687d
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Mon, 18 Dec 2023 14:44:47 -0500
cleanup
Diffstat:
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/pkg/web/handlers/poker/poker.go b/pkg/web/handlers/poker/poker.go
@@ -546,6 +546,8 @@ const (
func (a PlayerAction) String() string {
switch a {
+ case NoAction:
+ return ""
case FoldAction:
return "fold"
case CallAction:
@@ -568,8 +570,8 @@ const (
)
type AutoAction struct {
- v PlayerAction
- evt PlayerEvent
+ action PlayerAction
+ evt PlayerEvent
}
// Return either or not the game ended because only 1 player left playing (or none)
@@ -746,9 +748,9 @@ RoundIsSettledLoop:
handleAutoActionReceived := func(evt PlayerEvent) int {
roomUserTopic := roomID.UserTopic(evt.Player)
autoAction := autoCache[evt.Player]
- if evt.Fold && autoAction.v == FoldAction ||
- evt.Call && autoAction.v == CallAction ||
- evt.Check && autoAction.v == CheckAction {
+ if evt.Fold && autoAction.action == FoldAction ||
+ evt.Call && autoAction.action == CallAction ||
+ evt.Check && autoAction.action == CheckAction {
delete(autoCache, evt.Player)
setAutoAction(g, roomUserTopic, "")
return continueGetPlayerEventLoop
@@ -756,7 +758,7 @@ RoundIsSettledLoop:
action := evt.getAction()
if action != NoAction {
- autoCache[evt.Player] = AutoAction{v: action, evt: evt}
+ autoCache[evt.Player] = AutoAction{action: action, evt: evt}
setAutoAction(g, roomUserTopic, "Will auto "+action.String())
}
return continueGetPlayerEventLoop
@@ -781,10 +783,10 @@ RoundIsSettledLoop:
}
applyAutoAction := func(autoAction AutoAction) (actionResult int) {
- if autoAction.v > NoAction {
+ if autoAction.action > NoAction {
time.Sleep(500 * time.Millisecond)
p.LastActionTS = time.Now()
- switch autoAction.v {
+ switch autoAction.action {
case NoAction:
case FoldAction:
actionResult = doFold()