feat: finish game; store reports

This commit is contained in:
Ilia Denisov
2026-02-04 14:21:37 +02:00
parent abc98ee72f
commit 9a6d4112cf
6 changed files with 43 additions and 10 deletions
+9 -7
View File
@@ -50,6 +50,7 @@ func MakeTurn(c *Controller, r Repo) error {
// 16. Происходит голосование.
winners := c.Cache.TurnCalculateVotes()
c.Cache.TurnAcceptWinners(winners)
/*** Last steps ***/
@@ -107,15 +108,16 @@ func MakeTurn(c *Controller, r Repo) error {
c.Cache.DeleteKilledShipGroups()
// Store game state for the new turn and 'current' state as well
r.SaveTurn(c.Cache.g.Turn, c.Cache.g)
// TODO: Store individual reports
for ri := range c.Cache.g.Race {
_ = ri
// c.Cache.GenerateReport(ri)
if err := r.SaveTurn(c.Cache.g.Turn, c.Cache.g); err != nil {
return err
}
for rep := range c.Cache.Report(c.Cache.g.Turn, battleReport, bombingReport) {
if err := r.SaveReport(c.Cache.g.Turn, rep); err != nil {
return err
}
}
_ = winners
// [ ] monitor memory consumption at this point?
return nil
}