Fix rematch command
This commit is contained in:
parent
c3db42daee
commit
2493c76bdf
2 changed files with 41 additions and 21 deletions
|
@ -173,17 +173,23 @@ func (g *serverGame) addClient(client *serverClient) (bool, string) {
|
|||
return
|
||||
}
|
||||
|
||||
ev := &bgammon.EventJoined{
|
||||
GameID: g.id,
|
||||
PlayerNumber: playerNumber,
|
||||
{
|
||||
ev := &bgammon.EventJoined{
|
||||
GameID: g.id,
|
||||
PlayerNumber: 1,
|
||||
}
|
||||
ev.Player = string(client.name)
|
||||
client.sendEvent(ev)
|
||||
g.sendBoard(client)
|
||||
}
|
||||
ev.Player = string(client.name)
|
||||
|
||||
client.sendEvent(ev)
|
||||
g.sendBoard(client)
|
||||
|
||||
opponent := g.opponent(client)
|
||||
if opponent != nil {
|
||||
ev := &bgammon.EventJoined{
|
||||
GameID: g.id,
|
||||
PlayerNumber: 2,
|
||||
}
|
||||
ev.Player = string(client.name)
|
||||
opponent.sendEvent(ev)
|
||||
g.sendBoard(opponent)
|
||||
}
|
||||
|
|
|
@ -1047,23 +1047,37 @@ COMMANDS:
|
|||
|
||||
s.gamesLock.Unlock()
|
||||
|
||||
ev1 := &bgammon.EventJoined{
|
||||
GameID: newGame.id,
|
||||
PlayerNumber: 1,
|
||||
{
|
||||
ev1 := &bgammon.EventJoined{
|
||||
GameID: newGame.id,
|
||||
PlayerNumber: 1,
|
||||
}
|
||||
ev1.Player = newGame.Player1.Name
|
||||
ev2 := &bgammon.EventJoined{
|
||||
GameID: newGame.id,
|
||||
PlayerNumber: 2,
|
||||
}
|
||||
ev2.Player = newGame.Player2.Name
|
||||
newGame.client1.sendEvent(ev1)
|
||||
newGame.client1.sendEvent(ev2)
|
||||
newGame.sendBoard(newGame.client1)
|
||||
}
|
||||
ev1.Player = newGame.Player1.Name
|
||||
|
||||
ev2 := &bgammon.EventJoined{
|
||||
GameID: newGame.id,
|
||||
PlayerNumber: 1,
|
||||
{
|
||||
ev1 := &bgammon.EventJoined{
|
||||
GameID: newGame.id,
|
||||
PlayerNumber: 1,
|
||||
}
|
||||
ev1.Player = newGame.Player2.Name
|
||||
ev2 := &bgammon.EventJoined{
|
||||
GameID: newGame.id,
|
||||
PlayerNumber: 2,
|
||||
}
|
||||
ev2.Player = newGame.Player1.Name
|
||||
newGame.client2.sendEvent(ev1)
|
||||
newGame.client2.sendEvent(ev2)
|
||||
newGame.sendBoard(newGame.client2)
|
||||
}
|
||||
ev2.Player = newGame.Player2.Name
|
||||
|
||||
newGame.eachClient(func(client *serverClient) {
|
||||
client.sendEvent(ev1)
|
||||
client.sendEvent(ev2)
|
||||
newGame.sendBoard(client)
|
||||
})
|
||||
} else {
|
||||
clientGame.rematch = cmd.client.playerNumber
|
||||
|
||||
|
|
Loading…
Reference in a new issue