fix(game): small reconciliation fixes (science, generation, dismantle, report)
A bundle of small rules-vs-engine corrections: - Science proportions: accept a sum that equals 1 only up to float rounding (was an exact != 1 comparison); the rules example is reworded so it is unambiguous that proportions are fractions summing to 1. - Generation: super-big planets get a resource strictly above 0 (minimum 0.001, was a hard 0.1); the rules table is fixed for big planets (1-10, not 0.1-10) and the false "0.1-20 / average 1.5" resource claim removed. - Dismantle over a neutral planet now unloads the colonists and settles it (the planet becomes the race's); over a foreign planet they are still lost. The rules clause is clarified for own / neutral / foreign. - Report: ship-production entries are written at the compacted report index (was the planet's map index, which could write past the grown slice and panic); the incoming-group "remaining distance" is measured from the group's current hyperspace position, not its origin planet (matching OtherGroup). - validator: the cargo-value error now carries the cargo value, not the shields value. Tests added for each behavioural fix; rules.txt updated in the same patch.
This commit is contained in:
@@ -412,7 +412,6 @@ func (c *Cache) ReportIncomingGroup(ri int, rep *mr.Report) {
|
||||
if sg.OwnerID == r.ID || sg.State() != game.StateInSpace {
|
||||
continue
|
||||
}
|
||||
p1 := c.MustPlanet(sg.StateInSpace.Origin)
|
||||
p2 := c.MustPlanet(sg.Destination)
|
||||
if !p2.OwnedBy(r.ID) {
|
||||
continue
|
||||
@@ -434,7 +433,9 @@ func (c *Cache) ReportIncomingGroup(ri int, rep *mr.Report) {
|
||||
continue
|
||||
}
|
||||
|
||||
distance := calc.ShortDistance(c.g.Map.Width, c.g.Map.Height, p1.X.F(), p1.Y.F(), p2.X.F(), p2.Y.F())
|
||||
// Remaining distance is measured from the group's current position in
|
||||
// hyperspace to the destination, not from its origin planet.
|
||||
distance := calc.ShortDistance(c.g.Map.Width, c.g.Map.Height, sg.StateInSpace.X.F(), sg.StateInSpace.Y.F(), p2.X.F(), p2.Y.F())
|
||||
var speed, mass float64
|
||||
if sg.FleetID != nil {
|
||||
speed, mass = c.FleetSpeedAndMass(c.MustFleetIndex(*sg.FleetID))
|
||||
@@ -577,12 +578,12 @@ func (c *Cache) ReportShipProduction(ri int, rep *mr.Report) {
|
||||
st := c.MustShipType(ri, *p.Production.SubjectID)
|
||||
|
||||
sliceIndexValidate(&rep.ShipProduction, i)
|
||||
rep.ShipProduction[pi].Planet = p.Number
|
||||
rep.ShipProduction[pi].Class = st.Name
|
||||
rep.ShipProduction[pi].Cost = mr.F(calc.ShipProductionCost(st.EmptyMass()))
|
||||
rep.ShipProduction[pi].Free = mr.F(c.PlanetProductionCapacity(p.Number))
|
||||
rep.ShipProduction[pi].ProdUsed = mr.F((*p.Production.ProdUsed).F())
|
||||
rep.ShipProduction[pi].Percent = mr.F((*p.Production.Progress).F())
|
||||
rep.ShipProduction[i].Planet = p.Number
|
||||
rep.ShipProduction[i].Class = st.Name
|
||||
rep.ShipProduction[i].Cost = mr.F(calc.ShipProductionCost(st.EmptyMass()))
|
||||
rep.ShipProduction[i].Free = mr.F(c.PlanetProductionCapacity(p.Number))
|
||||
rep.ShipProduction[i].ProdUsed = mr.F((*p.Production.ProdUsed).F())
|
||||
rep.ShipProduction[i].Percent = mr.F((*p.Production.Progress).F())
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user