wip: generate report

This commit is contained in:
Ilia Denisov
2026-02-03 23:41:18 +02:00
parent a567229f8a
commit adbe605783
36 changed files with 1037 additions and 391 deletions
+21 -7
View File
@@ -6,9 +6,22 @@ import (
"maps"
"github.com/google/uuid"
"github.com/iliadenisov/galaxy/internal/model/report"
)
type Float float64
func F(v float64) Float {
return Float(v)
}
func (f Float) Add(v float64) Float {
return F(f.F() + v)
}
func (f Float) F() float64 {
return float64(f)
}
type TechSet map[Tech]float64
func (ts TechSet) Value(t Tech) float64 {
@@ -25,6 +38,7 @@ func (ts TechSet) Set(t Tech, v float64) TechSet {
return m
}
// TODO: turn's incremental Version
type Game struct {
ID uuid.UUID `json:"id"`
Turn uint `json:"turn"`
@@ -36,8 +50,8 @@ type Game struct {
}
type GameMeta struct {
Battles []BattleMeta `json:"battles,omitempty"`
Bombings []report.BombingPlanetReport `json:"bombings,omitempty"`
Battles []BattleMeta `json:"battles,omitempty"`
Bombings []Bombing `json:"bombings,omitempty"`
}
type BattleMeta struct {
@@ -66,10 +80,10 @@ 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 (gm GameMeta) MarshalBinary() (data []byte, err error) {
return json.Marshal(&gm)
}
func (b *GameMeta) UnmarshalBinary(data []byte) error {
return json.Unmarshal(data, b)
func (gm *GameMeta) UnmarshalBinary(data []byte) error {
return json.Unmarshal(data, gm)
}