23 lines
645 B
Go
23 lines
645 B
Go
package game
|
|
|
|
import (
|
|
"github.com/iliadenisov/galaxy/internal/controller"
|
|
"github.com/iliadenisov/galaxy/internal/model/game"
|
|
)
|
|
|
|
func RenamePlanet(configure func(*controller.Param), race string, number int, name string) (err error) {
|
|
control(configure, func(c *controller.Controller) {
|
|
c.ExecuteGame(func(r controller.Repo, g *game.Game) {
|
|
err = renamePlanet(c, r, g, race, number, name)
|
|
})
|
|
})
|
|
return
|
|
}
|
|
|
|
func renamePlanet(c *controller.Controller, r controller.Repo, g *game.Game, race string, number int, name string) error {
|
|
if err := c.RenamePlanet(race, number, name); err != nil {
|
|
return err
|
|
}
|
|
return r.SaveLastState(g)
|
|
}
|