Changed to use user-provided stats.

This commit is contained in:
Stephen McQuay 2013-08-19 21:42:43 -07:00
parent 7f75104f3a
commit e391cd3a0b
3 changed files with 7 additions and 12 deletions

15
main.go
View File

@ -1,11 +1,11 @@
package main package main
import ( import (
"bitbucket.org/hackerbots/botserv/protocol"
v "bitbucket.org/hackerbots/vector"
"code.google.com/p/go.net/websocket" "code.google.com/p/go.net/websocket"
"flag" "flag"
"fmt" "fmt"
"bitbucket.org/hackerbots/botserv/protocol"
v "bitbucket.org/hackerbots/vector"
"log" "log"
"math/rand" "math/rand"
"net/http" "net/http"
@ -98,7 +98,7 @@ func addPlayer(ws *websocket.Conn) {
log.Printf("%s invalid config", id) 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{ start_pos := v.Point2d{
X: rand.Float64() * *width, X: rand.Float64() * *width,
@ -106,16 +106,11 @@ func addPlayer(ws *websocket.Conn) {
} }
p := &player{ p := &player{
Robot: robot{ Robot: robot{
Stats: stats{ Stats: conf.Stats,
Speed: *velocity,
Hp: 200,
WeaponRadius: 35,
ScannerRadius: 200,
},
Position: start_pos, Position: start_pos,
MoveTo: start_pos, MoveTo: start_pos,
Id: id, Id: id,
Health: 200, Health: conf.Stats.Hp,
Scanners: make([]scanner, 0)}, Scanners: make([]scanner, 0)},
send: make(chan *boardstate), send: make(chan *boardstate),
ws: ws, ws: ws,

View File

@ -1,8 +1,8 @@
package main package main
import ( import (
"code.google.com/p/go.net/websocket"
v "bitbucket.org/hackerbots/vector" v "bitbucket.org/hackerbots/vector"
"code.google.com/p/go.net/websocket"
"log" "log"
"math/rand" "math/rand"
) )

View File

@ -11,8 +11,8 @@ type weapon struct {
} }
type stats struct { type stats struct {
Speed float64 `json:"speed"`
Hp int `json:"hp"` Hp int `json:"hp"`
Speed float64 `json:"speed"`
WeaponRadius int `json:"weapon_radius"` WeaponRadius int `json:"weapon_radius"`
ScannerRadius int `json:"scanner_radius"` ScannerRadius int `json:"scanner_radius"`
} }