feat: load player's report

This commit is contained in:
Ilia Denisov
2026-02-08 20:47:46 +02:00
parent f8412be248
commit e48a0c8b96
16 changed files with 91 additions and 35 deletions
+4 -4
View File
@@ -11,19 +11,19 @@ import (
"github.com/iliadenisov/galaxy/internal/model/rest"
)
type CommandExecutor func(controller.Config, rest.Command) error
type CommandExecutor func(controller.Configurer, rest.Command) error
var (
ErrCommandNotProcessed = errors.New("command was not processed by executor")
)
func CommandHandler(c *gin.Context, config controller.Config, executor CommandExecutor) {
func CommandHandler(c *gin.Context, configurer controller.Configurer, executor CommandExecutor) {
var cmd rest.Command
if err := c.ShouldBindJSON(&cmd); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
return
}
err := executor(config, cmd)
err := executor(configurer, cmd)
switch {
case err == nil:
c.Status(http.StatusOK)
@@ -35,7 +35,7 @@ func CommandHandler(c *gin.Context, config controller.Config, executor CommandEx
}
}
func ExecuteCommand(config controller.Config, cmd rest.Command) error {
func ExecuteCommand(config controller.Configurer, cmd rest.Command) error {
switch {
case cmd.DeclareWar != nil:
return game.DeclareWar(config, cmd.Race, cmd.DeclareWar.Opponent)