refactor: float64 types for storage and report
This commit is contained in:
@@ -20,12 +20,12 @@ func (c *Cache) bombingReport(p *game.Planet, ri int, groups []int) report.Bombi
|
||||
Owner: c.g.Race[c.RaceIndex(p.Owner)].Name,
|
||||
Attacker: c.g.Race[ri].Name,
|
||||
Production: c.PlanetProductionDisplayName(p.Number),
|
||||
Industry: p.Industry,
|
||||
Population: p.Population,
|
||||
Colonists: p.Colonists,
|
||||
Capital: p.Capital,
|
||||
Material: p.Material,
|
||||
AttackPower: attackPower,
|
||||
Industry: p.Industry.RF(),
|
||||
Population: p.Population.RF(),
|
||||
Colonists: p.Colonists.RF(),
|
||||
Capital: p.Capital.RF(),
|
||||
Material: p.Material.RF(),
|
||||
AttackPower: game.RF(attackPower),
|
||||
}
|
||||
bombPlanet(p, attackPower)
|
||||
r.Wiped = p.Population == 0
|
||||
@@ -61,23 +61,23 @@ func (c *Cache) ProduceBombings() []report.BombingPlanetReport {
|
||||
|
||||
func bombPlanet(p *game.Planet, power float64) {
|
||||
// Уничтожается население и колонисты в количестве равном [суммарной] мощности бомбардировки
|
||||
if power > p.Population {
|
||||
p.Population = 0
|
||||
if power > p.Population.F() {
|
||||
p.Pop(0)
|
||||
} else {
|
||||
p.Population -= power
|
||||
p.Pop(p.Population.F() - power)
|
||||
}
|
||||
if power > p.Colonists {
|
||||
p.Colonists = 0
|
||||
if power > p.Colonists.F() {
|
||||
p.Col(0)
|
||||
} else {
|
||||
p.Colonists -= power
|
||||
p.Col(p.Colonists.F() - power)
|
||||
}
|
||||
// Такое же количество промышленности превращается в сырье
|
||||
if power > p.Industry {
|
||||
p.Material += p.Industry
|
||||
p.Industry = 0
|
||||
if power > p.Industry.F() {
|
||||
p.Mat(p.Material.F() + p.Industry.F())
|
||||
p.Ind(0)
|
||||
} else {
|
||||
p.Material += power
|
||||
p.Industry -= power
|
||||
p.Mat(p.Material.F() + power)
|
||||
p.Ind(p.Industry.F() - power)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user