complete generator test

This commit is contained in:
Ilia Denisov
2025-09-24 15:35:33 +03:00
parent ab822a1abf
commit 99035fd95d
4 changed files with 127 additions and 46 deletions
+23 -9
View File
@@ -20,10 +20,23 @@ type Coordinate struct {
X, Y float64
}
type PlanetClass int
const (
PlanetClassHW PlanetClass = iota
PlanetClassDW
PlanetClassGiant
PlanetClassBig
PlanetClassNormal
PlanetClassRich
PlanetClassAsterioid
)
type Planet struct {
Position Coordinate
Size float64
Resources float64 // Сырьё
PlanetClass PlanetClass
Position Coordinate
Size float64
Resources float64 // Сырьё
}
type PlanetarySystem struct {
@@ -44,13 +57,13 @@ func NewMap(width, height, players uint32) (*Map, error) {
}, nil
}
func (m *Map) CreatePlanets(num int, deadZoneRadius float64, size, resources func() float64) error {
func (m *Map) CreatePlanets(pc PlanetClass, num int, deadZoneRadius float64, size, resources func() float64) error {
for range num {
coord, err := m.NewCoordinate(deadZoneRadius)
if err != nil {
return err
}
planet := NewPlanet(coord, size(), resources())
planet := NewPlanet(pc, coord, size(), resources())
m.AddPlanet(planet)
}
return nil
@@ -80,11 +93,12 @@ func (m Map) ShortDistance(from, to Coordinate) float64 {
return math.Sqrt(math.Pow(dx, 2) + math.Pow(dy, 2))
}
func NewPlanet(c Coordinate, size, resources float64) Planet {
func NewPlanet(pc PlanetClass, c Coordinate, size, resources float64) Planet {
return Planet{
Position: c,
Size: size,
Resources: resources,
PlanetClass: pc,
Position: c,
Size: size,
Resources: resources,
}
}