feat: status api

This commit is contained in:
Ilia Denisov
2026-01-07 18:38:06 +02:00
parent 1b0ab7a079
commit 204d3df8cf
20 changed files with 188 additions and 40 deletions
+13 -4
View File
@@ -6,14 +6,23 @@ import (
"github.com/iliadenisov/galaxy/internal/model/game"
)
func LoadState(configure func(*controller.Param)) (g game.Game, err error) {
control(configure, func(c *controller.Controller) { c.ExecuteInit(func(r controller.Repo) { g, err = c.Repo.LoadState() }) })
func GenerateGame(configure func(*controller.Param), races []string) (gameID uuid.UUID, err error) {
control(configure, func(c *controller.Controller) {
c.ExecuteState(func(r controller.Repo) { gameID, err = controller.NewGame(r, races) })
})
return
}
func GenerateGame(configure func(*controller.Param), races []string) (gameID uuid.UUID, err error) {
// LoadState used for lock-safe loading game state and may be called concurrently.
func LoadState(configure func(*controller.Param)) (g game.Game, err error) {
control(configure, func(c *controller.Controller) { g, err = c.Repo.LoadStateSafe() })
return
}
// TODO: command for loading report by players (MUST be limited by router)
func LoadReport(configure func(*controller.Param)) (g game.Game, err error) {
control(configure, func(c *controller.Controller) {
c.ExecuteInit(func(r controller.Repo) { gameID, err = controller.NewGame(r, races) })
c.ExecuteState(func(r controller.Repo) { g, err = c.Repo.LoadState() })
})
return
}