tests: produce on planets, unload on routes

This commit is contained in:
Ilia Denisov
2026-01-23 00:28:23 +02:00
parent 9825e05c0e
commit 812e0d4afd
15 changed files with 522 additions and 103 deletions
+22 -25
View File
@@ -56,7 +56,7 @@ func PlanetProduction(industry, population float64) float64 {
// [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() {
func (p *Planet) ProduceIndustry() {
production := p.ProductionCapacity()
var ind float64
if p.Material > 0 {
@@ -72,27 +72,13 @@ func (p *Planet) IncreaseIndustry() {
}
}
func (p *Planet) UnpackCAPtoIND() {
if p.Capital == 0 {
return
}
cap := p.Population - p.Industry
if cap > p.Capital {
cap = p.Capital
}
p.Capital -= cap
p.Industry += cap
}
// Производство материалов
// TODO: test on real values
func (p *Planet) IncreaseMaterial() {
func (p *Planet) ProduceMaterial() {
p.Material += p.ProductionCapacity() * p.Resources
}
// Автоматическое увеличение населения на каждом ходу
// TODO: test - whether POP is busy on production or not?
func (p *Planet) IncreasePopulation() {
func (p *Planet) ProducePopulation() {
p.Population *= 1.08
if p.Population > p.Size {
p.Colonists += (p.Population - p.Size) / 8.
@@ -100,17 +86,28 @@ func (p *Planet) IncreasePopulation() {
}
}
func (p *Planet) UnpackCOLtoPOP() {
if p.Colonists < 1 {
func (p *Planet) UnpackCapital() {
if p.Capital == 0 {
return
}
maxCOL := uint((p.Size - p.Population) / 8.)
if float64(maxCOL) > p.Colonists {
maxCOL = uint(p.Colonists)
deficit := p.Population - p.Industry
if deficit > p.Capital {
deficit = p.Capital
}
maxCOL = uint(float64(maxCOL) - math.Mod(float64(maxCOL), 8.))
p.Colonists -= float64(maxCOL)
p.Population += float64(maxCOL) * 8
p.Capital -= deficit
p.Industry += deficit
}
func (p *Planet) UnpackColonists() {
if p.Colonists == 0 {
return
}
deficit := (p.Size - p.Population) / 8
if deficit > p.Colonists {
deficit = p.Colonists
}
p.Colonists -= deficit
p.Population += deficit * 8
}
func UnloadColonists(p Planet, v float64) Planet {