support multi-module (#4)

* add multimodule
* re-package modules
This commit is contained in:
Ilia Denisov
2026-02-22 08:57:19 +02:00
committed by GitHub
parent 9e36d7151e
commit 8f982278d2
132 changed files with 317 additions and 191 deletions
+43
View File
@@ -0,0 +1,43 @@
package report
import (
"encoding/json"
"github.com/google/uuid"
)
type BattleReport struct {
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 {
InBattle bool `json:"inBattle"`
Number uint `json:"num"`
NumberLeft uint `json:"numLeft"`
LoadQuantity Float `json:"loadQuantity"`
Tech map[string]Float `json:"tech"`
Race string `json:"race"`
ClassName string `json:"className"`
LoadType string `json:"loadType"`
}
type BattleActionReport struct {
Attacker int `json:"a"`
AttackerShipClass int `json:"sa"`
Defender int `json:"d"`
DefenderShipClass int `json:"sd"`
Destroyed bool `json:"x"`
}
func (b BattleReport) MarshalBinary() (data []byte, err error) {
return json.Marshal(&b)
}
func (b *BattleReport) UnmarshalBinary(data []byte) error {
return json.Unmarshal(data, b)
}
+19
View File
@@ -0,0 +1,19 @@
package report
import "github.com/google/uuid"
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"`
}
+31
View File
@@ -0,0 +1,31 @@
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" - Свободный производственный потенциал
// [ ] FreeIndustry - неактуальная информация, т.к. модернизация происходит в процессе производства хода
}
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"`
}
+76
View File
@@ -0,0 +1,76 @@
package report
import (
"encoding/json"
n "galaxy/util"
"github.com/google/uuid"
)
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 `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"`
OnPlanetGroupCache map[uint][]int `json:"-"`
InSpaceGroupRangeCache map[int]map[uint]float64 `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"`
Extinct bool `json:"extinct"`
}
func (r Report) MarshalBinary() (data []byte, err error) {
return json.Marshal(&r)
}
func (r *Report) UnmarshalBinary(data []byte) error {
return json.Unmarshal(data, r)
}
+14
View File
@@ -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
}
+70
View File
@@ -0,0 +1,70 @@
package report
import "github.com/google/uuid"
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"` // Стоимость постройки одного такого корабля (в производственных ед.) без учета расходов на добычу сырья
ProdUsed Float `json:"prodUsed"` // Сколько производственных единиц уже было затрачено на постройку этого корабля (уже учитывая производство сырья)
Percent Float `json:"percent"` // Процент завершения активного производства
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"`
}
type LocalGroup struct {
OtherGroup
ID uuid.UUID `json:"id"`
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"`
}