sgm

package
v0.0.0-...-ae9a0ba Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SectorCore   = "core_sector"
	SectorNormal = "normal_sector"

	StarbaseOutpost  = "starbase_level_outpost"
	StarbaseStarport = "starbase_level_starport"
	StarbaseStarhold = "starbase_level_starhold"
	StarbaseFortress = "starbase_level_starfortress"
	StarbaseCitadel  = "starbase_level_citadel"

	StarbaseMarauder   = "starbase_level_marauder"
	StarbaseCaravaneer = "starbase_level_caravaneer"

	StarbaseModuleShipyard       = "shipyard"
	StarbaseModuleTradingHub     = "trading_hub"
	StarbaseModuleAnchorage      = "anchorage"
	StarbaseModuleGunBattery     = "gun_battery"
	StarbaseModuleMissileBattery = "missile_battery"
	StarbaseModuleHangarBay      = "hangar_bay"

	StarbaseBuildingFleetAcademy    = "fleet_academy"
	StarbaseBuildingTitanYards      = "titan_yards"
	StarbaseBuildingColossusYards   = "colossus_yards"
	StarbaseBuildingNavalOffice     = "naval_logistics_office"
	StarbaseBuildingTradingCompany  = "offworld_trading_company"
	StarbaseBuildingCrewQuarters    = "crew_quarters"
	StarbaseBuildingTargetComputer  = "target_uplink_computer"
	StarbaseBuildingCommJammer      = "communications_jammer"
	StarbaseBuildingDefenceGrid     = "defense_grid"
	StarbaseBuildingDisruptionField = "disruption_field"
	StarbaseBuildingWarpFluctuator  = "warp_fluctuator"

	MegastructureRingWorld   = "ring_world"
	MegastructureDysonSphere = "dyson_sphere"
	MegastructureMatterUnzip = "matter_decompressor"

	MegastructureScienceNexus         = "think_tank"
	MegastructureSentryArray          = "spy_orb"
	MegastructureArtInstallation      = "mega_art_installation"
	MegastructureInterstellarAssembly = "interstellar_assembly"
	MegastructureShipyard             = "mega_shipyard"
	MegastructureStrategicCenter      = "strategic_coordination_center"

	MegastructureGateway         = "gateway"
	MegastructureLGate           = "lgate_base"
	MegastructureHyperRelay      = "hyper_relay"
	MegastructureQuantumCatapult = "quantum_catapult"

	MegastructureSizeRingWorld = 3
	MegastructureSizeStar      = 2
	MegastructureSizePlanet    = 1

	FleetOwnershipNormal      = "normal"
	FleetOwnershipLostControl = "lost_control"

	BattleTypeShips  = "ships"
	BattleTypeArmies = "armies"
)
View Source
const (
	DistantStarInitializer       = "distantstars_init"
	DistantStarInitializerLGate0 = "distantstars_init_00"
	DistantStarInitializerLGate6 = "distantstars_init_06"

	PlanetClassEcumenopolis = "pc_city"
	PlanetClassHabitat      = "pc_habitat"
	PlanetClassShielded     = "pc_shielded"

	PlanetDesignationCapital = "col_capital"

	BypassWormhole        = "wormhole"
	BypassLGate           = "lgate"
	BypassGateway         = "gateway"
	BypassGatewayRuined   = "gateway-ruined"
	BypassHyperRelay      = "relay"
	BypassQuantumCatapult = "catapult"
)
View Source
const (
	NewFormatAdj1      = "%ADJECTIVE%"
	NewFormatAdj2      = "%ADJ%"
	NewFormatKeyAppend = "1"
)

Variables

