Documentation ¶
Index ¶
- Variables
- func WithColonies(colonies []*Colony) func(e *Engine) error
- type AssembleFactoryGroupOrder
- type AssembleMiningGroupOrder
- type AssemblyPhaseOrder
- type Colony
- type ControlColonyOrder
- type ControlPhaseOrder
- type ControlShipOrder
- type Coordinates
- type Engine
- func (e *Engine) Execute(pos []*PhaseOrders, phases ...string) error
- func (e *Engine) ExecuteAssemblyPhase(pos []*PhaseOrders) []error
- func (e *Engine) ExecuteControlPhase(pos []*PhaseOrders) []error
- func (e *Engine) ExecuteRetoolPhase(pos []*PhaseOrders) []error
- func (e *Engine) LoadGame(shortName string) error
- func (e *Engine) Report(w io.Writer, game string, nation, year, quarter int) error
- func (e *Engine) ReportWriter(game *models.Game, nationNo int, w io.Writer) error
- func (e *Engine) Version() string
- type FactoryGroup
- type Game
- type Inventory
- type MiningGroup
- type NameColonyOrder
- type NameShipOrder
- type Nation
- type NaturalResource
- type Option
- type PhaseOrders
- type Planet
- type Player
- type ReportTurns
- type RetoolFactoryGroupOrder
- type RetoolMiningGroupOrder
- type RetoolPhaseOrder
- type Ship
- type Skills
- type Star
- type System
- type Turn
- type TurnsIndex
- type XColony
- type XGroup
- type XGroupUnits
- type XPopulation
- type XShip
Constants ¶
This section is empty.
Variables ¶
var ErrDuplicateKey = errors.New("duplicate key")
var ErrInvalidField = errors.New("invalid field")
var ErrMissingField = errors.New("missing field")
var ErrNoConnection = errors.New("no connection")
var ErrNoEngine = errors.New("missing engine")
var ErrNoGame = errors.New("missing game")
var ErrNoNation = errors.New("missing nation")
var ErrNoStore = errors.New("missing store")
var ErrNoTurn = errors.New("missing turn")
var ErrNotImplemented = errors.New("not implemented")
Functions ¶
func WithColonies ¶
Types ¶
type AssemblyPhaseOrder ¶
type AssemblyPhaseOrder struct { FactoryGroup *AssembleFactoryGroupOrder MiningGroup *AssembleMiningGroupOrder }
type ControlColonyOrder ¶
type ControlColonyOrder struct {
Id string // id of colony to take control of
}
type ControlPhaseOrder ¶
type ControlPhaseOrder struct { ControlColony *ControlColonyOrder ControlShip *ControlShipOrder NameColony *NameColonyOrder NameShip *NameShipOrder }
type ControlShipOrder ¶
type ControlShipOrder struct {
Id string // id of ship to take control of
}
type Coordinates ¶
Coordinates are the x,y,z coordinates of a system
type Engine ¶
type Engine struct { Game *models.Game Colonies map[string]*Colony // key is id Ships map[string]*Ship // key is id // contains filtered or unexported fields }
func (*Engine) Execute ¶
func (e *Engine) Execute(pos []*PhaseOrders, phases ...string) error
Execute runs all the orders in the list of phases. If the list is empty, no phases will run.
func (*Engine) ExecuteAssemblyPhase ¶
func (e *Engine) ExecuteAssemblyPhase(pos []*PhaseOrders) []error
ExecuteAssemblyPhase runs all the orders in the assembly phase.
func (*Engine) ExecuteControlPhase ¶
func (e *Engine) ExecuteControlPhase(pos []*PhaseOrders) []error
ExecuteControlPhase runs all the orders in the control phase.
func (*Engine) ExecuteRetoolPhase ¶
func (e *Engine) ExecuteRetoolPhase(pos []*PhaseOrders) []error
ExecuteRetoolPhase runs all the orders in the retool phase.
func (*Engine) ReportWriter ¶
type FactoryGroup ¶
type FactoryGroup struct { Id int // key in database No int // factory group number BuildCode string BuildTechLevel int Units []*XGroupUnits }
type Game ¶
type Game struct { Id int ShortName string Name string Descr string Players []*Player CurrentTurn string // formatted as yyyy/q Turn int // index to current game turn Turns []*Turn Nations []*Nation Systems []*System }
Game configuration
type Inventory ¶
type Inventory struct { Name string `json:"name"` Code string `json:"code,omitempty"` TechLevel int `json:"tech-level,omitempty"` OperationalQty int `json:"operational-qty,omitempty"` StowedQty int `json:"stowed-qty,omitempty"` MassUnits int `json:"mass-units,omitempty"` EnclosedUnits int `json:"enclosed-units,omitempty"` }
type MiningGroup ¶
type MiningGroup struct { Id int // key in database No int // mining group number Deposit *NaturalResource Units []*XGroupUnits }
type NameColonyOrder ¶
type NameShipOrder ¶
type Nation ¶
type Nation struct { Id int // this is the PK in the database No int Name string Description string Speciality string Government struct { Kind string Name string } HomePlanet struct { Name string Location *Planet } TechLevel int ResearchPool int Skills Skills Colonies []*XColony Ships []*XShip ControlledBy *Player }
Nation configuration
type NaturalResource ¶
type PhaseOrders ¶
type PhaseOrders struct { Player *Player // orders sorted by phase Combat []*orders.Order SetUp []*orders.Order Disassembly []*orders.Order Retool []*RetoolPhaseOrder Transfer []*orders.Order Assembly []*AssemblyPhaseOrder Trade []*orders.Order Survey []*orders.Order Espionage []*orders.Order Movement []*orders.Order Draft []*orders.Order Pay []*orders.Order Ration []*orders.Order Control []*ControlPhaseOrder }
type ReportTurns ¶
type ReportTurns struct { Store string `json:"store"` // path to store data Index []TurnsIndex `json:"index"` }
ReportTurns configuration
func CreateTurns ¶
func CreateTurns(path string, overwrite bool) (*ReportTurns, error)
CreateTurns creates a new store. Assumes that the path to store the data already exists. It returns any errors.
func LoadTurns ¶
func LoadTurns(path string) (*ReportTurns, error)
LoadTurns loads an existing store. It returns any errors.
func (*ReportTurns) Read ¶
func (s *ReportTurns) Read() error
Read loads a store from a JSON file. It returns any errors.
func (*ReportTurns) Write ¶
func (s *ReportTurns) Write() error
Write writes a store to a JSON file. It returns any errors.
type RetoolFactoryGroupOrder ¶
type RetoolMiningGroupOrder ¶
type RetoolPhaseOrder ¶
type RetoolPhaseOrder struct { FactoryGroup *RetoolFactoryGroupOrder MiningGroup *RetoolMiningGroupOrder }
type TurnsIndex ¶
type TurnsIndex struct {
Id int `json:"id"` // unique turn number
}
type XColony ¶
type XColony struct { Id int // key for database No int Name string Kind string Location *Planet TechLevel int Population struct { Professional XPopulation Soldier XPopulation Unskilled XPopulation Unemployed XPopulation ConstructionCrews int SpyTeams int RebelPct float64 Births int Deaths int } Hull []*Inventory // units used to build colony Inventory []*Inventory // units stored in colony FactoryGroups []*FactoryGroup FarmGroups []*XGroup MiningGroups []*MiningGroup }
type XGroup ¶
type XGroup struct { Id int Name string Units []*XGroupUnits }
type XGroupUnits ¶
type XShip ¶
type XShip struct { Id int // key for database No int Name string Kind string Location *Planet TechLevel int Population struct { Professional XPopulation Soldier XPopulation Unskilled XPopulation Unemployed XPopulation ConstructionCrews int SpyTeams int RebelPct float64 } Hull []*Inventory // units used to build ship Inventory []*Inventory // units stored in ship FactoryGroups []*FactoryGroup FarmGroups []*XGroup }