Ver código fonte

Include robot Id in the Stats structure that gets sent back to the client

master
Fraser Graham 3 anos atrás
pai
commit
37d0335f92
2 arquivos alterados com 6 adições e 3 exclusões
  1. +3
    -1
      protocol.go
  2. +3
    -2
      robot.go

+ 3
- 1
protocol.go Ver arquivo

@@ -312,7 +312,7 @@ encodingLoops:
convertedStats := map[string]Stats{}
for name, stats := range conf.Stats {
dstat := DeriveStats(stats)
convertedStats[name] = dstat
r := Robot{
Stats: dstat,
Id: c.Idg.Hash(),
@@ -327,6 +327,8 @@ encodingLoops:
log.Printf("%s: adding robot: %s", p.Id, r.Id)
r.reset(game)
p.Robots = append(p.Robots, &r)
dstat.Id = r.Id
convertedStats[name] = dstat
}

statsPayload := struct {

+ 3
- 2
robot.go Ver arquivo

@@ -33,8 +33,8 @@ type Robot struct {
Hit bool `json:"hit"`
Probe *v.Point2d `json:"probe"`
ProbeResult *Collision `json:"probe_result"`
gameStats *BotStats `json:"-"`
Delta float64 `json:"-"`
gameStats *BotStats
Delta float64 `json:"-"`
idg *idg.Generator
}

@@ -101,6 +101,7 @@ func (s AllRobotSorter) Less(i, j int) bool {

// Stats is the point allocation for a Robot.
type Stats struct {
Id string
Hp int `json:"hp"`
Speed float64 `json:"speed"`
Acceleration float64 `json:"acceleration"`

Carregando…
Cancelar
Salvar