View Source
var (
	CountryNameFormats      map[string]string
	EmpireNames             map[string]string
	SpeciesNames            map[string]string
	PrescriptedCountryNames map[string]string

	PlanetNames = map[string]string{
		"PLANET_NAME_FORMAT": "<PARENT> <NUMERAL>",
	}
)
View Source
var ColorMap struct {
	Colors map[string]*ColorDef `sgm:"colors"`
}
View Source
var DefaultArmyId = ArmyId(math.MaxUint32)
View Source
var DefaultCountryId = CountryId(math.MaxUint32)
View Source
var DefaultFleetId = FleetId(math.MaxUint32)
View Source
var DefaultNames = map[string]string{}
View Source
var DefaultPlanetId = PlanetId(math.MaxUint32)
View Source
var DefaultSectorId = SectorId(math.MaxUint32)
View Source
var DefaultStarId = StarId(math.MaxUint32)
View Source
var DefaultStarbaseId = StarbaseId(math.MaxUint32)
View Source
var MegastructureStages = map[string]int{
	"ruined":   -1,
	"0":        0,
	"1":        1,
	"2":        2,
	"3":        3,
	"4":        4,
	"5":        5,
	"restored": 10,
	"final":    20,
}

Functions

func CountryName

func CountryName(countryId CountryId, country *Country) string

Types

type ArmyId

type ArmyId uint32

type Battle

type Battle struct {
	DefenderIds []CountryId `sgm:"defenders"`
	AttackerIds []CountryId `sgm:"attackers"`

	AttackerVictory bool   `sgm:"attacker_victory"`
	Date            Date   `sgm:"date"`
	Type            string `sgm:"type"`

	StarId StarId `sgm:"system,id"`

	AttackerLosses int `sgm:"attacker_losses"`
	DefenderLosses int `sgm:"defender_losses"`
}

type BattleRef

type BattleRef struct {
	WarId       WarId
	BattleIndex int
}

type Bypass

type Bypass struct {
	Type     string   `sgm:"type"`
	LinkedTo BypassId `sgm:"linked_to"`

	Owner struct {
		Type int    `sgm:"type"`
		Id   uint32 `sgm:"id"`
	} `sgm:"owner"`
}

type BypassId

type BypassId uint32

type Color

type Color struct {
	HSV []float64 `sgm:"hsv"`
	RGB []uint8   `sgm:"rgb"`
}

func (*Color) Color

func (c *Color) Color() colorcode.RGB

type ColorDef

type ColorDef struct {
	Flag Color `sgm:"flag"`
	Map  Color `sgm:"map"`
	Ship Color `sgm:"ship"`
}

type Coordinate

type Coordinate struct {
	X float64 `sgm:"x"`
	Y float64 `sgm:"y"`
}

type Country

type Country struct {
	NameString string `sgm:"name"`
	NameStruct Name   `sgm:"name,struct"`

	Flag CountryFlag `sgm:"flag"`

	CapitalId PlanetId `sgm:"capital"`
	Capital   *Planet

	FleetMgr struct {
		OwnedFleets []OwnedFleet `sgm:"owned_fleets"`
	} `sgm:"fleets_manager"`

	Wars []WarRef
}

func (*Country) Name

func (c *Country) Name() string

type CountryFlag

type CountryFlag struct {
	Colors []string `sgm:"colors"`
}

type CountryId

type CountryId uint32

type Date

type Date string

func (Date) Year

func (d Date) Year() int

type Fleet

type Fleet struct {
	NameString string `sgm:"name"`
	NameStruct Name   `sgm:"name,struct"`

	Station  bool `sgm:"station"`
	Mobile   bool `sgm:"mobile"`
	Civilian bool `sgm:"civilian"`

	MilitaryPower float64 `sgm:"military_power"`

	OwnerId         CountryId `sgm:"owner,id"`
	Owner           *Country
	OwnershipStatus string
	DebtorId        CountryId `sgm:"-,id"`

	ShipIds []ShipId `sgm:"ships"`
	Ships   []*Ship

	Starbase *Starbase
}

func (*Fleet) IsTransport

func (fleet *Fleet) IsTransport() bool

func (*Fleet) MilitaryPowerString

func (fleet *Fleet) MilitaryPowerString() string

func (*Fleet) Name

func (f *Fleet) Name() string

type FleetId

type FleetId uint32

type GameState

