refactor: planet industry production
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"math"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
@@ -106,20 +104,15 @@ func ProducedMaterial(shipMass, progress 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) ProduceIndustry(freeProduction float64) {
|
||||
var ind float64
|
||||
if p.Material > 0 {
|
||||
ind = math.Min(freeProduction/5, p.Material.F())
|
||||
p.Mat(p.Material.F() - ind)
|
||||
freeProduction -= ind * 5.
|
||||
prod := freeProduction / 5
|
||||
if float64(p.Material) < prod {
|
||||
prod = (freeProduction + float64(p.Material/p.Resources)) / (5. + 1./float64(p.Resources))
|
||||
p.Material = 0.
|
||||
} else {
|
||||
p.Material = p.Material.Add(-prod)
|
||||
}
|
||||
ind += (freeProduction * p.Resources.F()) / (5.*p.Resources.F() + 1.)
|
||||
p.Ind(p.Industry.F() + ind)
|
||||
p.Industry = p.Industry.Add(prod)
|
||||
if p.Industry > p.Population {
|
||||
p.Capital += p.Industry - p.Population
|
||||
p.Industry = p.Population
|
||||
|
||||
Reference in New Issue
Block a user