feat: store battles and bombings

This commit is contained in:
Ilia Denisov
2026-01-30 18:57:43 +03:00
parent 824f6609ab
commit 4c14234afb
16 changed files with 274 additions and 103 deletions
+5 -24
View File
@@ -3,36 +3,17 @@ package controller
import (
"github.com/google/uuid"
"github.com/iliadenisov/galaxy/internal/model/game"
"github.com/iliadenisov/galaxy/internal/model/report"
)
type BombingReport struct {
Planets []BombingPlanetReport `json:"planets"`
}
type BombingPlanetReport struct {
ID uuid.UUID `json:"id"`
Planet string `json:"name"`
Number uint `json:"number"`
Owner string `json:"owner"`
Attacker string `json:"attacker"`
Production string `json:"production"`
Industry float64 `json:"industry"` // I - Промышленность
Population float64 `json:"population"` // P - Население
Colonists float64 `json:"colonists"` // COL C - Количество колонистов
Capital float64 `json:"capital"` // CAP $ - Запасы промышленности
Material float64 `json:"material"` // MAT M - Запасы ресурсов / сырья
AttackPower float64 `json:"attack"`
Wiped bool `json:"wiped"`
}
func (c *Cache) bombingReport(p *game.Planet, ri int, groups []int) BombingPlanetReport {
func (c *Cache) bombingReport(p *game.Planet, ri int, groups []int) report.BombingPlanetReport {
attackPower := 0.
for _, i := range groups {
sg := c.ShipGroup(i)
st := c.ShipGroupShipClass(i)
attackPower += sg.BombingPower(st)
}
r := &BombingPlanetReport{
r := &report.BombingPlanetReport{
ID: uuid.New(),
Planet: p.Name,
Number: p.Number,
@@ -51,8 +32,8 @@ func (c *Cache) bombingReport(p *game.Planet, ri int, groups []int) BombingPlane
return *r
}
func (c *Cache) ProduceBombings() []BombingPlanetReport {
report := make([]BombingPlanetReport, 0)
func (c *Cache) ProduceBombings() []report.BombingPlanetReport {
report := make([]report.BombingPlanetReport, 0)
for pn, enemies := range c.collectBombingGroups() {
p := c.MustPlanet(pn)
for ri, groups := range enemies {