allow the control interface to specify game type

This commit is contained in:
Fraser Graham
2014-01-15 22:16:06 -08:00
parent 9583de2ffa
commit 90b7731865
4 changed files with 20 additions and 11 deletions
+3 -3
View File
@@ -24,8 +24,8 @@ func startGame(w http.ResponseWriter, req *http.Request) {
requested_game_name := idg.Hash()
width, height := float32(conf.Width), float32(conf.Height)
obstacles := 0
tick := conf.Tick
maxPoints := conf.MaxPoints
mode := "deathmatch"
// here we determine if we are going to run with defaults or pick them off
// a posted json blob
@@ -50,14 +50,14 @@ func startGame(w http.ResponseWriter, req *http.Request) {
width = float32(cfg.Width)
height = float32(cfg.Height)
obstacles = cfg.Obstacles
tick = cfg.Tick
maxPoints = cfg.MaxPoints
mode = cfg.Mode
}
g := games.get(requested_game_name)
if g == nil {
log.Printf("Game '%s' non-existant; making it now", requested_game_name)
g = NewGame(requested_game_name, width, height, obstacles, tick, maxPoints)
g = NewGame(requested_game_name, width, height, obstacles, conf.Tick, maxPoints, mode)
go g.run()
games.add(g)
} else {