better ping handling

This commit is contained in:
Branden J Brown 2024-02-02 21:07:30 -06:00
parent 5df96a5c33
commit d2e9d6cf01
1 changed files with 4 additions and 4 deletions

View File

@ -41,8 +41,6 @@ func applyAction(g *game.Match, a action) error {
return g.Apply(a.Player, 6)
case "7":
return g.Apply(a.Player, 7)
case "ping":
return errJustAPing
default:
return errWeirdAction
}
@ -101,7 +99,7 @@ func gameActor(ctx context.Context, g *game.Match, dealer, chall person, join <-
broadcast(ctx, g, dealer, chall, obs)
g.NextGame()
broadcast(ctx, g, dealer, chall, obs)
case game.ErrWrongTurn, errJustAPing: // do nothing
case game.ErrWrongTurn: // do nothing
case errWeirdAction:
slog.WarnContext(ctx, "nonsense action", "from", a.Player, "action", a.Action)
default:
@ -131,6 +129,9 @@ func playerActor(ctx context.Context, p person, actions chan<- action) {
}
return
}
if a.Action == "ping" {
continue
}
select {
case <-ctx.Done():
return
@ -174,6 +175,5 @@ func gameOver(ctx context.Context, dealer, chall person, obs []observer) {
var (
errWeirdAction = errors.New("unknown action")
errJustAPing = errors.New("just a ping")
errMatchExpired = errors.New("there is a time limit on matches please")
)