Files
galaxy-game/internal/model/rest/command.go
T
2026-02-10 18:31:53 +03:00

66 lines
2.4 KiB
Go

package rest
import "encoding/json"
type Command struct {
Actor string `json:"actor" binding:"required,notblank"`
Commands []json.RawMessage `json:"cmd" binding:"min=1"`
}
type CommandType string
const (
CommandTypeRaceQuit CommandType = "raceQuit"
CommandTypeRaceVote CommandType = "raceVote"
CommandTypeRaceRelation CommandType = "declarePeace"
CommandTypeShipClassCreate CommandType = "shipClassCreate"
CommandTypeShipClassMerge CommandType = "shipClassMerge"
CommandTypeShipClassRemove CommandType = "shipClassRemove"
CommandTypeShipGroupLoad CommandType = "shipGroupLoad"
CommandTypeShipGroupUnload CommandType = "shipGroupUnload"
CommandTypeShipGroupSend CommandType = "shipGroupSend"
CommandTypeShipGroupUpgrade CommandType = "shipGroupUpgrade"
CommandTypeShipGroupBreak CommandType = "shipGroupBreak"
CommandTypeShipGroupMerge CommandType = "shipGroupMerge"
CommandTypeShipGroupDismantle CommandType = "shipGroupDismantle"
CommandTypeShipGroupTransfer CommandType = "shipGroupTransfer"
CommandTypeShipGroupJoinFleet CommandType = "shipGroupJoinFleet"
CommandTypeFleetMerge CommandType = "fleetMerge"
CommandTypeFleetSend CommandType = "fleetSend"
CommandTypeScienceCreate CommandType = "scienceCreate"
CommandTypeScienceRemove CommandType = "scienceRemove"
CommandTypePlanetRename CommandType = "planetRename"
CommandTypePlanetProduce CommandType = "planetProduce"
CommandTypePlanetRouteSet CommandType = "planetRouteSet"
CommandTypePlanetRouteRemove CommandType = "planetRouteRemove"
)
type CommandMeta struct {
Type CommandType `json:"@type" binding:"required,notblank"`
}
type CommandRaceQuit struct {
CommandMeta
}
type CommandRaceVote struct {
CommandMeta
Recipient string `json:"recipient" binding:"required,notblank"`
}
type CommandRaceRelation struct {
CommandMeta
Opponent string `json:"recipient" binding:"required,notblank"`
Relation string `json:"relation" binding:"required,notblank"`
}
type CommandShipClassCreate struct {
CommandMeta
Name string `json:"name" binding:"required,notblank"`
Drive float64 `json:"drive" binding:"eq=0|gte=1"`
Armament int `json:"armament" binding:"ammoWeapons=Weapons"`
Weapons float64 `json:"weapons" binding:"ammoWeapons=Armament"`
Shields float64 `json:"shields" binding:"eq=0|gte=1"`
Cargo float64 `json:"cargo" binding:"eq=0|gte=1"`
}