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++ robots_remaining++
p.scan(g.players) p.scan(g.players)
p.nudge() p.nudge()
// XXX: change to pointer, check for pointer as (0, 0) is valid target
if p.Robot.FireAt != nil { if p.Robot.FireAt != nil {
proj := p.fire(g.projectiles) proj := p.fire(g.projectiles)
if proj != nil { 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) { func listGames(w http.ResponseWriter, req *http.Request) {
games.RLock() games.RLock()
defer games.RUnlock() defer games.RUnlock()
type gl struct { type gl struct {
Id string `json:"id"` Id string `json:"id"`
Players []string `json:"players"` Players []string `json:"players"`
} }
ids := make([]gl, 0) ids := make([]gl, 0)
for id, g := range games.m { for id, g := range games.m {
players := make([]string, 0) players := make([]string, 0)
for p, _ := range g.players { for p, _ := range g.players {
// XXX: change this to be the user-provided bot name? // XXX: change this to be the user-provided bot name?
players = append(players, p.Robot.Id) players = append(players, p.Robot.Id)
} }
ids = append(ids, gl{ ids = append(ids, gl{
Id: id, Id: id,
Players: players, Players: players,
}) })
} }
if err := json.NewEncoder(w).Encode(ids); err != nil { if err := json.NewEncoder(w).Encode(ids); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError) http.Error(w, err.Error(), http.StatusInternalServerError)