cmd: rename planet
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package game
|
||||
|
||||
import "github.com/iliadenisov/galaxy/pkg/model/game"
|
||||
|
||||
func DeclareWar(configure func(*Param), from, to string) (err error) {
|
||||
control(configure, func(c *ctrl) {
|
||||
c.execute(func(r Repo, g game.Game) { err = updateRelation(r, g, from, to, game.RelationWar) })
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func DeclarePeace(configure func(*Param), from, to string) (err error) {
|
||||
control(configure, func(c *ctrl) {
|
||||
c.execute(func(r Repo, g game.Game) { err = updateRelation(r, g, from, to, game.RelationPeace) })
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func updateRelation(r Repo, g game.Game, hostRace, opponentRace string, rel game.Relation) error {
|
||||
if err := g.UpdateRelation(hostRace, opponentRace, rel); err != nil {
|
||||
return err
|
||||
}
|
||||
return r.SaveState(g)
|
||||
}
|
||||
Reference in New Issue
Block a user