type GameState struct {
	Name string `sgm:"name"`
	Date Date   `sgm:"date"`

	Stars    map[StarId]*Star     `sgm:"galactic_object"`
	Planets  PlanetState          `sgm:"planets"`
	Bypasses map[BypassId]*Bypass `sgm:"bypasses"`

	Countries      map[CountryId]*Country             `sgm:"country"`
	Sectors        map[SectorId]*Sector               `sgm:"sectors"`
	StarbaseMgr    StarbaseMgr                        `sgm:"starbase_mgr"`
	Megastructures map[MegastructureId]*Megastructure `sgm:"megastructures"`
	Fleets         map[FleetId]*Fleet                 `sgm:"fleet"`
	Ships          map[ShipId]*Ship                   `sgm:"ships"`
	Wars           map[WarId]*War                     `sgm:"war"`
	Pops           map[PopId]*Pop                     `sgm:"pop"`
}

func LoadGameState

func LoadGameState(path string) (*GameState, error)

type Hyperlane

type Hyperlane struct {
	ToId StarId `sgm:"to"`
	To   *Star
}

type Megastructure

type Megastructure struct {
	Type     string   `sgm:"type"`
	Owner    int      `sgm:"owner"`
	PlanetId PlanetId `sgm:"planet,id"`

	Star   *Star
	Planet *Planet
}

func (Megastructure) TypeStage

func (m Megastructure) TypeStage() (string, int)

type MegastructureId

type MegastructureId uint32

type Name

type Name struct {
	Key       string         `sgm:"key"`
	Variables []NameVariable `sgm:"variables"`
}

func (*Name) Format

func (n *Name) Format(formatNames map[string]string) string

func (*Name) Resolve

func (n *Name) Resolve() string

type NameVariable

type NameVariable struct {
	Key   string `sgm:"key"`
	Value Name   `sgm:"value"`
}

type OwnedFleet

type OwnedFleet struct {
	FleetId FleetId `sgm:"fleet"`
	Fleet   *Fleet

	OwnershipStatus string `sgm:"ownership_status"`

	DebtorId CountryId `sgm:"debtor,id"`
}

type Planet

type Planet struct {
	Star *Star

	NameString  string `sgm:"name"`
	NameStruct  Name   `sgm:"name,struct"`
	Class       string `sgm:"planet_class"`
	Designation string `sgm:"final_designation"`

	Moons  []PlanetId `sgm:"moons"`
	MoonOf PlanetId   `sgm:"moon_of"`

	OrbitalFleetId FleetId `sgm:"orbital_defence,id"`
	OrbitalFleet   *Fleet

	OwnerId CountryId `sgm:"owner,id"`

	EmployablePops int `sgm:"employable_pops"`
}

func (*Planet) IsHabitat

func (p *Planet) IsHabitat() bool

func (*Planet) Name

func (p *Planet) Name() string

func (*Planet) OrbitalStarbase

func (p *Planet) OrbitalStarbase() *Starbase

type PlanetId

type PlanetId uint32

type PlanetState

type PlanetState struct {
	Planets map[PlanetId]*Planet `sgm:"planet"`
}

type Pop

type Pop struct {
	PlanetId  PlanetId  `sgm:"planet,id"`
	SpeciesId SpeciesId `sgm:"species,id"`
	Category  string    `sgm:"category"`
}

type PopId

type PopId uint32

type Sector

type Sector struct {
	NameString string `sgm:"name"`
	NameStruct struct {
		Key string `sgm:"key"`
	} `sgm:"name,struct"`

	Type  string    `sgm:"type"`
	Owner CountryId `sgm:"owner,id"`
}

func (*Sector) Name

func (s *Sector) Name() string

type SectorId

type SectorId uint32

type Ship

type Ship struct {
	FleetId FleetId `sgm:"fleet,id"`
	Fleet   *Fleet

	ArmyId ArmyId `sgm:"army,id"`
}

type ShipId

type ShipId uint32

type SpeciesId

type SpeciesId uint32

type Star

type Star struct {
	Type        string `sgm:"type"`
	NameString  string `sgm:"name"`
	NameStruct  Name   `sgm:"name,struct"`
	Initializer string `sgm:"initializer"`

	Coordinate Coordinate  `sgm:"coordinate"`
	Hyperlanes []Hyperlane `sgm:"hyperlane"`

	SectorId SectorId `sgm:"sector,id"`
	Sector   *Sector

	StarbaseId  StarbaseId   `sgm:"starbase,id"`
	StarbaseIds []StarbaseId `sgm:"starbases"`
	Starbases   []*Starbase

	PlanetIds []PlanetId `sgm:"planet"`
	Planets   []*Planet

	MegastructureIds []MegastructureId `sgm:"megastructures"`
	Megastructures   []*Megastructure

	WormholeIds []WormholeId `sgm:"natural_wormholes"`
	Wormholes   []*Wormhole

	FleetIds []FleetId `sgm:"fleet_presence"`
	Fleets   []*Fleet

	Battles []BattleRef
	// contains filtered or unexported fields
}

