refactor: load/save state as ptr

This commit is contained in:
Ilia Denisov
2026-01-12 19:30:50 +02:00
parent ac60bb3020
commit 4451850f22
18 changed files with 71 additions and 57 deletions
+3 -3
View File
@@ -7,19 +7,19 @@ import (
func DeclareWar(configure func(*controller.Param), from, to string) (err error) {
control(configure, func(c *controller.Controller) {
c.ExecuteGame(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.ExecuteGame(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
}
func updateRelation(r controller.Repo, g game.Game, hostRace, opponentRace string, rel game.Relation) error {
func updateRelation(r controller.Repo, g *game.Game, hostRace, opponentRace string, rel game.Relation) error {
if err := g.UpdateRelation(hostRace, opponentRace, rel); err != nil {
return err
}