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

View File

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

View File

@ -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"`
}