refactor: executors and routers
* refactor: executors and routers
This commit is contained in:
@@ -1,6 +1,24 @@
|
||||
package game
|
||||
|
||||
import "github.com/google/uuid"
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Relation string
|
||||
|
||||
const (
|
||||
RelationWar Relation = "War"
|
||||
RelationPeace Relation = "Peace"
|
||||
)
|
||||
|
||||
var (
|
||||
relationSet = map[string]Relation{
|
||||
strings.ToLower(RelationWar.String()): RelationWar,
|
||||
strings.ToLower(RelationPeace.String()): RelationPeace,
|
||||
}
|
||||
)
|
||||
|
||||
type Race struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
@@ -15,17 +33,17 @@ type Race struct {
|
||||
ShipTypes []ShipType `json:"shipType,omitempty"`
|
||||
}
|
||||
|
||||
type Relation string
|
||||
func ParseRelation(v string) (Relation, bool) {
|
||||
if v, ok := relationSet[strings.ToLower(v)]; ok {
|
||||
return v, ok
|
||||
}
|
||||
return Relation(""), false
|
||||
}
|
||||
|
||||
func (r Relation) String() string {
|
||||
return string(r)
|
||||
}
|
||||
|
||||
const (
|
||||
RelationWar Relation = "War"
|
||||
RelationPeace Relation = "Peace"
|
||||
)
|
||||
|
||||
type RaceRelation struct {
|
||||
RaceID uuid.UUID `json:"raceId"`
|
||||
Relation Relation `json:"relation"`
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package game
|
||||
|
||||
import "github.com/google/uuid"
|
||||
|
||||
type State struct {
|
||||
ID uuid.UUID
|
||||
Turn uint
|
||||
Stage uint
|
||||
Players []PlayerState
|
||||
}
|
||||
|
||||
type PlayerState struct {
|
||||
ID uuid.UUID
|
||||
Name string
|
||||
Extinct bool
|
||||
}
|
||||
Reference in New Issue
Block a user