cmd: upgrade group

This commit is contained in:
Ilia Denisov
2026-01-04 19:22:06 +02:00
parent 6157c07a35
commit c6e1cb5cdf
17 changed files with 918 additions and 245 deletions
+24 -7
View File
@@ -25,10 +25,10 @@ type UninhabitedPlanet struct {
type PlanetReport struct {
UninhabitedPlanet
Industry float64 `json:"industry"` // I - Промышленность
Population float64 `json:"population"` // P - Население
Colonists float64 `json:"colonists"` // COL C - Количество колонистов
Production ProductionType `json:"production"` // TODO: internal/report format
Industry float64 `json:"industry"` // I - Промышленность
Population float64 `json:"population"` // P - Население
Colonists float64 `json:"colonists"` // COL C - Количество колонистов
Production Production `json:"production"` // TODO: internal/report format
// Параметр "L" - Свободный производственный потенциал
}
@@ -42,13 +42,30 @@ type PlanetReportForeign struct {
PlanetReport
}
// Свободный производственный потенциал (L)
// промышленность * 0.75 + население * 0.25
// TODO: за вычетом затрат, расходуемых в течение хода на модернизацию кораблей
// TODO: delete func
func (p Planet) ProductionCapacity() float64 {
return p.Industry*0.75 + p.Population*0.25
}
// Свободный производственный потенциал (L)
// промышленность * 0.75 + население * 0.25
// за вычетом затрат, расходуемых в течение хода на модернизацию кораблей
func PlanetProductionCapacity(g *Game, planetNumber uint) float64 {
p, err := g.PlanetByNumber(planetNumber)
if err != nil {
panic(err)
}
var busyResources float64
for sg := range g.ShipsInUpgrade(p.Number) {
busyResources += sg.StateUpgrade.Cost()
}
return PlanetProduction(p.Industry, p.Population) - busyResources
}
func PlanetProduction(industry, population float64) float64 {
return industry*0.75 + population*0.25
}
// Производство промышленности
// TODO: test on real values
func (p *Planet) IncreaseIndustry() {