race quit, transfer state, refactor

This commit is contained in:
Ilia Denisov
2026-02-07 01:59:11 +02:00
parent 43ba5eb07c
commit fc73cbf83a
27 changed files with 520 additions and 341 deletions
+16 -12
View File
@@ -38,7 +38,7 @@ const (
StateLaunched ShipGroupState = "Launched"
StateInSpace ShipGroupState = "In_Space"
StateUpgrade ShipGroupState = "Upgrade"
StateTransfer ShipGroupState = "Transfer_Status"
StateTransfer ShipGroupState = "Transfer"
)
func (sgs ShipGroupState) String() string {
@@ -104,17 +104,18 @@ func (t Tech) String() string {
}
type ShipGroup struct {
Index uint `json:"index"` // FIXME: use UUID for Group Index (ordered)
OwnerID uuid.UUID `json:"ownerId"` // Race link
TypeID uuid.UUID `json:"typeId"` // ShipType link
FleetID *uuid.UUID `json:"fleetId,omitempty"` // Fleet link
Number uint `json:"number"` // Number (quantity) ships of specific ShipType
CargoType *CargoType `json:"loadType,omitempty"` //
Load Float `json:"load"` // Cargo loaded - "Масса груза"
Tech TechSet `json:"tech"` //
Destination uint `json:"destination"` // TODO: TEST: Destination, Origin, Range
StateInSpace *InSpace `json:"stateInSpace,omitempty"` //
StateUpgrade *InUpgrade `json:"stateUpgrade,omitempty"` //
Index uint `json:"index"` // FIXME: use UUID for Group Index (ordered)
OwnerID uuid.UUID `json:"ownerId"` // Race link
TypeID uuid.UUID `json:"typeId"` // ShipType link
FleetID *uuid.UUID `json:"fleetId,omitempty"` // Fleet link
Number uint `json:"number"` // Number (quantity) ships of specific ShipType
CargoType *CargoType `json:"loadType,omitempty"` //
Load Float `json:"load"` // Cargo loaded - "Масса груза"
Tech TechSet `json:"tech"` //
Destination uint `json:"destination"` // TODO: TEST: Destination, Origin, Range
StateInSpace *InSpace `json:"inSpace,omitempty"` //
StateUpgrade *InUpgrade `json:"upgrade,omitempty"` //
StateTransfer bool `json:"transfer,omitempty"` //
}
func (sg ShipGroup) TechLevel(t Tech) Float {
@@ -134,6 +135,9 @@ func (sg ShipGroup) State() ShipGroupState {
if sg.StateInSpace.Range > 0 {
return StateInSpace
}
if sg.StateTransfer {
return StateTransfer
}
return StateLaunched
case sg.StateUpgrade != nil && sg.StateInSpace == nil:
return StateUpgrade
+7
View File
@@ -38,9 +38,16 @@ func (p *Planet) Free() {
p.Owner = nil
p.Production = ProductionNone.AsType(uuid.Nil)
p.Colonists = 0.
p.Population = 0.
clear(p.Route)
}
func (p *Planet) Wipe() {
p.Free()
p.Industry = 0
p.Capital = 0
}
func (p Planet) Owned() bool {
return p.Owner != nil && *p.Owner != uuid.Nil
}
+1
View File
@@ -5,6 +5,7 @@ import "github.com/google/uuid"
type Race struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
TTL uint `json:"ttl"`
Extinct bool `json:"extinct"`
Votes Float `json:"votes"`
VoteFor uuid.UUID `json:"voteFor"`