refactor: executors and routers

* refactor: executors and routers
This commit is contained in:
Ilia Denisov
2026-02-09 15:53:34 +03:00
committed by GitHub
parent e48a0c8b96
commit d9c8de27e5
38 changed files with 508 additions and 838 deletions
+18 -14
View File
@@ -1,26 +1,30 @@
package rest
/*
Full list of requirements must be updated when adding new command:
import "encoding/json"
required_without_all=Vote DeclarePeace DeclareWar
| excluded_with=Vote DeclarePeace DeclareWar
*/
type Command struct {
Race string `json:"race" binding:"required,notblank"`
Vote *CommandVote `json:"vote" binding:"required_without_all=DeclarePeace DeclareWar,excluded_with=DeclarePeace DeclareWar"`
DeclarePeace *CommandDeclarePeace `json:"declarePeace" binding:"required_without_all=Vote DeclareWar,excluded_with=Vote DeclareWar"`
DeclareWar *CommandDeclareWar `json:"declareWar" binding:"required_without_all=Vote DeclarePeace,excluded_with=Vote DeclarePeace"`
Actor string `json:"actor" binding:"required,notblank"`
Commands []json.RawMessage `json:"cmd" binding:"min=1"`
}
type CommandType string
const (
CommandTypeVote CommandType = "vote"
CommandTypeRelation CommandType = "declarePeace"
)
type CommandMeta struct {
Type CommandType `json:"@type"`
}
type CommandVote struct {
CommandMeta
Recipient string `json:"recipient" binding:"required,notblank"`
}
type CommandDeclarePeace struct {
Opponent string `json:"recipient" binding:"required,notblank"`
}
type CommandDeclareWar struct {
type CommandUpdateRelation struct {
CommandMeta
Opponent string `json:"recipient" binding:"required,notblank"`
Relation string `json:"relation" binding:"required,notblank"`
}
+13 -3
View File
@@ -1,6 +1,16 @@
package rest
type Status struct {
Turn uint `json:"turn"`
Players int `json:"players"`
import "github.com/google/uuid"
type StateResponse struct {
ID uuid.UUID `json:"id"`
Turn uint `json:"turn"`
Stage uint `json:"stage"`
Players []PlayerState `json:"player"`
}
type PlayerState struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Extinct bool `json:"extinct"`
}