fix: production with free P.I.

This commit is contained in:
Ilia Denisov
2026-02-06 21:43:47 +02:00
parent 3c4968ab8f
commit 43ba5eb07c
7 changed files with 62 additions and 54 deletions
+7 -8
View File
@@ -76,7 +76,7 @@ func (p Planet) Votes() float64 {
return p.Population.F() / 1000.
}
// Производственный потенциал
// Производственный потенциал без учёта модернизации кораблей
func (p Planet) ProductionCapacity() float64 {
return PlanetProduction(p.Industry.F(), p.Population.F())
}
@@ -104,15 +104,14 @@ func ProducedMaterial(shipMass, progress 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) ProduceIndustry() {
production := p.ProductionCapacity()
func (p *Planet) ProduceIndustry(freeProduction float64) {
var ind float64
if p.Material > 0 {
ind = math.Min(production/5, p.Material.F())
ind = math.Min(freeProduction/5, p.Material.F())
p.Mat(p.Material.F() - ind)
production -= ind * 5.
freeProduction -= ind * 5.
}
ind += (production * p.Resources.F()) / (5.*p.Resources.F() + 1.)
ind += (freeProduction * p.Resources.F()) / (5.*p.Resources.F() + 1.)
p.Ind(p.Industry.F() + ind)
if p.Industry > p.Population {
p.Capital += p.Industry - p.Population
@@ -121,8 +120,8 @@ func (p *Planet) ProduceIndustry() {
}
// Производство материалов
func (p *Planet) ProduceMaterial() {
p.Material = p.Material.Add(p.ProductionCapacity() * p.Resources.F())
func (p *Planet) ProduceMaterial(freeProduction float64) {
p.Material = p.Material.Add(freeProduction * p.Resources.F())
}
// Автоматическое увеличение населения на каждом ходу