bugfix for incorrect logic in game creation

This commit is contained in:
sm
2013-10-18 23:56:06 -07:00
parent c80acb478b
commit c074397c1f
3 changed files with 18 additions and 9 deletions
+6 -3
View File
@@ -17,13 +17,16 @@ func (h JsonHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
func startGame(w http.ResponseWriter, req *http.Request) {
log.Println("asked to create a game")
new_game_name := idg.Hash()
games.getOrCreate(new_game_name)
g, err := games.get("", true)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
game_json := struct {
Id string `json:"id"`
}{
Id: new_game_name,
Id: g.id,
}
if err := json.NewEncoder(w).Encode(game_json); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)