Fix sending roll events

This commit is contained in:
Trevor Slocum 2023-11-17 11:37:04 -08:00
parent 9b8b1767eb
commit e8fb2fd4d2

View file

@ -814,6 +814,18 @@ COMMANDS:
continue
}
clientGame.eachClient(func(client *serverClient) {
ev := &bgammon.EventRolled{
Roll1: clientGame.Roll1,
Roll2: clientGame.Roll2,
}
ev.Player = string(cmd.client.name)
if clientGame.Turn == 0 && client.playerNumber == 2 {
ev.Roll1, ev.Roll2 = ev.Roll2, ev.Roll1
}
client.sendEvent(ev)
})
if clientGame.Turn == 0 && clientGame.Roll1 != 0 && clientGame.Roll2 != 0 {
if clientGame.Roll1 > clientGame.Roll2 {
clientGame.Turn = 1
@ -825,15 +837,6 @@ COMMANDS:
}
}
clientGame.eachClient(func(client *serverClient) {
ev := &bgammon.EventRolled{
Roll1: clientGame.Roll1,
Roll2: clientGame.Roll2,
}
ev.Player = string(cmd.client.name)
if client.playerNumber == 2 {
ev.Roll1, ev.Roll2 = ev.Roll2, ev.Roll1
}
client.sendEvent(ev)
if clientGame.Turn != 0 || !client.json {
clientGame.sendBoard(client)
}