weapon stats are now set via robot

This commit is contained in:
Fraser Graham 2013-11-06 21:07:31 -08:00
parent dfb3dba4f4
commit 855b8518b8
2 changed files with 15 additions and 3 deletions

View File

@ -218,9 +218,9 @@ func (p *player) fire(projectiles map[*Projectile]bool, turn int) *Projectile {
Id: idg.Hash(),
Position: p.Robot.Position,
MoveTo: *p.Robot.FireAt,
Damage: 10,
Damage: p.Robot.Stats.WeaponDamage,
Radius: p.Robot.Stats.WeaponRadius,
Speed: float32(p.Robot.Stats.Speed * 3),
Speed: p.Robot.Stats.WeaponSpeed,
Owner: p,
}
}

View File

@ -64,6 +64,8 @@ type Stats struct {
ScannerRadius int `json:"-"`
TurnSpeed int `json:"-"`
FireRate int `json:"-"`
WeaponDamage int `json:"-"`
WeaponSpeed float32 `json:"-"`
}
// We request stats using an integer between 1 and 100, the
@ -76,6 +78,8 @@ type StatsRequest struct {
ScannerRadius int `json:"scanner_radius"`
TurnSpeed int `json:"turn_speed"`
FireRate int `json:"fire_rate"`
WeaponDamage int `json:"weapon_damage"`
WeaponSpeed int `json:"weapon_speed"`
}
func DeriveStats(request StatsRequest) Stats {
@ -110,6 +114,14 @@ func DeriveStats(request StatsRequest) Stats {
var fire_rate_max float32 = 2000.0
s.FireRate = int(fire_rate_max+300.0) - int(((float32(request.FireRate)/100.0)*(fire_rate_max-fire_rate_min))+fire_rate_min)
var weapon_damage_min float32 = 0.0
var weapon_damage_max float32 = 20.0
s.WeaponDamage = int(((float32(request.WeaponDamage) / 100.0) * (weapon_damage_max - weapon_damage_min)) + weapon_damage_min)
var weapon_speed_min float32 = 80.0
var weapon_speed_max float32 = 600.0
s.WeaponSpeed = float32(((float32(request.WeaponSpeed) / 100.0) * (weapon_speed_max - weapon_speed_min)) + weapon_speed_min)
return s
}
@ -118,7 +130,7 @@ func (s StatsRequest) Valid() bool {
s.ScannerRadius + s.Acceleration + s.TurnSpeed + s.FireRate)
// allowing for 50 pts in every category
if total > 400 {
if total > 500 {
return false
}
return true