Changed to use user-provided stats.
This commit is contained in:
parent
7f75104f3a
commit
e391cd3a0b
15
main.go
15
main.go
@ -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,
|
||||||
|
@ -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"
|
||||||
)
|
)
|
||||||
|
2
robot.go
2
robot.go
@ -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"`
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user