wip: generate report
This commit is contained in:
@@ -7,27 +7,30 @@ import (
|
||||
)
|
||||
|
||||
type BattleReport struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Turn uint `json:"turn"`
|
||||
Planet uint `json:"planet"`
|
||||
PlanetName string `json:"planet_name"`
|
||||
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"`
|
||||
// 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"`
|
||||
}
|
||||
|
||||
type BattleReportGroup struct {
|
||||
OwnerID uuid.UUID `json:"ownerId"`
|
||||
InBattle bool `json:"inBattle"`
|
||||
Number uint `json:"num"`
|
||||
NumberLeft uint `json:"numLeft"`
|
||||
ClassName string `json:"className"`
|
||||
LoadType string `json:"loadType"`
|
||||
LoadQuantity Float `json:"loadQuantity"`
|
||||
Drive Float `json:"drive"`
|
||||
Weapons Float `json:"wwapons"`
|
||||
Shields Float `json:"shields"`
|
||||
Cargo Float `json:"cargo"`
|
||||
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"`
|
||||
}
|
||||
|
||||
type BattleActionReport struct {
|
||||
|
||||
@@ -2,18 +2,18 @@ package report
|
||||
|
||||
import "github.com/google/uuid"
|
||||
|
||||
type BombingPlanetReport struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Planet string `json:"name"`
|
||||
Number uint `json:"number"`
|
||||
Owner string `json:"owner"`
|
||||
Attacker string `json:"attacker"`
|
||||
Production string `json:"production"`
|
||||
Industry Float `json:"industry"` // I - Промышленность
|
||||
Population Float `json:"population"` // P - Население
|
||||
Colonists Float `json:"colonists"` // COL C - Количество колонистов
|
||||
Capital Float `json:"capital"` // CAP $ - Запасы промышленности
|
||||
Material Float `json:"material"` // MAT M - Запасы ресурсов / сырья
|
||||
AttackPower Float `json:"attack"`
|
||||
Wiped bool `json:"wiped"`
|
||||
type Bombing struct {
|
||||
PlanetOwnedID uuid.UUID `json:"-"` // make report: filter by planet's owner before bombing
|
||||
Number uint `json:"planet"`
|
||||
Planet string `json:"planetName"`
|
||||
Owner string `json:"owner"`
|
||||
Attacker string `json:"attacker"`
|
||||
Production string `json:"production"`
|
||||
Industry Float `json:"industry"` // I - Промышленность
|
||||
Population Float `json:"population"` // P - Население
|
||||
Colonists Float `json:"colonists"` // COL C - Количество колонистов
|
||||
Capital Float `json:"capital"` // CAP $ - Запасы промышленности
|
||||
Material Float `json:"material"` // MAT M - Запасы ресурсов / сырья
|
||||
AttackPower Float `json:"attack"`
|
||||
Wiped bool `json:"wiped"`
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package report
|
||||
|
||||
type OtherPlanet struct {
|
||||
Owner string `json:"owner"`
|
||||
LocalPlanet
|
||||
}
|
||||
|
||||
type LocalPlanet struct {
|
||||
UninhabitedPlanet
|
||||
Industry Float `json:"industry"` // I - Промышленность
|
||||
Population Float `json:"population"` // P - Население
|
||||
Colonists Float `json:"colonists"` // COL C - Количество колонистов
|
||||
Production string `json:"production"`
|
||||
FreeIndustry Float `json:"freeInductry"` // Параметр "L" - Свободный производственный потенциал
|
||||
}
|
||||
|
||||
type UninhabitedPlanet struct {
|
||||
UnidentifiedPlanet
|
||||
Size Float `json:"size"`
|
||||
Name string `json:"name"`
|
||||
Resources Float `json:"resources"` // R - Ресурсы
|
||||
Capital Float `json:"capital"` // CAP $ - Запасы промышленности
|
||||
Material Float `json:"material"` // MAT M - Запасы ресурсов / сырьё
|
||||
}
|
||||
|
||||
type UnidentifiedPlanet struct {
|
||||
X Float `json:"x"`
|
||||
Y Float `json:"y"`
|
||||
Number uint `json:"number"`
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package report
|
||||
|
||||
type Science struct {
|
||||
Name string `json:"name"`
|
||||
Drive Float `json:"drive"`
|
||||
Weapons Float `json:"weapons"`
|
||||
Shields Float `json:"shields"`
|
||||
Cargo Float `json:"cargo"`
|
||||
}
|
||||
|
||||
type OtherScience struct {
|
||||
Race string `json:"race"`
|
||||
Science
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package report
|
||||
|
||||
type ShipClass struct {
|
||||
Name string `json:"name"`
|
||||
Drive Float `json:"drive"`
|
||||
Armament uint `json:"armament"`
|
||||
Weapons Float `json:"weapons"`
|
||||
Shields Float `json:"shields"`
|
||||
Cargo Float `json:"cargo"`
|
||||
Mass Float `json:"mass"`
|
||||
}
|
||||
|
||||
type OthersShipClass struct {
|
||||
Race string `json:"race"`
|
||||
ShipClass
|
||||
}
|
||||
|
||||
type ShipProduction struct {
|
||||
Planet uint `json:"planet"` // Галактический номер планеты
|
||||
Class string `json:"class"` // Наименование типа строящегося корабля
|
||||
Cost Float `json:"cost"` // Стоимость постройки одного такого корабля (в производственных ед.) без учета расходов на добычу сырья
|
||||
Wasted Float `json:"wasted"` // Сколько производственных единиц уже было затрачено на постройку этого корабля (уже учитывая производство сырья)
|
||||
Free Float `json:"free"` // Свободный производственный потенциал
|
||||
}
|
||||
|
||||
type IncomingGroup struct {
|
||||
Origin uint `json:"origin"`
|
||||
Destination uint `json:"destination"`
|
||||
Distance Float `json:"distance"`
|
||||
Speed Float `json:"speed"`
|
||||
Mass Float `json:"mass"`
|
||||
}
|
||||
Reference in New Issue
Block a user