Documentation ¶
Index ¶
- Variables
- type CSDetail
- type CSHull
- type CSInventory
- type CSLocation
- type CSPay
- type CSPopulation
- type CSRations
- type Claim
- type ColonyOrShip
- type Coordinates
- type FactoryGroup
- type FactoryGroupStages
- type FactoryGroupUnits
- type FarmGroup
- type FarmGroupStages
- type FarmGroupUnits
- type Game
- type GameClaim
- type MiningGroup
- type MiningGroupStages
- type MiningGroupUnits
- type Nation
- type NationDetail
- type NationResearch
- type NationSkills
- type NaturalResource
- type NaturalResourceDetail
- type Planet
- type PlanetDetail
- type Player
- type PlayerDetail
- type PlayerPosition
- type Star
- type Store
- func (s *Store) AddSystem(g Game, x, y, z int) (System, error)
- func (s *Store) Close()
- func (s *Store) CreateGame(g *Game) error
- func (s *Store) CreateUnit(code, name, descr string, usesTech bool) error
- func (s *Store) CreateUser(displayHandle, handle, email, secret string) error
- func (s *Store) DeleteGame(id int) error
- func (s *Store) DeleteGameByName(shortName string) error
- func (s *Store) FetchClaims(asOfTurn string) (map[string]*Claim, error)
- func (s *Store) FetchClusterListByGame(gameId int) ([]*SystemScan, error)
- func (s *Store) FetchCurrentTurn(userHandle, gameName string) (*Turn, error)
- func (s *Store) FetchGame(id int) (*Game, error)
- func (s *Store) FetchGameByName(name string) (*Game, error)
- func (s *Store) FetchGameByNameAsOf(name string, asOfTurn string) (*Game, error)
- func (s *Store) FetchUnits() []*Unit
- func (s *Store) FetchUser(id int) (*User, error)
- func (s *Store) FetchUserByCredentials(handle, secret string) (*User, error)
- func (s *Store) FetchUserByEmail(email string) (*User, error)
- func (s *Store) FetchUserByHandle(handle string) (*User, error)
- func (s *Store) FetchUserClaimAsOf(id int, asOf time.Time) (*UserClaim, error)
- func (s *Store) FetchUserClaimsFromGameAsOf(id int, asOf time.Time) ([]*UserClaim, error)
- func (s *Store) GenerateGame(shortName, name, descr string, radius int, startDt time.Time, ...) (*Game, error)
- func (s *Store) GetDB() *sql.DB
- func (s *Store) LookupGame(id int) (*Game, error)
- func (s *Store) LookupGameByName(name string) (*Game, error)
- func (s *Store) OrdersPath() string
- func (s *Store) Ping() error
- func (s *Store) SaveGame(game *Game) error
- func (s *Store) UpdateUserSecret(id int, secret string) error
- func (s *Store) Version() string
- type System
- type SystemScan
- type Turn
- type Unit
- type User
- type UserClaim
- type UserProfile
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 ErrNoDataFound = errors.New("no data found")
var ErrNotImplemented = errors.New("not implemented")
Functions ¶
This section is empty.
Types ¶
type CSDetail ¶
type CSDetail struct { CS *ColonyOrShip EffTurn *Turn // turn record becomes active EndTurn *Turn // turn record ceases to be active Name string TechLevel int ControlledBy *Player }
CSDetail contains items that may change from turn to turn
type CSHull ¶
type CSHull struct { CS *ColonyOrShip EffTurn *Turn // turn record becomes active EndTurn *Turn // turn record ceases to be active Unit *Unit TechLevel int QtyOperational int MassOperational int TotalMass int }
CSHull is the infrastructure and components of the ship or colony. Colonies are not allowed to add engines or drives to their hull.
type CSInventory ¶
type CSInventory struct { CS *ColonyOrShip EffTurn *Turn // turn record becomes active EndTurn *Turn // turn record ceases to be active Unit *Unit TechLevel int QtyOperational int MassOperational int QtyStowed int MassStowed int TotalMass int EnclosedMass int }
CSInventory is the contents of the ship or colony.
type CSLocation ¶
type CSLocation struct { CS *ColonyOrShip EffTurn *Turn // turn record becomes active EndTurn *Turn // turn record ceases to be active Location *Planet }
CSLocation is the location of the colony or ship and may change from turn to turn
type CSPay ¶
type CSPay struct { CS *ColonyOrShip EffTurn *Turn // turn record becomes active EndTurn *Turn // turn record ceases to be active ProfessionalPct float64 SoldierPct float64 UnskilledPct float64 UnemployedPct float64 }
CSPay is the pay rate for the ship or colony.
type CSPopulation ¶
type CSPopulation struct { CS *ColonyOrShip EffTurn *Turn // turn record becomes active EndTurn *Turn // turn record ceases to be active QtyProfessional int QtySoldier int QtyUnskilled int QtyUnemployed int QtyConstructionCrew int QtySpyTeam int RebelPct float64 Births int Deaths int }
CSPopulation is the population of the ship or colony.
type CSRations ¶
type CSRations struct { CS *ColonyOrShip EffTurn *Turn // turn record becomes active EndTurn *Turn // turn record ceases to be active ProfessionalPct float64 SoldierPct float64 UnskilledPct float64 UnemployedPct float64 }
CSRations is the rations rate for the ship or colony.
type ColonyOrShip ¶
type ColonyOrShip struct { Game *Game Planet *Planet Id int // unique identifier MSN int // manufacturer serial number; in game id for the colony or ship Kind string // surface colony, enclosed colony, orbital colony, ship HomeColony bool BuiltBy *Nation Details []*CSDetail Locations []*CSLocation Hull []*CSHull Inventory []*CSInventory Population []*CSPopulation Rations []*CSRations Pay []*CSPay Factories []*FactoryGroup Farms []*FarmGroup Mines []*MiningGroup }
ColonyOrShip is either a colony or a ship. Ships may change orbits; colonies may not.
type Coordinates ¶
Coordinates are the x,y,z coordinates of a system
func (Coordinates) Less ¶
func (c Coordinates) Less(d Coordinates) bool
func (Coordinates) String ¶
func (c Coordinates) String() string
type FactoryGroup ¶
type FactoryGroup struct { CS *ColonyOrShip Id int // unique identifier No int EffTurn *Turn // turn record becomes active EndTurn *Turn // turn record ceases to be active Unit *Unit // unit being manufactured Units []*FactoryGroupUnits // factory units in the group Stages []*FactoryGroupStages }
FactoryGroup is a group of factories on the ship or colony. Each group is dedicated to manufacturing one type of unit.
type FactoryGroupStages ¶
type FactoryGroupStages struct { Group *FactoryGroup Turn *Turn QtyStage1 int QtyStage2 int QtyStage3 int QtyStage4 int }
FactoryGroupStages is the number units in each stage of the group
type FactoryGroupUnits ¶
type FactoryGroupUnits struct { Group *FactoryGroup EffTurn *Turn // turn record becomes active EndTurn *Turn // turn record ceases to be active Unit *Unit // factory unit doing the manufacturing QtyOperational int }
FactoryGroupUnits is the number of factories working together in the group
type FarmGroup ¶
type FarmGroup struct { CS *ColonyOrShip Id int // unique identifier No int EffTurn *Turn // turn record becomes active EndTurn *Turn // turn record ceases to be active Unit *Unit // unit being farmed Units []*FarmGroupUnits // farm units in the group Stages []*FarmGroupStages }
FarmGroup is a group of farms on the ship or colony.
type FarmGroupStages ¶
type FarmGroupStages struct { Group *FarmGroup Turn *Turn QtyStage1 int QtyStage2 int QtyStage3 int QtyStage4 int }
FarmGroupStages is the number units in each stage of the group
type FarmGroupUnits ¶
type FarmGroupUnits struct { Group *FarmGroup EffTurn *Turn // turn record becomes active EndTurn *Turn // turn record ceases to be active Unit *Unit // farm unit QtyOperational int }
FarmGroupUnits is the number of farms working together in the group
type Game ¶
type Game struct { Id int // unique identifier ShortName string Name string Description string CurrentTurn *Turn Colonies map[int]*ColonyOrShip CorS map[int]*ColonyOrShip Nations map[int]*Nation Planets map[int]*Planet Players map[int]*Player Resources map[int]*NaturalResource Ships map[int]*ColonyOrShip Stars map[int]*Star Systems map[int]*System Turns map[string]*Turn Units map[int]*Unit Users map[int]*User }
Game is a single game
func (*Game) AllColonies ¶
func (g *Game) AllColonies() []*ColonyOrShip
func (*Game) AllShips ¶
func (g *Game) AllShips() []*ColonyOrShip
type GameClaim ¶
type GameClaim struct { Id int // game id ShortName string // game code EffTurn *Turn // game's turn that is effective as of the claim date PlayerId int // player id PlayerHandle string // player handle in game NationId int // nation id NationNo int // nation player is aligned with NationName string // nation government name }
type MiningGroup ¶
type MiningGroup struct { CS *ColonyOrShip Id int // unique identifier No int EffTurn *Turn // turn record becomes active EndTurn *Turn // turn record ceases to be active Deposit *NaturalResource Units []*MiningGroupUnits // mine units in the group Stages []*MiningGroupStages }
MiningGroup is a group of mines working a single deposit.
type MiningGroupStages ¶
type MiningGroupStages struct { Group *MiningGroup Turn *Turn QtyStage1 int QtyStage2 int QtyStage3 int QtyStage4 int }
MiningGroupStages is the number units in each stage of the group
type MiningGroupUnits ¶
type MiningGroupUnits struct { Group *MiningGroup EffTurn *Turn // turn record becomes active EndTurn *Turn // turn record ceases to be active Unit *Unit // unit mining QtyOperational int }
MiningGroupUnits is the number of mines working together in the group
type Nation ¶
type Nation struct { Game *Game Id int // unique identifier No int // nation number in the game, starts at 1 HomePlanet *Planet Speciality string Description string Details []*NationDetail Research []*NationResearch Skills []*NationSkills Player *Player // player currently controlling the nation CorS []*ColonyOrShip Colonies []*ColonyOrShip Ships []*ColonyOrShip Players []*Player }
Nation is a single nation in the game. The "ruler" of the nation controls it, but may create viceroys or regents to control ships and colonies in the nation.
type NationDetail ¶
type NationDetail struct { Nation *Nation EffTurn *Turn // turn record becomes active EndTurn *Turn // turn record ceases to be active Name string GovtName string GovtKind string ControlledBy *Player }
NationDetail is items that can change value during the game.
type NationResearch ¶
type NationResearch struct { Nation *Nation EffTurn *Turn // turn record becomes active EndTurn *Turn // turn record ceases to be active TechLevel int // ResearchPointsPool int // }
NationResearch is the tech level and research level of the nation.
type NationSkills ¶
type NationSkills struct { Nation *Nation EffTurn *Turn // turn record becomes active EndTurn *Turn // turn record ceases to be active Biology int // not used currently Bureaucracy int // not used currently Gravitics int // not used currently LifeSupport int // not used currently Manufacturing int // not used currently Military int // not used currently Mining int // not used currently Shields int // not used currently }
NationSkills are the skills and tech levels of the nation.
type NaturalResource ¶
type NaturalResource struct { Planet *Planet Id int // unique identifier No int // number of deposit on planet Unit *Unit // fuel, gold, metallic, non-metallic QtyInitial int // in mass units YieldPct float64 // percentage of each mass unit that yields units Details []*NaturalResourceDetail }
NaturalResource is a deposit of fuel, gold, metal, or non-metals on a planet
type NaturalResourceDetail ¶
type NaturalResourceDetail struct { NaturalResource *NaturalResource EffTurn *Turn // turn record becomes active EndTurn *Turn // turn record ceases to be active ControlledBy *Nation // nation currently controlling the resource QtyRemaining int // in mass units }
NaturalResourceDetail contains items that change from turn to turn
type Planet ¶
type Planet struct { Star *Star Id int // unique identifier OrbitNo int // 1..10 Kind string // asteroid belt, gas giant, terrestrial HomePlanet bool Deposits []*NaturalResource Details []*PlanetDetail Colonies []*ColonyOrShip // colonies on or orbiting the planet Ships []*ColonyOrShip // ships orbiting the planet }
Planet is a non-empty orbit.
type PlanetDetail ¶
type PlanetDetail struct { Planet *Planet EffTurn *Turn // turn record becomes active EndTurn *Turn // turn record ceases to be active ControlledBy *Nation // nation currently controlling the planet HabitabilityNo int }
PlanetDetail contains items that change from turn to turn
type Player ¶
type Player struct { Game *Game Id int MemberOf *Nation Details []*PlayerDetail }
Player is a User's position in a Game
type PlayerDetail ¶
type PlayerDetail struct { Player *Player EffTurn *Turn // turn record becomes active EndTurn *Turn // turn record ceases to be active Handle string ControlledBy *User SubjectOf *Player // set if the player is a viceroy or regent }
PlayerDetail is the handle of the player in the game
type PlayerPosition ¶
type PlayerPosition struct { Id int UserHandle string PlayerHandle string Nation struct { Name string Speciality string HomeWorld string GovtKind string GovtName string } }
PlayerPosition maps json data into our users and players tables
type Star ¶
type Star struct { System *System Id int // unique identifier Sequence string // A, B, etc Kind string HomeStar bool Orbits []*Planet // each orbit may or may not contain a planet }
Star is a stellar system in the game. It contains zero or more planets, with each planet assigned to an orbit ranging from 1...10
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) CreateGame ¶
CreateGame adds a new game to the store if it passes validation
func (*Store) CreateUnit ¶
func (*Store) CreateUser ¶
CreateUser adds a new user to the store if it passes validation
func (*Store) DeleteGame ¶
DeleteGame removes a game from the store.
func (*Store) DeleteGameByName ¶
DeleteGameByName removes a game from the store.
func (*Store) FetchClusterListByGame ¶
func (s *Store) FetchClusterListByGame(gameId int) ([]*SystemScan, error)
func (*Store) FetchCurrentTurn ¶
func (*Store) FetchGameByName ¶
FetchGameByName does just that
func (*Store) FetchGameByNameAsOf ¶
FetchGameByNameAsOf fetches a game by name and turn
func (*Store) FetchUnits ¶
func (*Store) FetchUserByCredentials ¶
func (*Store) FetchUserByEmail ¶
FetchUserByEmail returns the user that matches the email
func (*Store) FetchUserClaimAsOf ¶
func (*Store) FetchUserClaimsFromGameAsOf ¶
func (*Store) GenerateGame ¶
func (*Store) LookupGame ¶
LookupGame looks up a game by id
func (*Store) LookupGameByName ¶
LookupGameByName does just that
func (*Store) OrdersPath ¶
type System ¶
type System struct { Game *Game Id int // unique identifier Coords Coordinates HomeSystem bool Ring int // ring is light years from the origin Stars []*Star }
System is a system in the game. It contains zero or more stars.
type Turn ¶
type Turn struct { No int // 0+ Year int // 1...9999 Quarter int // 1...4 StartDt time.Time // moment turn starts EndDt time.Time // moment turn ends }
Turn is a single turn in the game
type Unit ¶
type Unit struct { Id int // unique identifier Code string TechLevel int Name string Description string MassPerUnit float64 // mass (in mass units) of a single unit VolumePerUnit float64 // volume (in enclosed mass units) of a single unit Hudnut bool // true if unit can be disassembled for storage StowedVolumePerUnit float64 // half mass if unit is hudnut }
Unit is a thing in the game.
type User ¶
type User struct { Id int // unique identifier Handle string // unique handle, forced to lower-case HashedSecret string Profiles []*UserProfile }
User is the person who owns the account used to access the game