test dw distances
This commit is contained in:
@@ -37,18 +37,18 @@ func Generate(cfg ...func(*MapSetting)) (Map, error) {
|
||||
|
||||
// 3. Place players' Home Worlds
|
||||
for player := 0; player < int(ms.Players); player++ {
|
||||
coord, err := m.NewCoordinate(float64(ms.HWMinDistance))
|
||||
hwCoord, err := m.NewCoordinate(float64(ms.HWMinDistance))
|
||||
if err != nil {
|
||||
return Map{}, fmt.Errorf("%s: hw new_coordinate: %s", ms, err)
|
||||
}
|
||||
planet := NewPlanet(coord, float64(ms.HWSize), float64(ms.HWResources))
|
||||
m.HomePlanets[player] = PlanetarySystem{HW: planet, DW: make([]Planet, ms.DWCount)}
|
||||
hwPlanet := NewPlanet(hwCoord, float64(ms.HWSize), float64(ms.HWResources))
|
||||
m.HomePlanets[player] = PlanetarySystem{HW: hwPlanet, DW: make([]Planet, ms.DWCount)}
|
||||
for dw := 0; dw < int(ms.DWCount); dw++ {
|
||||
p := rand.Float64()*(float64(ms.DWMaxDistance)-float64(ms.DWMinDistance)) + float64(ms.DWMinDistance)
|
||||
phi := rand.Float64() * 360
|
||||
x := p * math.Cos(phi)
|
||||
y := p * math.Sin(phi)
|
||||
dwPlanet := NewPlanet(Coordinate{x, y}, float64(ms.DWSize), float64(ms.DWResources))
|
||||
dwPlanet := NewPlanet(Coordinate{hwCoord.X + x, hwCoord.Y + y}, float64(ms.DWSize), float64(ms.DWResources))
|
||||
m.HomePlanets[player].DW[dw] = dwPlanet
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user