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
+10 -17
View File
@@ -211,29 +211,30 @@ func (c *Cache) TurnPlanetProductions() {
}
case game.ResearchScience:
sc := c.mustScience(ri, *p.Production.SubjectID)
IncreaseTech(r, p, sc.Drive, sc.Weapons, sc.Shields, sc.Cargo)
ResearchTech(r, p.ProductionCapacity(), sc.Drive, sc.Weapons, sc.Shields, sc.Cargo)
case game.ResearchDrive:
IncreaseTech(r, p, 1., 0, 0, 0)
ResearchTech(r, p.ProductionCapacity(), 1., 0, 0, 0)
case game.ResearchWeapons:
IncreaseTech(r, p, 0, 1., 0, 0)
ResearchTech(r, p.ProductionCapacity(), 0, 1., 0, 0)
case game.ResearchShields:
IncreaseTech(r, p, 0, 0, 1., 0)
ResearchTech(r, p.ProductionCapacity(), 0, 0, 1., 0)
case game.ResearchCargo:
IncreaseTech(r, p, 0, 0, 0, 1.)
ResearchTech(r, p.ProductionCapacity(), 0, 0, 0, 1.)
case game.ProductionMaterial:
p.IncreaseMaterial()
p.ProduceMaterial()
case game.ProductionCapital:
p.IncreaseIndustry()
p.ProduceIndustry()
default:
panic(fmt.Sprintf("unprocessed production type: %v", pt))
}
p.IncreasePopulation()
// last step: increase population / colonists
p.ProducePopulation()
}
c.TurnMergeEqualShipGroups()
}
// listProducingPlanets iterates over all inhabited planet numbers with production not set to None.
// listProducingPlanets iterates over all inhabited planet numbers with defined production type.
// Planets producing ships guaranteed to be iterated first for correct turn actions order.
func (c *Cache) listProducingPlanets() iter.Seq[uint] {
ordered := make([]int, 0)
@@ -261,14 +262,6 @@ func (c *Cache) listProducingPlanets() iter.Seq[uint] {
}
}
func IncreaseTech(r *game.Race, p *game.Planet, d, w, s, c float64) {
increment := 5000. / p.ProductionCapacity()
r.Tech.Set(game.TechDrive, r.Tech.Value(game.TechDrive)+increment*d)
r.Tech.Set(game.TechWeapons, r.Tech.Value(game.TechWeapons)+increment*w)
r.Tech.Set(game.TechShields, r.Tech.Value(game.TechShields)+increment*s)
r.Tech.Set(game.TechCargo, r.Tech.Value(game.TechCargo)+increment*c)
}
// Internal funcs
func (c *Cache) putPopulation(pn uint, v float64) {