wip: generate report
This commit is contained in:
@@ -3,37 +3,37 @@ package controller
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/internal/model/report"
|
||||
)
|
||||
|
||||
func (c *Cache) bombingReport(p *game.Planet, ri int, groups []int) report.BombingPlanetReport {
|
||||
func (c *Cache) bombingReport(p *game.Planet, ri int, groups []int) *game.Bombing {
|
||||
attackPower := 0.
|
||||
for _, i := range groups {
|
||||
sg := c.ShipGroup(i)
|
||||
st := c.ShipGroupShipClass(i)
|
||||
attackPower += sg.BombingPower(st)
|
||||
}
|
||||
r := &report.BombingPlanetReport{
|
||||
ID: uuid.New(),
|
||||
Planet: p.Name,
|
||||
Number: p.Number,
|
||||
Owner: c.g.Race[c.RaceIndex(p.Owner)].Name,
|
||||
Attacker: c.g.Race[ri].Name,
|
||||
Production: c.PlanetProductionDisplayName(p.Number),
|
||||
Industry: p.Industry.RF(),
|
||||
Population: p.Population.RF(),
|
||||
Colonists: p.Colonists.RF(),
|
||||
Capital: p.Capital.RF(),
|
||||
Material: p.Material.RF(),
|
||||
AttackPower: game.RF(attackPower),
|
||||
r := &game.Bombing{
|
||||
ID: uuid.New(),
|
||||
PlanetOwnedID: p.Owner,
|
||||
Planet: p.Name,
|
||||
Number: p.Number,
|
||||
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: game.F(attackPower),
|
||||
}
|
||||
bombPlanet(p, attackPower)
|
||||
r.Wiped = p.Population == 0
|
||||
return *r
|
||||
return r
|
||||
}
|
||||
|
||||
func (c *Cache) ProduceBombings() []report.BombingPlanetReport {
|
||||
report := make([]report.BombingPlanetReport, 0)
|
||||
func (c *Cache) ProduceBombings() []*game.Bombing {
|
||||
report := make([]*game.Bombing, 0)
|
||||
for pn, enemies := range c.collectBombingGroups() {
|
||||
p := c.MustPlanet(pn)
|
||||
for ri, groups := range enemies {
|
||||
|
||||
Reference in New Issue
Block a user