feat: load player's report
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user