Added ability to configure game at creation time
This commit is contained in:
+16
-7
@@ -98,14 +98,23 @@ func addPlayer(ws *websocket.Conn) {
|
||||
log.Println("problem parsing the requested game id")
|
||||
return
|
||||
}
|
||||
log.Printf("requested game id: %+v", gid)
|
||||
|
||||
force := *debug
|
||||
game, err := games.get(gid.Id, force)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("ERROR: game '%s' not found", gid.Id)
|
||||
websocket.JSON.Send(ws, NewFailure("game 404"))
|
||||
return
|
||||
game := games.get(gid.Id)
|
||||
log.Printf("found game: %p", game)
|
||||
if game == nil {
|
||||
log.Println("game was nil")
|
||||
force := *debug
|
||||
if force {
|
||||
log.Println("forcing game start")
|
||||
game = NewGame(gid.Id, float32(*width), float32(*height))
|
||||
go game.run()
|
||||
games.add(game)
|
||||
} else {
|
||||
log.Printf("ERROR: game '%s' not found", gid.Id)
|
||||
websocket.JSON.Send(ws, NewFailure("game 404"))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
player_id := idg.Hash()
|
||||
|
||||
Reference in New Issue
Block a user