diff --git a/main.go b/main.go index 1346637..8370130 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "flag" + "fmt" "log" "math/rand" "sync" @@ -43,6 +44,7 @@ func main() { *server, *port, gameName, + fmt.Sprintf("%s%d", *botname, i), *hp, *speed, *acceleration, diff --git a/robot.go b/robot.go index 9746bbf..9e12dae 100644 --- a/robot.go +++ b/robot.go @@ -19,12 +19,14 @@ type robot struct { ws *websocket.Conn game GameParam playerId string + name string } func NewRobot( server string, port int, gameName string, + botName string, hp, speed, acceleration, @@ -36,7 +38,8 @@ func NewRobot( return nil, errors.New(fmt.Sprintf("connection failure: %s", err)) } r := &robot{ - ws: ws, + ws: ws, + name: botName, } // XXX: update with missing fields @@ -84,7 +87,7 @@ func (r *robot) negociate(req StatsRequest, gameName string) (err error) { Name string `json:"name"` Useragent string `json:"useragent"` }{ - Name: *botname, + Name: r.name, Useragent: "gobot", Type: "robot", }) @@ -101,7 +104,7 @@ func (r *robot) negociate(req StatsRequest, gameName string) (err error) { conf := ClientConfig{ ID: gameName, Stats: map[string]StatsRequest{ - *botname: req, + r.name: req, }, }