wip: generate rest of report
This commit is contained in:
@@ -41,13 +41,17 @@ const (
|
||||
StateTransfer ShipGroupState = "Transfer_Status"
|
||||
)
|
||||
|
||||
func (sgs ShipGroupState) String() string {
|
||||
return string(sgs)
|
||||
}
|
||||
|
||||
type InSpace struct {
|
||||
Origin uint `json:"origin"`
|
||||
X float64 `json:"x"`
|
||||
Y float64 `json:"y"`
|
||||
Origin uint `json:"origin"`
|
||||
X Float `json:"x"`
|
||||
Y Float `json:"y"`
|
||||
// zero is for Launched status
|
||||
// TODO: calculate range dynamically -BUT- if affects ShipGroup.State()
|
||||
Range float64 `json:"range"`
|
||||
Range Float `json:"range"`
|
||||
}
|
||||
|
||||
func (is InSpace) Equal(other InSpace) bool {
|
||||
@@ -138,6 +142,7 @@ func (sg ShipGroup) State() ShipGroupState {
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: ambigous func, refactor
|
||||
func (sg ShipGroup) OnPlanet() (uint, bool) {
|
||||
switch sg.State() {
|
||||
case StateInOrbit:
|
||||
@@ -152,7 +157,7 @@ func (sg ShipGroup) OnPlanet() (uint, bool) {
|
||||
func (sg ShipGroup) Coord() (float64, float64, bool) {
|
||||
state := sg.State()
|
||||
if state == StateInSpace || state == StateLaunched {
|
||||
return sg.StateInSpace.X, sg.StateInSpace.Y, true
|
||||
return sg.StateInSpace.X.F(), sg.StateInSpace.Y.F(), true
|
||||
}
|
||||
return 0, 0, false
|
||||
}
|
||||
|
||||
@@ -7,30 +7,30 @@ import (
|
||||
)
|
||||
|
||||
type BattleReport struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Planet uint `json:"planet"`
|
||||
PlanetName string `json:"planetName"`
|
||||
// PlanetOwnedID uuid.UUID `json:"-"` // TODO: need this? for make report: bombings: initial owher of a planet
|
||||
Races map[int]uuid.UUID `json:"races"`
|
||||
Ships map[int]BattleReportGroup `json:"ships"`
|
||||
Protocol []BattleActionReport `json:"protocol"`
|
||||
ID uuid.UUID `json:"id"`
|
||||
Planet uint `json:"planet"`
|
||||
PlanetName string `json:"planetName"`
|
||||
Races map[int]uuid.UUID `json:"races"`
|
||||
Ships map[int]BattleReportGroup `json:"ships"`
|
||||
Protocol []BattleActionReport `json:"protocol"`
|
||||
}
|
||||
|
||||
type BattleReportGroup struct {
|
||||
OwnerID uuid.UUID `json:"-"` // make report: visible ship class
|
||||
InBattle bool `json:"inBattle"`
|
||||
Number uint `json:"num"`
|
||||
NumberLeft uint `json:"numLeft"`
|
||||
ClassArmament uint `json:"-"` // make report: visible ship class
|
||||
ClassMass Float `json:"-"` // make report: visible ship class
|
||||
LoadQuantity Float `json:"loadQuantity"`
|
||||
DriveTech Float `json:"drive"`
|
||||
WeaponsTech Float `json:"wwapons"`
|
||||
ShieldsTech Float `json:"shields"`
|
||||
CargoTech Float `json:"cargo"`
|
||||
Race string `json:"race"`
|
||||
ClassName string `json:"className"`
|
||||
LoadType string `json:"loadType"`
|
||||
// OwnerID uuid.UUID `json:"-"` // make report: visible ship class
|
||||
InBattle bool `json:"inBattle"`
|
||||
Number uint `json:"num"`
|
||||
NumberLeft uint `json:"numLeft"`
|
||||
// ClassArmament uint `json:"-"` // make report: visible ship class
|
||||
// ClassMass Float `json:"-"` // make report: visible ship class
|
||||
LoadQuantity Float `json:"loadQuantity"`
|
||||
Tech map[string]Float `json:"tech"`
|
||||
// DriveTech Float `json:"drive"`
|
||||
// WeaponsTech Float `json:"weapons"`
|
||||
// ShieldsTech Float `json:"shields"`
|
||||
// CargoTech Float `json:"cargo"`
|
||||
Race string `json:"race"`
|
||||
ClassName string `json:"className"`
|
||||
LoadType string `json:"loadType"`
|
||||
}
|
||||
|
||||
type BattleActionReport struct {
|
||||
|
||||
@@ -14,36 +14,36 @@ func F(v float64) Float {
|
||||
}
|
||||
|
||||
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"`
|
||||
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 `json:"otherPlanet,omitempty"`
|
||||
UninhabitedPlanet []UninhabitedPlanet `json:"uninhabitedPlanet,omitempty"`
|
||||
UnidentifiedPlanet []UnidentifiedPlanet `json:"unidentifiedPlanet,omitempty"`
|
||||
LocalFleet []LocalFleet `json:"localFleet,omitempty"`
|
||||
LocalGroup []LocalGroup `json:"localGroup,omitempty"`
|
||||
OtherGroup []OtherGroup `json:"otherGroup,omitempty"`
|
||||
UnidentifiedGroup []UnidentifiedGroup `json:"unidentifiedGroup,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:"-"`
|
||||
OnPlanetGroupCache map[uint][]int `json:"-"`
|
||||
InSpaceGroupRangeCache map[int]map[uint]float64 `json:"-"`
|
||||
}
|
||||
|
||||
type Route struct {
|
||||
|
||||
@@ -30,3 +30,38 @@ type IncomingGroup struct {
|
||||
Speed Float `json:"speed"`
|
||||
Mass Float `json:"mass"`
|
||||
}
|
||||
|
||||
type LocalGroup struct {
|
||||
OtherGroup
|
||||
Index uint `json:"index"`
|
||||
State string `json:"state"`
|
||||
Fleet *string `json:"fleet"`
|
||||
}
|
||||
|
||||
type OtherGroup struct {
|
||||
Number uint `json:"number"`
|
||||
Class string `json:"class"`
|
||||
Tech map[string]Float `json:"tech"`
|
||||
Cargo string `json:"cargo"`
|
||||
Load Float `json:"load"`
|
||||
Destination uint `json:"destination"`
|
||||
Origin *uint `json:"origin,omitempty"`
|
||||
Range *Float `json:"range,omitempty"`
|
||||
Speed Float `json:"speed"`
|
||||
Mass Float `json:"mass"`
|
||||
}
|
||||
|
||||
type UnidentifiedGroup struct {
|
||||
X Float `json:"x"`
|
||||
Y Float `json:"y"`
|
||||
}
|
||||
|
||||
type LocalFleet struct {
|
||||
Name string `json:"name"`
|
||||
Groups uint `json:"groups"`
|
||||
Destination uint `json:"destination"`
|
||||
Origin *uint `json:"origin,omitempty"`
|
||||
Range *Float `json:"range,omitempty"`
|
||||
Speed Float `json:"speed"`
|
||||
State string `json:"state"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user