feat: store battles and bombings
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"maps"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/iliadenisov/galaxy/internal/model/report"
|
||||
)
|
||||
|
||||
type TechSet map[Tech]float64
|
||||
@@ -26,7 +27,7 @@ func (ts TechSet) Set(t Tech, v float64) TechSet {
|
||||
|
||||
type Game struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Age uint `json:"turn"` // Game's turn number
|
||||
Turn uint `json:"turn"`
|
||||
Map Map `json:"map"`
|
||||
Race []Race `json:"races"`
|
||||
Votes float64 `json:"votes"`
|
||||
@@ -34,6 +35,18 @@ type Game struct {
|
||||
Fleets []Fleet `json:"fleet,omitempty"`
|
||||
}
|
||||
|
||||
type GameMeta struct {
|
||||
Battles []BattleMeta `json:"battles,omitempty"`
|
||||
Bombings []report.BombingPlanetReport `json:"bombings,omitempty"`
|
||||
}
|
||||
|
||||
type BattleMeta struct {
|
||||
Turn uint `json:"turn"`
|
||||
Planet uint `json:"planet"`
|
||||
BattleID uuid.UUID `json:"battle_id"`
|
||||
ObserverIDs []uuid.UUID `json:"observer_ids"`
|
||||
}
|
||||
|
||||
// TODO: remove if not needed
|
||||
func (g Game) RaceVotes(raceID uuid.UUID) float64 {
|
||||
var result float64
|
||||
@@ -52,3 +65,11 @@ func (g Game) MarshalBinary() (data []byte, err error) {
|
||||
func (g *Game) UnmarshalBinary(data []byte) error {
|
||||
return json.Unmarshal(data, g)
|
||||
}
|
||||
|
||||
func (b GameMeta) MarshalBinary() (data []byte, err error) {
|
||||
return json.Marshal(&b)
|
||||
}
|
||||
|
||||
func (b *GameMeta) UnmarshalBinary(data []byte) error {
|
||||
return json.Unmarshal(data, b)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user