wip: generate report
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
package report
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/google/uuid"
|
||||
n "github.com/iliadenisov/galaxy/internal/number"
|
||||
)
|
||||
|
||||
type Float float64
|
||||
|
||||
func F(v float64) Float {
|
||||
return Float(n.Fixed3(v))
|
||||
}
|
||||
|
||||
type Report struct {
|
||||
Version uint `json:"version"`
|
||||
Turn uint `json:"turn"`
|
||||
Width uint32 `json:"mapWidth"`
|
||||
Height uint32 `json:"mapHeight"`
|
||||
PlanetCount uint32 `json:"mapPlanets"`
|
||||
Race string `json:"race"`
|
||||
RaceID uuid.UUID `json:"-"`
|
||||
Votes Float `json:"votes"`
|
||||
VoteFor string `json:"voteFor"`
|
||||
Player []Player `json:"player"`
|
||||
LocalScience []Science `json:"localScience,omitempty"`
|
||||
OtherScience []OtherScience `json:"otherScience,omitempty"`
|
||||
LocalShipClass []ShipClass `json:"localShipClass,omitempty"`
|
||||
OtherShipClass []OthersShipClass `json:"otherShipClass,omitempty"`
|
||||
Battle []uuid.UUID `json:"battle,omitempty"`
|
||||
Bombing []*Bombing `json:"bombing,omitempty"`
|
||||
IncomingGroup []IncomingGroup `json:"incomingGroup,omitempty"`
|
||||
LocalPlanet []LocalPlanet `json:"localPlanet,omitempty"`
|
||||
ShipProduction []ShipProduction `json:"shipProduction,omitempty"`
|
||||
Route []Route `json:"route,omitempty"`
|
||||
|
||||
OtherPlanet []OtherPlanet
|
||||
UninhabitedPlanet []UninhabitedPlanet
|
||||
UnidentifiedPlanet []UnidentifiedPlanet
|
||||
Fleet []any // TODO: tbd
|
||||
LocalShipGroup []any // TODO: tbd
|
||||
OtherShipGroup []any // TODO: tbd
|
||||
UnidentifiedGroups []any // TODO: tbd
|
||||
|
||||
PlanetGroupsCache map[uint][]int `json:"-"`
|
||||
}
|
||||
|
||||
type Route struct {
|
||||
Planet uint `json:"planet"`
|
||||
Route map[uint]string `json:"route"`
|
||||
}
|
||||
|
||||
type Player struct {
|
||||
ID uuid.UUID `json:"-"`
|
||||
Name string `json:"name"`
|
||||
Drive Float `json:"drive"`
|
||||
Weapons Float `json:"weapons"`
|
||||
Shields Float `json:"shields"`
|
||||
Cargo Float `json:"cargo"`
|
||||
Population Float `json:"population"`
|
||||
Industry Float `json:"industry"`
|
||||
Planets uint16 `json:"planets"`
|
||||
Relation string `json:"relation"`
|
||||
Votes Float `json:"votes"`
|
||||
}
|
||||
|
||||
func (r Report) MarshalBinary() (data []byte, err error) {
|
||||
return json.Marshal(&r)
|
||||
}
|
||||
|
||||
func (r *Report) UnmarshalBinary(data []byte) error {
|
||||
return json.Unmarshal(data, r)
|
||||
}
|
||||
Reference in New Issue
Block a user