cmd: rename planet

This commit is contained in:
Ilia Denisov
2025-10-01 22:42:23 +03:00
parent 2295840efe
commit 8a7e2f57c7
12 changed files with 156 additions and 20 deletions
+24
View File
@@ -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)
}