feat: game order api methods

This commit is contained in:
Ilia Denisov
2026-05-09 10:36:44 +02:00
parent f2a7f2b515
commit 2a1e80053a
17 changed files with 166 additions and 75 deletions
+8 -2
View File
@@ -25,8 +25,10 @@ type CommandExecutor interface {
GameState() (rest.StateResponse, error)
BanishRace(string) error
LoadReport(actor string, turn uint) (*report.Report, error)
// Execute is reserved for future use; any API request for orders should use ValidateOrder
Execute(cmd ...Command) error
ValidateOrder(actor string, cmd ...order.DecodableCommand) error
ValidateOrder(actor string, cmd ...order.DecodableCommand) (*order.UserGamesOrder, error)
FetchOrder(actor string, turn uint) (*order.UserGamesOrder, bool, error)
}
type Command func(controller.Ctrl) error
@@ -76,10 +78,14 @@ func (e *executor) Execute(cmd ...Command) error {
})
}
func (e *executor) ValidateOrder(actor string, cmd ...order.DecodableCommand) error {
func (e *executor) ValidateOrder(actor string, cmd ...order.DecodableCommand) (*order.UserGamesOrder, error) {
return controller.ValidateOrder(e.cfg, actor, cmd...)
}
func (e *executor) FetchOrder(actor string, turn uint) (*order.UserGamesOrder, bool, error) {
return controller.FetchOrder(e.cfg, actor, turn)
}
func (e *executor) GenerateGame(races []string) (rest.StateResponse, error) {
s, err := controller.GenerateGame(e.cfg, races)
if err != nil {