From e391cd3a0bafccf71285390b901ddb3eb2697f79 Mon Sep 17 00:00:00 2001 From: Stephen McQuay Date: Mon, 19 Aug 2013 21:42:43 -0700 Subject: [PATCH] Changed to use user-provided stats. --- main.go | 15 +++++---------- player.go | 2 +- robot.go | 2 +- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/main.go b/main.go index da5e227..0d15053 100644 --- a/main.go +++ b/main.go @@ -1,11 +1,11 @@ package main import ( + "bitbucket.org/hackerbots/botserv/protocol" + v "bitbucket.org/hackerbots/vector" "code.google.com/p/go.net/websocket" "flag" "fmt" - "bitbucket.org/hackerbots/botserv/protocol" - v "bitbucket.org/hackerbots/vector" "log" "math/rand" "net/http" @@ -98,7 +98,7 @@ func addPlayer(ws *websocket.Conn) { log.Printf("%s invalid config", id) } } - log.Printf("%s eventually sent valid config", id) + log.Printf("%s eventually sent valid config: %+v", id, conf) start_pos := v.Point2d{ X: rand.Float64() * *width, @@ -106,16 +106,11 @@ func addPlayer(ws *websocket.Conn) { } p := &player{ Robot: robot{ - Stats: stats{ - Speed: *velocity, - Hp: 200, - WeaponRadius: 35, - ScannerRadius: 200, - }, + Stats: conf.Stats, Position: start_pos, MoveTo: start_pos, Id: id, - Health: 200, + Health: conf.Stats.Hp, Scanners: make([]scanner, 0)}, send: make(chan *boardstate), ws: ws, diff --git a/player.go b/player.go index 11ee71d..450bae0 100644 --- a/player.go +++ b/player.go @@ -1,8 +1,8 @@ package main import ( - "code.google.com/p/go.net/websocket" v "bitbucket.org/hackerbots/vector" + "code.google.com/p/go.net/websocket" "log" "math/rand" ) diff --git a/robot.go b/robot.go index f9ccc70..1f1a691 100644 --- a/robot.go +++ b/robot.go @@ -11,8 +11,8 @@ type weapon struct { } type stats struct { - Speed float64 `json:"speed"` Hp int `json:"hp"` + Speed float64 `json:"speed"` WeaponRadius int `json:"weapon_radius"` ScannerRadius int `json:"scanner_radius"` }