better ping handling
This commit is contained in:
parent
5df96a5c33
commit
d2e9d6cf01
8
game.go
8
game.go
@ -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")
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user