This commit is contained in:
Stephen McQuay 2013-09-07 19:12:46 -07:00
parent f9b646e50c
commit bf853880ca
2 changed files with 12 additions and 13 deletions

View File

@ -88,7 +88,6 @@ func (g *game) run() {
robots_remaining++
p.scan(g.players)
p.nudge()
// XXX: change to pointer, check for pointer as (0, 0) is valid target
if p.Robot.FireAt != nil {
proj := p.fire(g.projectiles)
if proj != nil {

24
http.go
View File

@ -33,21 +33,21 @@ func startGame(w http.ResponseWriter, req *http.Request) {
func listGames(w http.ResponseWriter, req *http.Request) {
games.RLock()
defer games.RUnlock()
type gl struct {
Id string `json:"id"`
Players []string `json:"players"`
}
type gl struct {
Id string `json:"id"`
Players []string `json:"players"`
}
ids := make([]gl, 0)
for id, g := range games.m {
players := make([]string, 0)
for p, _ := range g.players {
// XXX: change this to be the user-provided bot name?
players = append(players, p.Robot.Id)
}
players := make([]string, 0)
for p, _ := range g.players {
// XXX: change this to be the user-provided bot name?
players = append(players, p.Robot.Id)
}
ids = append(ids, gl{
Id: id,
Players: players,
})
Id: id,
Players: players,
})
}
if err := json.NewEncoder(w).Encode(ids); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)