chore: refactor structure

This commit is contained in:
Ilia Denisov
2025-11-21 22:06:40 +03:00
parent 269de2184c
commit 1bdb40a27d
8 changed files with 18 additions and 18 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ import (
)
func JoinEqualGroups(configure func(*controller.Param), race string) (err error) {
control(configure, func(c *controller.Ctrl) {
control(configure, func(c *controller.Controller) {
c.Execute(func(r controller.Repo, g game.Game) {
err = joinEqualGroups(r, g, race)
})
+1 -1
View File
@@ -6,7 +6,7 @@ import (
)
func RenamePlanet(configure func(*controller.Param), race string, number int, name string) (err error) {
control(configure, func(c *controller.Ctrl) {
control(configure, func(c *controller.Controller) {
c.Execute(func(r controller.Repo, g game.Game) {
err = renamePlanet(r, g, race, number, name)
})
+1 -1
View File
@@ -6,7 +6,7 @@ import (
)
func PlanetProduction(configure func(*controller.Param), race string, planetNumber int, prodType, subject string) (err error) {
control(configure, func(c *controller.Ctrl) {
control(configure, func(c *controller.Controller) {
c.Execute(func(r controller.Repo, g game.Game) {
err = planetProduction(r, g, race, planetNumber, prodType, subject)
})
+2 -2
View File
@@ -6,7 +6,7 @@ import (
)
func CreateScience(configure func(*controller.Param), race, typeName string, drive, weapons, shields, cargo float64) (err error) {
control(configure, func(c *controller.Ctrl) {
control(configure, func(c *controller.Controller) {
c.Execute(func(r controller.Repo, g game.Game) {
err = createScience(r, g, race, typeName, drive, weapons, shields, cargo)
})
@@ -22,7 +22,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.Ctrl) {
control(configure, func(c *controller.Controller) {
c.Execute(func(r controller.Repo, g game.Game) {
err = deleteScience(r, g, race, typeName)
})
+3 -3
View File
@@ -6,7 +6,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.Ctrl) {
control(configure, func(c *controller.Controller) {
c.Execute(func(r controller.Repo, g game.Game) {
err = createShipType(r, g, race, typeName, drive, weapons, shields, cargo, armament)
})
@@ -22,7 +22,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.Ctrl) {
control(configure, func(c *controller.Controller) {
c.Execute(func(r controller.Repo, g game.Game) {
err = mergeShipType(r, g, race, source, target)
})
@@ -38,7 +38,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.Ctrl) {
control(configure, func(c *controller.Controller) {
c.Execute(func(r controller.Repo, g game.Game) {
err = deleteShipType(r, g, race, typeName)
})
+2 -2
View File
@@ -6,14 +6,14 @@ import (
)
func DeclareWar(configure func(*controller.Param), from, to string) (err error) {
control(configure, func(c *controller.Ctrl) {
control(configure, func(c *controller.Controller) {
c.Execute(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.Ctrl) {
control(configure, func(c *controller.Controller) {
c.Execute(func(r controller.Repo, g game.Game) { err = updateRelation(r, g, from, to, game.RelationPeace) })
})
return
+3 -3
View File
@@ -7,18 +7,18 @@ import (
)
func LoadState(configure func(*controller.Param)) (g game.Game, err error) {
control(configure, func(c *controller.Ctrl) { c.ExecuteInit(func(r controller.Repo) { g, err = c.Repo.LoadState() }) })
control(configure, func(c *controller.Controller) { c.ExecuteInit(func(r controller.Repo) { g, err = c.Repo.LoadState() }) })
return
}
func GenerateGame(configure func(*controller.Param), races []string) (gameID uuid.UUID, err error) {
control(configure, func(c *controller.Ctrl) {
control(configure, func(c *controller.Controller) {
c.ExecuteInit(func(r controller.Repo) { gameID, err = controller.NewGame(r, races) })
})
return
}
func control(configure func(*controller.Param), consumer func(*controller.Ctrl)) error {
func control(configure func(*controller.Param), consumer func(*controller.Controller)) error {
c, err := controller.NewController(configure)
if err != nil {
return err