well, fuck...

This commit is contained in:
Ilia Denisov
2025-09-28 09:17:17 +03:00
parent 66eeefc65d
commit 6510676237
8 changed files with 203 additions and 62 deletions
+28 -14
View File
@@ -6,26 +6,40 @@ import (
"github.com/google/uuid"
)
type Planet struct {
X float64 `json:"x"`
Y float64 `json:"y"`
Size float64 `json:"size"`
Name string `json:"name"`
Number uint `json:"number"`
Owner uuid.UUID `json:"owner"`
Production ProductionType `json:"production"`
Population float64 `json:"population"` // P - Население
Industry float64 `json:"industry"` // I - Промышленность
Resources float64 `json:"resources"` // R - Ресурсы / сырьё
type UnidentifiedPlanet struct {
X float64 `json:"x"`
Y float64 `json:"y"`
Number uint `json:"number"`
}
type UninhabitedPlanet struct {
UnidentifiedPlanet
Size float64 `json:"size"`
Name string `json:"name"`
Resources float64 `json:"resources"` // R - Ресурсы / сырьё
Capital float64 `json:"capital"` // CAP $ - Запасы промышленности
Material float64 `json:"material"` // MAT M - Запасы ресурсов / сырья
Colonists float64 `json:"colonists"` // COL C - Количество колонистов
}
type PlanetReport struct {
UninhabitedPlanet
Industry float64 `json:"industry"` // I - Промышленность
Population float64 `json:"population"` // P - Население
Colonists float64 `json:"colonists"` // COL C - Количество колонистов
Production ProductionType `json:"production"` // TODO: internal/report format
// Параметр "L" - Свободный производственный потенциал
}
type Planet struct {
Owner uuid.UUID `json:"owner"`
PlanetReport
}
type PlanetReportForeign struct {
RaceName string
PlanetReport
}
// Свободный производственный потенциал (L)
// промышленность * 0.75 + население * 0.25
// TODO: за вычетом затрат, расходуемых в течение хода на модернизацию кораблей
+9 -2
View File
@@ -22,9 +22,16 @@ type Race struct {
Fleets []Fleet `json:"fleet,omitempty"`
}
type Relation string
const (
RelationWar = "War"
RelationPeace = "Peace"
)
type RaceRelation struct {
RaceID uuid.UUID `json:"raceId"`
Peace bool `json:"peace"`
RaceID uuid.UUID `json:"raceId"`
Relation Relation `json:"relation"`
}
func (r Race) FlightDistance() float64 {
+67
View File
@@ -0,0 +1,67 @@
package game
type Report struct {
Width, Height uint32
PlanetCount uint32 // do we need that?
PlayersLeft uint32 // do we need that?
Votes float64
VoteFor string
Statuses []PlayerStatus
Sciences []ScienceReport
ForeignSciences []ScienceReportForeign
ShipTypes []ShipTypeReport
ForeignShipTypes []ShipTypeReportForeign
Battles []any // TODO: tbd
Bombings []any // TODO: tbd
IncomingGroups []IncomingGroup
Planets []PlanetReport
ForeignPlanets []PlanetReportForeign
UninhabitedPlanets []UninhabitedPlanet
UnidentifiedPlanets []UnidentifiedPlanet
ShipsInProduction []any // TODO: tbd
Routes []any // TODO: tbd
Fleets []any // TODO: tbd
ShipGroups []any // TODO: tbd
ForeignShipGroups []any // TODO: tbd
UnidentifiedGroups []any // TODO: tbd
}
type IncomingGroup struct {
SourcePlanetNumber uint
TargetPlanetNumber uint
Distance float64
Speed float64
Mass float64
}
type ReportRelation struct {
RaceName string
Relation string
}
type PlayerStatus struct {
Name string
Drive float64 `json:"drive"`
Weapons float64 `json:"weapons"`
Shields float64 `json:"shields"`
Cargo float64 `json:"cargo"`
Population float64
Industry float64
Planets uint16
Relation ReportRelation
Votes float64
}
+15 -6
View File
@@ -3,10 +3,19 @@ package game
import "github.com/google/uuid"
type Science struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Drive float64 `json:"drive"`
Weapons float64 `json:"weapons"`
Shields float64 `json:"shields"`
Cargo float64 `json:"cargo"`
ID uuid.UUID `json:"id"`
ScienceReport
}
type ScienceReportForeign struct {
RaceName string
ScienceReport
}
type ScienceReport struct {
Name string `json:"name"`
Drive float64 `json:"drive"`
Weapons float64 `json:"weapons"`
Shields float64 `json:"shields"`
Cargo float64 `json:"cargo"`
}
+16 -7
View File
@@ -7,14 +7,23 @@ import (
"github.com/iliadenisov/galaxy/pkg/number"
)
type ShipTypeReport struct {
Name string `json:"name"`
Drive float64 `json:"drive"` // [0], [1...]
Armament uint `json:"armament"`
Weapons float64 `json:"weapons"` // [0], [1...]
Shields float64 `json:"shields"` // [0], [1...]
Cargo float64 `json:"cargo"` // [0], [1...]
}
type ShipType struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Drive float64 `json:"drive"` // [0], [1...]
Armament uint `json:"armament"`
Weapons float64 `json:"weapons"` // [0], [1...]
Shields float64 `json:"shields"` // [0], [1...]
Cargo float64 `json:"cargo"` // [0], [1...]
ID uuid.UUID `json:"id"`
ShipTypeReport
}
type ShipTypeReportForeign struct {
RaceName string
ShipTypeReport
}
type ShipGroup struct {
+28 -20
View File
@@ -9,20 +9,24 @@ import (
func TestShipType(t *testing.T) {
Gunship := game.ShipType{
Drive: 4,
Armament: 2,
Weapons: 2,
Shields: 4,
Cargo: 0,
ShipTypeReport: game.ShipTypeReport{
Drive: 4,
Armament: 2,
Weapons: 2,
Shields: 4,
Cargo: 0,
},
}
assert.Equal(t, Gunship.EmptyMass(), 11.)
Cruiser := game.ShipType{
Drive: 15,
Armament: 1,
Weapons: 15,
Shields: 15,
Cargo: 0,
ShipTypeReport: game.ShipTypeReport{
Drive: 15,
Armament: 1,
Weapons: 15,
Shields: 15,
Cargo: 0,
},
}
assert.Equal(t, Cruiser.EmptyMass(), 45.)
@@ -45,11 +49,13 @@ func TestShipType(t *testing.T) {
func TestCargoCapacity(t *testing.T) {
test := func(cargoSize float64, expectCapacity float64) {
ship := game.ShipType{
Drive: 1,
Armament: 1,
Weapons: 1,
Shields: 1,
Cargo: cargoSize,
ShipTypeReport: game.ShipTypeReport{
Drive: 1,
Armament: 1,
Weapons: 1,
Shields: 1,
Cargo: cargoSize,
},
}
sg := game.ShipGroup{
Type: ship,
@@ -71,11 +77,13 @@ func TestCargoCapacity(t *testing.T) {
func TestBombingPower(t *testing.T) {
Gunship := game.ShipType{
Drive: 60.0,
Armament: 3,
Weapons: 30.0,
Shields: 100.0,
Cargo: 0.0,
ShipTypeReport: game.ShipTypeReport{
Drive: 60.0,
Armament: 3,
Weapons: 30.0,
Shields: 100.0,
Cargo: 0.0,
},
}
sg := game.ShipGroup{
Type: Gunship,