feat: store battles and bombings

This commit is contained in:
Ilia Denisov
2026-01-30 18:57:43 +03:00
parent 824f6609ab
commit 4c14234afb
16 changed files with 274 additions and 103 deletions
+22 -1
View File
@@ -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)
}