From 1b2909647999d1a8e032ebfd083973d096854879 Mon Sep 17 00:00:00 2001 From: Stephen McQuay Date: Mon, 26 Aug 2013 23:02:41 -0700 Subject: [PATCH] pared down logging in favor of unittests --- game.go | 2 -- player.go | 3 --- protocol.go | 8 -------- robot.go | 4 ---- spectator.go | 1 - 5 files changed, 18 deletions(-) diff --git a/game.go b/game.go index 6a6101f..8ba9a81 100644 --- a/game.go +++ b/game.go @@ -67,13 +67,11 @@ func (g *game) run() { for { select { case p := <-g.register: - log.Printf("adding player: %+v", p.Robot.Id) g.players[p] = true case p := <-g.unregister: delete(g.players, p) close(p.send) case s := <-g.sregister: - log.Printf("registering a spectator: %+v", s) g.spectators[s] = true case s := <-g.sunregister: delete(g.spectators, s) diff --git a/player.go b/player.go index 665aa28..fa6d2b9 100644 --- a/player.go +++ b/player.go @@ -22,7 +22,6 @@ type instruction struct { func (p *player) sender() { for things := range p.send { - // log.Printf("%v\n", things) err := websocket.JSON.Send(p.ws, *things) if err != nil { break @@ -87,8 +86,6 @@ func (p *player) fire() { } } - // log.Printf("%v Fired at %v %v", p.Robot.Id, p.Robot.FireAt.X, p.Robot.FireAt.Y) - proj := &projectile{ Id: p.Robot.Id, Position: p.Robot.Position, diff --git a/protocol.go b/protocol.go index 62d8166..e4eb53e 100644 --- a/protocol.go +++ b/protocol.go @@ -84,22 +84,17 @@ func NewFailure(reason string) *Failure { func Negociate(ws *websocket.Conn, id string, width, height float64) (*Config, error) { var err error - log.Printf("sending robot id: %s", id) - err = websocket.JSON.Send(ws, NewIdRequest(id)) if err != nil { - log.Printf("%s: problem sending initial identification", id) return nil, errors.New("generic servr error") } var clientid ClientID err = websocket.JSON.Receive(ws, &clientid) if err != nil { - log.Printf("%s: problem parsing clientID", id) return nil, errors.New("could not parse id") } if v, msg := clientid.Valid(); !v { - log.Printf("%s: invalid clientid: %+v", id, clientid) websocket.JSON.Send( ws, NewFailure(msg), @@ -110,7 +105,6 @@ func Negociate(ws *websocket.Conn, id string, width, height float64) (*Config, e gameParam := NewGameParam(width, height) err = websocket.JSON.Send(ws, gameParam) if err != nil { - log.Println("%s: problem sending game info: %+v", id, gameParam) websocket.JSON.Send(ws, NewFailure("generic server error")) return nil, err } @@ -128,10 +122,8 @@ func Negociate(ws *websocket.Conn, id string, width, height float64) (*Config, e break } else { _ = websocket.JSON.Send(ws, NewHandshake(id, false)) - log.Printf("%s invalid config", id) } } - log.Printf("%s eventually sent valid config: %+v", id, conf) return &conf, nil case "spectator": return nil, nil diff --git a/robot.go b/robot.go index 1f1a691..1b806af 100644 --- a/robot.go +++ b/robot.go @@ -2,7 +2,6 @@ package main import ( v "bitbucket.org/hackerbots/vector" - "log" ) type weapon struct { @@ -19,7 +18,6 @@ type stats struct { func (s stats) valid() bool { total := int(s.Speed) + s.Hp + s.WeaponRadius + s.ScannerRadius - log.Printf("total: %d", total) if total > 500 { return false } @@ -101,9 +99,7 @@ func (p *projectile) nudge() { // TODO map damage Max to Min based on distance from explosion if player.Robot.Health > 0 { player.Robot.Health -= p.Damage - // log.Printf("Robot %+v is injured", player.Robot) if player.Robot.Health <= 0 { - // log.Printf("Robot %+v is dead", player.Robot) } } } diff --git a/spectator.go b/spectator.go index 27aae5e..055a4b1 100644 --- a/spectator.go +++ b/spectator.go @@ -11,7 +11,6 @@ type Spectator struct { func (s *Spectator) sender() { for things := range s.send { - // log.Printf("%v\n", things) err := websocket.JSON.Send(s.ws, *things) if err != nil { break