func (*Star) Bypasses

func (s *Star) Bypasses() (bypasses []string)

func (*Star) Colonies

func (s *Star) Colonies(isHabitat bool) (colonies []*Planet)

func (*Star) HasCapital

func (s *Star) HasCapital() bool

func (*Star) HasHyperRelay

func (s *Star) HasHyperRelay() bool

func (*Star) HasHyperlane

func (s *Star) HasHyperlane(dst *Star) bool

func (*Star) HasPops

func (s *Star) HasPops() bool

func (*Star) HasSignificantMegastructures

func (s *Star) HasSignificantMegastructures() bool

func (*Star) HasUpgradedStarbase

func (s *Star) HasUpgradedStarbase() bool

func (*Star) IsDistant

func (s *Star) IsDistant() bool

IsDistant returns true if star is from distant star pack (L-Galaxy)

func (*Star) IsOwnedBy

func (s *Star) IsOwnedBy(countryId CountryId) bool

func (*Star) IsSignificant

func (s *Star) IsSignificant() bool

func (*Star) MegastructuresBySize

func (s *Star) MegastructuresBySize(size int) (megastructures []*Megastructure)

func (*Star) MobileMilitaryFleets

func (s *Star) MobileMilitaryFleets() []*Fleet

func (*Star) Name

func (s *Star) Name() string

func (*Star) Occupier

func (s *Star) Occupier() CountryId

func (*Star) Owner

func (s *Star) Owner() CountryId

func (*Star) Point

func (s *Star) Point() sgmmath.Point

func (*Star) PrimaryStarbase

func (s *Star) PrimaryStarbase() *Starbase

type StarId

type StarId uint32

type Starbase

type Starbase struct {
	Level     string         `sgm:"level"`
	Modules   map[int]string `sgm:"modules"`
	Buildings map[int]string `sgm:"buildings"`
	Owner     CountryId      `sgm:"owner,id"`

	StationId ShipId `sgm:"station,id"`
	Station   *Ship

	Star *Star
}

func (*Starbase) Role

func (sb *Starbase) Role() StarbaseRole

type StarbaseId

type StarbaseId uint32

type StarbaseMgr

type StarbaseMgr struct {
	Starbases map[StarbaseId]*Starbase `sgm:"starbases"`
}

type StarbaseRole

type StarbaseRole int
const (
	StarbaseRoleShipyard StarbaseRole = iota
	StarbaseRoleBastion
	StarbaseRoleAnchorage
	StarbaseRoleTradingHub

	StarbaseRoleMax
)

func (StarbaseRole) String

func (role StarbaseRole) String() string

type Station

type Station struct {
	FleetId FleetId `sgm:"fleet"`
	Fleet   *Fleet
}

type StationId

type StationId uint32

type War

type War struct {
	StartDate Date `sgm:"start_date"`

	Defenders []WarCountry `sgm:"defenders"`
	Attackers []WarCountry `sgm:"attackers"`

	Battles []Battle `sgm:"battles"`
}

type WarCountry

type WarCountry struct {
	CountryId CountryId `sgm:"country,id"`
}

type WarId

type WarId uint32

type WarRef

type WarRef struct {
	WarId      WarId
	War        *War
	IsAttacker bool
}

type WarRole

type WarRole int
const (
	WarRoleStarNeutral WarRole = iota
	WarRoleStarDefender
	WarRoleStarAttacker

	WarRoleMax
)

func ComputeWarRole

func ComputeWarRole(countryId CountryId, country *Country, s *Star) WarRole

type Wormhole

type Wormhole struct {
	Bypass BypassId `sgm:"bypass"`
}

type WormholeId

type WormholeId uint32

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL