rewrite of the stats system
This commit is contained in:
@@ -29,6 +29,7 @@ type Robot struct {
|
||||
Hit bool `json:"hit"`
|
||||
Probe *v.Point2d `json:"probe"`
|
||||
ProbeResult *v.Point2d `json:"probe_result"`
|
||||
gameStats *BotStats `json:-`
|
||||
}
|
||||
|
||||
// This is the subset of data we send to players about robots
|
||||
@@ -323,7 +324,7 @@ func (r *Robot) Tick(g *game) {
|
||||
}
|
||||
|
||||
if r.FireAt != nil {
|
||||
proj := r.fire(g.projectiles, g.turn)
|
||||
proj := r.fire(g)
|
||||
if proj != nil {
|
||||
g.projectiles[proj] = true
|
||||
}
|
||||
@@ -384,14 +385,15 @@ func (r *Robot) scan(g *game) {
|
||||
|
||||
}
|
||||
|
||||
func (r *Robot) fire(projectiles map[*Projectile]bool, turn int) *Projectile {
|
||||
func (r *Robot) fire(g *game) *Projectile {
|
||||
// Throttle the fire rate
|
||||
time_since_fired := (float32(turn) * (delta * 1000)) - (float32(r.LastFired) * (delta * 1000))
|
||||
time_since_fired := (float32(g.turn) * (delta * 1000)) - (float32(r.LastFired) * (delta * 1000))
|
||||
if time_since_fired < float32(r.Stats.FireRate) {
|
||||
return nil
|
||||
}
|
||||
|
||||
r.LastFired = turn
|
||||
r.LastFired = g.turn
|
||||
r.gameStats.Shots++
|
||||
|
||||
return &Projectile{
|
||||
Id: idg.Hash(),
|
||||
|
||||
Reference in New Issue
Block a user