feat: turn stage increment after player's command
This commit is contained in:
@@ -6,22 +6,26 @@ 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(c, r, g, from, to, game.RelationWar) })
|
||||
err = control(configure, func(c *controller.Controller) error {
|
||||
return c.ExecuteCommand(func(r controller.Repo, g *game.Game) error {
|
||||
return updateRelation(c, 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(c, r, g, from, to, game.RelationPeace) })
|
||||
err = control(configure, func(c *controller.Controller) error {
|
||||
return c.ExecuteCommand(func(r controller.Repo, g *game.Game) error {
|
||||
return updateRelation(c, from, to, game.RelationPeace)
|
||||
})
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func updateRelation(c *controller.Controller, r controller.Repo, g *game.Game, hostRace, opponentRace string, rel game.Relation) error {
|
||||
func updateRelation(c *controller.Controller, hostRace, opponentRace string, rel game.Relation) error {
|
||||
if err := c.UpdateRelation(hostRace, opponentRace, rel); err != nil {
|
||||
return err
|
||||
}
|
||||
return r.SaveLastState(g)
|
||||
return nil // r.SaveLastState(g)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user