From f939d053a8198e3a40bc79563ef6a7e930e69c67 Mon Sep 17 00:00:00 2001 From: Trevor Slocum Date: Mon, 11 Dec 2023 10:52:48 -0800 Subject: [PATCH] Fix rerolling in acey-deucey games --- pkg/server/server.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pkg/server/server.go b/pkg/server/server.go index f1f91a9..412d071 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -943,12 +943,9 @@ COMMANDS: client.sendEvent(ev) }) + var skipBoard bool if clientGame.Turn == 0 && clientGame.Roll1 != 0 && clientGame.Roll2 != 0 { reroll := func() { - clientGame.eachClient(func(client *serverClient) { - clientGame.sendBoard(client) - }) - clientGame.Roll1 = 0 clientGame.Roll2 = 0 if !clientGame.roll(clientGame.Turn) { @@ -964,8 +961,10 @@ COMMANDS: ev.Player = string(clientGame.Player2.Name) } clientGame.eachClient(func(client *serverClient) { + clientGame.sendBoard(client) client.sendEvent(ev) }) + skipBoard = true } if clientGame.Roll1 > clientGame.Roll2 { @@ -983,11 +982,13 @@ COMMANDS: clientGame.Roll2 = 0 } } - clientGame.eachClient(func(client *serverClient) { - if clientGame.Turn != 0 || !client.json { - clientGame.sendBoard(client) - } - }) + if !skipBoard { + clientGame.eachClient(func(client *serverClient) { + if clientGame.Turn != 0 || !client.json { + clientGame.sendBoard(client) + } + }) + } case bgammon.CommandMove, "m", "mv": if clientGame == nil { cmd.client.sendEvent(&bgammon.EventFailedMove{