feat: status api
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
func JoinEqualGroups(configure func(*controller.Param), race string) (err error) {
|
||||
control(configure, func(c *controller.Controller) {
|
||||
c.Execute(func(r controller.Repo, g game.Game) {
|
||||
c.ExecuteGame(func(r controller.Repo, g game.Game) {
|
||||
err = joinEqualGroups(r, g, race)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
func RenamePlanet(configure func(*controller.Param), race string, number int, name string) (err error) {
|
||||
control(configure, func(c *controller.Controller) {
|
||||
c.Execute(func(r controller.Repo, g game.Game) {
|
||||
c.ExecuteGame(func(r controller.Repo, g game.Game) {
|
||||
err = renamePlanet(r, g, race, number, name)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
func PlanetProduction(configure func(*controller.Param), race string, planetNumber int, prodType, subject string) (err error) {
|
||||
control(configure, func(c *controller.Controller) {
|
||||
c.Execute(func(r controller.Repo, g game.Game) {
|
||||
c.ExecuteGame(func(r controller.Repo, g game.Game) {
|
||||
err = planetProduction(r, g, race, planetNumber, prodType, subject)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
func CreateScience(configure func(*controller.Param), race, typeName string, drive, weapons, shields, cargo float64) (err error) {
|
||||
control(configure, func(c *controller.Controller) {
|
||||
c.Execute(func(r controller.Repo, g game.Game) {
|
||||
c.ExecuteGame(func(r controller.Repo, g game.Game) {
|
||||
err = createScience(r, g, race, typeName, drive, weapons, shields, cargo)
|
||||
})
|
||||
})
|
||||
@@ -23,7 +23,7 @@ func createScience(r controller.Repo, g game.Game, race, typeName string, d, w,
|
||||
|
||||
func DeleteScience(configure func(*controller.Param), race, typeName string) (err error) {
|
||||
control(configure, func(c *controller.Controller) {
|
||||
c.Execute(func(r controller.Repo, g game.Game) {
|
||||
c.ExecuteGame(func(r controller.Repo, g game.Game) {
|
||||
err = deleteScience(r, g, race, typeName)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
|
||||
func CreateShipType(configure func(*controller.Param), race, typeName string, drive, weapons, shields, cargo float64, armament int) (err error) {
|
||||
control(configure, func(c *controller.Controller) {
|
||||
c.Execute(func(r controller.Repo, g game.Game) {
|
||||
c.ExecuteGame(func(r controller.Repo, g game.Game) {
|
||||
err = createShipType(r, g, race, typeName, drive, weapons, shields, cargo, armament)
|
||||
})
|
||||
})
|
||||
@@ -23,7 +23,7 @@ func createShipType(r controller.Repo, g game.Game, race, typeName string, d, w,
|
||||
|
||||
func MergeShipType(configure func(*controller.Param), race, source, target string) (err error) {
|
||||
control(configure, func(c *controller.Controller) {
|
||||
c.Execute(func(r controller.Repo, g game.Game) {
|
||||
c.ExecuteGame(func(r controller.Repo, g game.Game) {
|
||||
err = mergeShipType(r, g, race, source, target)
|
||||
})
|
||||
})
|
||||
@@ -39,7 +39,7 @@ func mergeShipType(r controller.Repo, g game.Game, race, source, target string)
|
||||
|
||||
func DeleteShipType(configure func(*controller.Param), race, typeName string) (err error) {
|
||||
control(configure, func(c *controller.Controller) {
|
||||
c.Execute(func(r controller.Repo, g game.Game) {
|
||||
c.ExecuteGame(func(r controller.Repo, g game.Game) {
|
||||
err = deleteShipType(r, g, race, typeName)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -7,14 +7,14 @@ import (
|
||||
|
||||
func DeclareWar(configure func(*controller.Param), from, to string) (err error) {
|
||||
control(configure, func(c *controller.Controller) {
|
||||
c.Execute(func(r controller.Repo, g game.Game) { err = updateRelation(r, g, from, to, game.RelationWar) })
|
||||
c.ExecuteGame(func(r controller.Repo, g game.Game) { err = updateRelation(r, g, from, to, game.RelationWar) })
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func DeclarePeace(configure func(*controller.Param), from, to string) (err error) {
|
||||
control(configure, func(c *controller.Controller) {
|
||||
c.Execute(func(r controller.Repo, g game.Game) { err = updateRelation(r, g, from, to, game.RelationPeace) })
|
||||
c.ExecuteGame(func(r controller.Repo, g game.Game) { err = updateRelation(r, g, from, to, game.RelationPeace) })
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user