feat: bomb planets
This commit is contained in:
@@ -41,9 +41,9 @@ type PlanetReportForeign struct {
|
||||
PlanetReport
|
||||
}
|
||||
|
||||
// TODO: delete func
|
||||
// Производственный потенциал
|
||||
func (p Planet) ProductionCapacity() float64 {
|
||||
return p.Industry*0.75 + p.Population*0.25
|
||||
return PlanetProduction(p.Industry, p.Population)
|
||||
}
|
||||
|
||||
func PlanetProduction(industry, population float64) float64 {
|
||||
@@ -53,7 +53,7 @@ func PlanetProduction(industry, population float64) float64 {
|
||||
// Производство промышленности
|
||||
// TODO: test on real values
|
||||
func (p *Planet) IncreaseIndustry() {
|
||||
prod := p.ProductionCapacity() / 5
|
||||
prod := p.ProductionCapacity() / 5.
|
||||
industryIncrement := math.Min(prod, p.Material)
|
||||
p.Industry += industryIncrement
|
||||
if p.Industry > p.Population {
|
||||
@@ -62,6 +62,18 @@ 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() {
|
||||
@@ -69,14 +81,28 @@ func (p *Planet) IncreaseMaterial() {
|
||||
}
|
||||
|
||||
// Автоматическое увеличение населения на каждом ходу
|
||||
// TODO: test
|
||||
func (p *Planet) IncreasePopulation() {
|
||||
p.Population *= 1.08
|
||||
if p.Population > p.Size {
|
||||
p.Colonists += (p.Population - p.Size) / 8
|
||||
p.Colonists += (p.Population - p.Size) / 8.
|
||||
p.Population = p.Size
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Planet) UnpackCOLtoPOP() {
|
||||
if p.Colonists < 1 {
|
||||
return
|
||||
}
|
||||
maxCOL := uint((p.Size - p.Population) / 8.)
|
||||
if float64(maxCOL) > p.Colonists {
|
||||
maxCOL = uint(p.Colonists)
|
||||
}
|
||||
maxCOL = uint(float64(maxCOL) - math.Mod(float64(maxCOL), 8.))
|
||||
p.Colonists -= float64(maxCOL)
|
||||
p.Population += float64(maxCOL) * 8
|
||||
}
|
||||
|
||||
func UnloadColonists(p Planet, v float64) Planet {
|
||||
p.Population += v * 8
|
||||
if p.Population > p.Size {
|
||||
|
||||
Reference in New Issue
Block a user