pared down logging in favor of unittests

This commit is contained in:
Stephen McQuay 2013-08-26 23:02:41 -07:00
parent 63f6d1a2e0
commit 1b29096479
5 changed files with 0 additions and 18 deletions

View File

@ -67,13 +67,11 @@ func (g *game) run() {
for { for {
select { select {
case p := <-g.register: case p := <-g.register:
log.Printf("adding player: %+v", p.Robot.Id)
g.players[p] = true g.players[p] = true
case p := <-g.unregister: case p := <-g.unregister:
delete(g.players, p) delete(g.players, p)
close(p.send) close(p.send)
case s := <-g.sregister: case s := <-g.sregister:
log.Printf("registering a spectator: %+v", s)
g.spectators[s] = true g.spectators[s] = true
case s := <-g.sunregister: case s := <-g.sunregister:
delete(g.spectators, s) delete(g.spectators, s)

View File

@ -22,7 +22,6 @@ type instruction struct {
func (p *player) sender() { func (p *player) sender() {
for things := range p.send { for things := range p.send {
// log.Printf("%v\n", things)
err := websocket.JSON.Send(p.ws, *things) err := websocket.JSON.Send(p.ws, *things)
if err != nil { if err != nil {
break 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{ proj := &projectile{
Id: p.Robot.Id, Id: p.Robot.Id,
Position: p.Robot.Position, Position: p.Robot.Position,

View File

@ -84,22 +84,17 @@ func NewFailure(reason string) *Failure {
func Negociate(ws *websocket.Conn, id string, width, height float64) (*Config, error) { func Negociate(ws *websocket.Conn, id string, width, height float64) (*Config, error) {
var err error var err error
log.Printf("sending robot id: %s", id)
err = websocket.JSON.Send(ws, NewIdRequest(id)) err = websocket.JSON.Send(ws, NewIdRequest(id))
if err != nil { if err != nil {
log.Printf("%s: problem sending initial identification", id)
return nil, errors.New("generic servr error") return nil, errors.New("generic servr error")
} }
var clientid ClientID var clientid ClientID
err = websocket.JSON.Receive(ws, &clientid) err = websocket.JSON.Receive(ws, &clientid)
if err != nil { if err != nil {
log.Printf("%s: problem parsing clientID", id)
return nil, errors.New("could not parse id") return nil, errors.New("could not parse id")
} }
if v, msg := clientid.Valid(); !v { if v, msg := clientid.Valid(); !v {
log.Printf("%s: invalid clientid: %+v", id, clientid)
websocket.JSON.Send( websocket.JSON.Send(
ws, ws,
NewFailure(msg), NewFailure(msg),
@ -110,7 +105,6 @@ func Negociate(ws *websocket.Conn, id string, width, height float64) (*Config, e
gameParam := NewGameParam(width, height) gameParam := NewGameParam(width, height)
err = websocket.JSON.Send(ws, gameParam) err = websocket.JSON.Send(ws, gameParam)
if err != nil { if err != nil {
log.Println("%s: problem sending game info: %+v", id, gameParam)
websocket.JSON.Send(ws, NewFailure("generic server error")) websocket.JSON.Send(ws, NewFailure("generic server error"))
return nil, err return nil, err
} }
@ -128,10 +122,8 @@ func Negociate(ws *websocket.Conn, id string, width, height float64) (*Config, e
break break
} else { } else {
_ = websocket.JSON.Send(ws, NewHandshake(id, false)) _ = 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 return &conf, nil
case "spectator": case "spectator":
return nil, nil return nil, nil

View File

@ -2,7 +2,6 @@ package main
import ( import (
v "bitbucket.org/hackerbots/vector" v "bitbucket.org/hackerbots/vector"
"log"
) )
type weapon struct { type weapon struct {
@ -19,7 +18,6 @@ type stats struct {
func (s stats) valid() bool { func (s stats) valid() bool {
total := int(s.Speed) + s.Hp + s.WeaponRadius + s.ScannerRadius total := int(s.Speed) + s.Hp + s.WeaponRadius + s.ScannerRadius
log.Printf("total: %d", total)
if total > 500 { if total > 500 {
return false return false
} }
@ -101,9 +99,7 @@ func (p *projectile) nudge() {
// TODO map damage Max to Min based on distance from explosion // TODO map damage Max to Min based on distance from explosion
if player.Robot.Health > 0 { if player.Robot.Health > 0 {
player.Robot.Health -= p.Damage player.Robot.Health -= p.Damage
// log.Printf("Robot %+v is injured", player.Robot)
if player.Robot.Health <= 0 { if player.Robot.Health <= 0 {
// log.Printf("Robot %+v is dead", player.Robot)
} }
} }
} }

View File

@ -11,7 +11,6 @@ type Spectator struct {
func (s *Spectator) sender() { func (s *Spectator) sender() {
for things := range s.send { for things := range s.send {
// log.Printf("%v\n", things)
err := websocket.JSON.Send(s.ws, *things) err := websocket.JSON.Send(s.ws, *things)
if err != nil { if err != nil {
break break