feat: load player's report

This commit is contained in:
Ilia Denisov
2026-02-08 20:47:46 +02:00
parent f8412be248
commit e48a0c8b96
16 changed files with 91 additions and 35 deletions
+12 -5
View File
@@ -4,6 +4,7 @@ import (
"github.com/google/uuid"
"github.com/iliadenisov/galaxy/internal/controller"
"github.com/iliadenisov/galaxy/internal/model/game"
"github.com/iliadenisov/galaxy/internal/model/report"
)
func GenerateGame(configure func(*controller.Param), races []string) (gameID uuid.UUID, err error) {
@@ -25,13 +26,19 @@ func LoadState(configure func(*controller.Param)) (g *game.Game, err error) {
return
}
// TODO: command for loading report by players (MUST be limited by router)
func LoadReport(configure func(*controller.Param)) (g *game.Game, err error) {
func LoadReport(configure func(*controller.Param), t uint, actor string) (g *report.Report, err error) {
err = control(configure, func(c *controller.Controller) error {
return c.ExecuteState(func(r controller.Repo) error {
g, err = c.Repo.LoadState()
game, err := c.Repo.LoadStateSafe()
if err != nil {
return err
})
}
c.Cache = controller.NewCache(game)
id, err := c.RaceID(actor)
if err != nil {
return err
}
g, err = c.Repo.LoadReport(t, id)
return err
})
return
}