feat: finish game; store reports
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user