Include robot Id in the Stats structure that gets sent back to the client
This commit is contained in:
parent
c6befdf2f9
commit
37d0335f92
|
@ -312,7 +312,7 @@ encodingLoops:
|
||||||
convertedStats := map[string]Stats{}
|
convertedStats := map[string]Stats{}
|
||||||
for name, stats := range conf.Stats {
|
for name, stats := range conf.Stats {
|
||||||
dstat := DeriveStats(stats)
|
dstat := DeriveStats(stats)
|
||||||
convertedStats[name] = dstat
|
|
||||||
r := Robot{
|
r := Robot{
|
||||||
Stats: dstat,
|
Stats: dstat,
|
||||||
Id: c.Idg.Hash(),
|
Id: c.Idg.Hash(),
|
||||||
|
@ -327,6 +327,8 @@ encodingLoops:
|
||||||
log.Printf("%s: adding robot: %s", p.Id, r.Id)
|
log.Printf("%s: adding robot: %s", p.Id, r.Id)
|
||||||
r.reset(game)
|
r.reset(game)
|
||||||
p.Robots = append(p.Robots, &r)
|
p.Robots = append(p.Robots, &r)
|
||||||
|
dstat.Id = r.Id
|
||||||
|
convertedStats[name] = dstat
|
||||||
}
|
}
|
||||||
|
|
||||||
statsPayload := struct {
|
statsPayload := struct {
|
||||||
|
|
5
robot.go
5
robot.go
|
@ -33,8 +33,8 @@ type Robot struct {
|
||||||
Hit bool `json:"hit"`
|
Hit bool `json:"hit"`
|
||||||
Probe *v.Point2d `json:"probe"`
|
Probe *v.Point2d `json:"probe"`
|
||||||
ProbeResult *Collision `json:"probe_result"`
|
ProbeResult *Collision `json:"probe_result"`
|
||||||
gameStats *BotStats `json:"-"`
|
gameStats *BotStats
|
||||||
Delta float64 `json:"-"`
|
Delta float64 `json:"-"`
|
||||||
idg *idg.Generator
|
idg *idg.Generator
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,6 +101,7 @@ func (s AllRobotSorter) Less(i, j int) bool {
|
||||||
|
|
||||||
// Stats is the point allocation for a Robot.
|
// Stats is the point allocation for a Robot.
|
||||||
type Stats struct {
|
type Stats struct {
|
||||||
|
Id string
|
||||||
Hp int `json:"hp"`
|
Hp int `json:"hp"`
|
||||||
Speed float64 `json:"speed"`
|
Speed float64 `json:"speed"`
|
||||||
Acceleration float64 `json:"acceleration"`
|
Acceleration float64 `json:"acceleration"`
|
||||||
|
|
Loading…
Reference in New Issue