fix: production with free P.I.
This commit is contained in:
@@ -199,11 +199,10 @@ func (c *Cache) PlanetProductionCapacity(planetNumber uint) float64 {
|
||||
return p.ProductionCapacity() - busyResources
|
||||
}
|
||||
|
||||
// TODO: test upgrade & upgrade cancel
|
||||
func (c *Cache) TurnPlanetProductions() {
|
||||
// cancel upgrade for groups on wiped planets
|
||||
for sgi := range c.ShipGroupsIndex() {
|
||||
sg := c.ShipGroup(sgi)
|
||||
// cancel upgrade for groups on wiped planets
|
||||
if sg.State() == game.StateUpgrade && !c.MustPlanet(sg.Destination).Owned() {
|
||||
sg.StateUpgrade = nil
|
||||
}
|
||||
@@ -215,7 +214,7 @@ func (c *Cache) TurnPlanetProductions() {
|
||||
r := &c.g.Race[ri]
|
||||
|
||||
// upgrade groups and return to in_orbit state
|
||||
productionAvailable := p.ProductionCapacity()
|
||||
productionAvailable := c.PlanetProductionCapacity(pn)
|
||||
for sg := range c.shipGroupsInUpgrade(p.Number) {
|
||||
cost := sg.StateUpgrade.Cost()
|
||||
if productionAvailable >= cost {
|
||||
@@ -235,19 +234,19 @@ func (c *Cache) TurnPlanetProductions() {
|
||||
}
|
||||
case game.ResearchScience:
|
||||
sc := c.mustScience(ri, *p.Production.SubjectID)
|
||||
ResearchTech(r, p.ProductionCapacity(), sc.Drive.F(), sc.Weapons.F(), sc.Shields.F(), sc.Cargo.F())
|
||||
ResearchTech(r, productionAvailable, sc.Drive.F(), sc.Weapons.F(), sc.Shields.F(), sc.Cargo.F())
|
||||
case game.ResearchDrive:
|
||||
ResearchTech(r, p.ProductionCapacity(), 1., 0, 0, 0)
|
||||
ResearchTech(r, productionAvailable, 1., 0, 0, 0)
|
||||
case game.ResearchWeapons:
|
||||
ResearchTech(r, p.ProductionCapacity(), 0, 1., 0, 0)
|
||||
ResearchTech(r, productionAvailable, 0, 1., 0, 0)
|
||||
case game.ResearchShields:
|
||||
ResearchTech(r, p.ProductionCapacity(), 0, 0, 1., 0)
|
||||
ResearchTech(r, productionAvailable, 0, 0, 1., 0)
|
||||
case game.ResearchCargo:
|
||||
ResearchTech(r, p.ProductionCapacity(), 0, 0, 0, 1.)
|
||||
ResearchTech(r, productionAvailable, 0, 0, 0, 1.)
|
||||
case game.ProductionMaterial:
|
||||
p.ProduceMaterial()
|
||||
p.ProduceMaterial(productionAvailable)
|
||||
case game.ProductionCapital:
|
||||
p.ProduceIndustry()
|
||||
p.ProduceIndustry(productionAvailable)
|
||||
default:
|
||||
panic(fmt.Sprintf("unprocessed production type: '%v' for planet: #%d owner=%v", pt, pn, p.Owner))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user