File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ func (g *Game) onPlayerJoined(cgPlayer *cg.Player) {
6969 cg : cgPlayer ,
7070 username : cgPlayer .Username ,
7171 game : g ,
72+ finished : true ,
7273 }
7374
7475 g .hovercrafts [cgPlayer .Id ] = Hovercraft {}
@@ -180,7 +181,7 @@ func (g *Game) handleEvent(player *cg.Player, event cg.Event) {
180181
181182func (g * Game ) handleReady (playerId string ) {
182183 player := g .players [playerId ]
183- if g . running {
184+ if ! player . finished {
184185 player .cg .Send (playerId , cg .ErrorEvent , cg.ErrorEventData {
185186 Message : "the game has already begun" ,
186187 })
@@ -233,6 +234,7 @@ func (g *Game) start() {
233234 x := 0.0
234235 i := 0
235236 for _ , player := range g .players {
237+ player .ready = false
236238 player .vel = Vec {}
237239 player .acc = Vec {}
238240 player .angle = 0
@@ -277,9 +279,6 @@ func (g *Game) start() {
277279}
278280
279281func (g * Game ) finish () {
280- for _ , player := range g .players {
281- player .ready = false
282- }
283282 g .running = false
284283}
285284
You can’t perform that action at this time.
0 commit comments