server

package
v0.0.0-...-b9fa8cb Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	Radius  int       `json:"radius"`
	Systems []*System `json:"systems"`
}

type Colony

type Colony struct {
	Id       int    `json:"colony-id"`
	Kind     string `json:"kind"`
	Location struct {
		X     int `json:"x"`
		Y     int `json:"y"`
		Z     int `json:"z"`
		Star  int `json:"star,omitempty"`
		Orbit int `json:"orbit"`
	} `json:"location"`
	TechLevel  int `json:"tech-level"`
	Population struct {
		Professional      Population `json:"professional"`
		Soldier           Population `json:"soldier"`
		Unskilled         Population `json:"unskilled"`
		Unemployed        Population `json:"unemployed"`
		ConstructionCrews int        `json:"construction-crews,omitempty"`
		SpyTeams          int        `json:"spy-teams,omitempty"`
		Births            int        `json:"births,omitempty"`
		Deaths            int        `json:"deaths,omitempty"`
	} `json:"population"`
	Inventory     []*Inventory `json:"inventory,omitempty"`
	FactoryGroups []*Group     `json:"factory-groups,omitempty"`
	FarmGroups    []*Group     `json:"farm-groups,omitempty"`
	MiningGroups  []*Group     `json:"mining-groups,omitempty"`
}

func (*Colony) TotalPay

func (c *Colony) TotalPay() int

func (*Colony) TotalPopulation

func (c *Colony) TotalPopulation() int

func (*Colony) TotalRation

func (c *Colony) TotalRation() int

type Game

type Game struct {
	Id      string    `json:"id"`
	Turn    int       `json:"turn"`
	Nations []*Nation `json:"nations,omitempty"`
	Cluster *Cluster  `json:"cluster,omitempty"`
}

type Group

type Group struct {
	Id    int           `json:"group-id,omitempty"`
	Name  string        `json:"name,omitempty"`
	Units []*GroupUnits `json:"units,omitempty"`
}

type GroupUnits

type GroupUnits struct {
	TechLevel int   `json:"tech-level,omitempty"`
	Qty       int   `json:"qty,omitempty"`
	Stages    []int `json:"stages,omitempty"`
}

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"`
}

func (Inventory) EnclosedMassUnits

func (u Inventory) EnclosedMassUnits() int

func (Inventory) MassUnits

func (u Inventory) MassUnits() int

type Nation

type Nation struct {
	Id         int    `json:"nation-id"`
	Name       string `json:"name"`
	Speciality string `json:"speciality"`
	Government struct {
		Kind string `json:"kind"`
		Name string `json:"name"`
	} `json:"government"`
	HomePlanet struct {
		Name     string `json:"name"`
		Location struct {
			X     int `json:"x"`
			Y     int `json:"y"`
			Z     int `json:"z"`
			Star  int `json:"star,omitempty"`
			Orbit int `json:"orbit"`
		} `json:"location"`
	} `json:"home-planet"`
	Skills   Skills    `json:"skills"`
	Colonies []*Colony `json:"colonies,omitempty"`
}

type NaturalResource

type NaturalResource struct {
	Id                int     `json:"natural-resource-id,omitempty"`
	Kind              string  `json:"kind,omitempty"`
	Yield             float64 `json:"yield,omitempty"`
	InitialQuantity   int     `json:"initial-quantity,omitempty"`
	QuantityRemaining int     `json:"quantity-remaining,omitempty"`
}

type Option

type Option func(*Server) error

func Options

func Options(opts ...Option) Option

Options turns a list of Option instances into an Option.

func WithAuthenticationData

func WithAuthenticationData(root string) Option

func WithGame

func WithGame(filename string) Option

func WithHost

func WithHost(host string) Option

func WithJwtData

func WithJwtData(root string) Option

func WithMaxBodyLength

func WithMaxBodyLength(l int) Option

func WithPort

func WithPort(port string) Option

func WithReadTimeout

func WithReadTimeout(d time.Duration) Option

func WithWriteTimeout

func WithWriteTimeout(d time.Duration) Option

type Planet

type Planet struct {
	Id                 int                `json:"planet-id,omitempty"`
	Orbit              int                `json:"orbit,omitempty"`
	Kind               string             `json:"kind"`
	HomePlanet         bool               `json:"home-planet,omitempty"`
	HabitabilityNumber int                `json:"habitability-number,omitempty"`
	Deposits           []*NaturalResource `json:"deposits,omitempty"`
}

type Population

type Population struct {
	Code   string  `json:"code,omitempty"`
	Qty    int     `json:"qty,omitempty"`
	Pay    float64 `json:"pay,omitempty"`
	Ration float64 `json:"ration,omitempty"`
}

func (*Population) TotalPay

func (p *Population) TotalPay() int

TotalPay assumes that the base rates are per unit of population

PROFESSIONAL      0.375 CONSUMER GOODS
SOLDIER           0.250 CONSUMER GOODS
UNSKILLED WORKER  0.125 CONSUMER GOODS
UNEMPLOYABLE      0.000 CONSUMER GOODS

func (*Population) TotalPopulation

func (p *Population) TotalPopulation() int

func (*Population) TotalRation

func (p *Population) TotalRation() int

TotalRation assumes that base ration is 0.25 food units per unit of population

type Server

type Server struct {
	http.Server
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) (*Server, error)

func (*Server) Mux

func (s *Server) Mux() http.Handler

type Skills

type Skills struct {
	Biology       int `json:"biology"`
	Bureaucracy   int `json:"bureaucracy"`
	Gravitics     int `json:"gravitics"`
	LifeSupport   int `json:"life-support"`
	Manufacturing int `json:"manufacturing"`
	Military      int `json:"military"`
	Mining        int `json:"mining"`
	Shields       int `json:"shields"`
}

type Star

type Star struct {
	Id       int       `json:"star-id,omitempty"`
	Kind     string    `json:"kind,omitempty"`
	HomeStar bool      `json:"home-star,omitempty"`
	Orbits   []*Planet `json:"orbits,omitempty"`
}

type System

type System struct {
	Id          int     `json:"system-id,omitempty"`
	X           int     `json:"x"`
	Y           int     `json:"y"`
	Z           int     `json:"z"`
	HomeSystem  bool    `json:"home-system,omitempty"`
	Singularity bool    `json:"singularity,omitempty"`
	Ring        int     `json:"ring,omitempty"`
	Stars       []*Star `json:"stars,omitempty"`
}

Jump to

Keyboard shortcuts

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