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 {
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)

View File

@ -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,

View File

@ -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

View File

@ -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)
}
}
}

View File

@ -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