Added ability to configure game at creation time

This commit is contained in:
sm
2013-11-07 22:11:54 -08:00
parent 164c37e7d6
commit caea45741f
3 changed files with 61 additions and 33 deletions
+16 -7
View File
@@ -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()