feat: produce on planets, unload on routes

This commit is contained in:
Ilia Denisov
2026-01-21 23:01:33 +02:00
parent 7e73601bce
commit 9825e05c0e
10 changed files with 319 additions and 60 deletions
+17 -7
View File
@@ -18,7 +18,7 @@ type UninhabitedPlanet struct {
Name string `json:"name"`
Resources float64 `json:"resources"` // R - Ресурсы
Capital float64 `json:"capital"` // CAP $ - Запасы промышленности
Material float64 `json:"material"` // MAT M - Запасы ресурсов / сырья
Material float64 `json:"material"` // MAT M - Запасы ресурсов / сырьё
}
type PlanetReport struct {
@@ -52,13 +52,23 @@ func PlanetProduction(industry, population float64) float64 {
// Производство промышленности
// TODO: test on real values
// [x] ind * 5 + ind / res = prod
// [x] ind = (res * prod) / (5 * res + 1)
// ind = 10 * 1000 / (5 * 10 + 1) = 10000 / 55 = 181.(81)
// int = 10 * 500 / 55 = 5000 / 55
func (p *Planet) IncreaseIndustry() {
prod := p.ProductionCapacity() / 5.
industryIncrement := math.Min(prod, p.Material)
p.Industry += industryIncrement
production := p.ProductionCapacity()
var ind float64
if p.Material > 0 {
ind = math.Min(production/5, p.Material)
p.Material -= ind
production -= ind * 5.
}
ind += (production * p.Resources) / (5.*p.Resources + 1.)
p.Industry += ind
if p.Industry > p.Population {
p.Capital += p.Industry - p.Population
p.Industry = p.Population
p.Capital += p.Population - p.Industry
}
}
@@ -77,11 +87,11 @@ func (p *Planet) UnpackCAPtoIND() {
// Производство материалов
// TODO: test on real values
func (p *Planet) IncreaseMaterial() {
p.Material += p.ProductionCapacity() * p.Industry
p.Material += p.ProductionCapacity() * p.Resources
}
// Автоматическое увеличение населения на каждом ходу
// TODO: test
// TODO: test - whether POP is busy on production or not?
func (p *Planet) IncreasePopulation() {
p.Population *= 1.08
if p.Population > p.Size {