stycoon

package
v0.0.0-...-aa25481 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const PlayerIdField = "playerId"
View Source
const SeasonField = "season"
View Source
const SessionKey = "SESSION_ID"
View Source
const TickDuration = time.Second
View Source
const UsernameField = "username"

Variables

View Source
var (
	// ErrTypeAssertionError is thrown when type an interface does not match the asserted type
	ErrTypeAssertionError = errors.New("unable to assert type")
)

Functions

func AssertAttackCommandRequired

func AssertAttackCommandRequired(obj AttackCommand) error

AssertAttackCommandRequired checks if the required fields are not zero-ed

func AssertCombatRequired

func AssertCombatRequired(obj Combat) error

AssertCombatRequired checks if the required fields are not zero-ed

func AssertCommandRequired

func AssertCommandRequired(obj Command) error

AssertCommandRequired checks if the required fields are not zero-ed

func AssertConstructCommandRequired

func AssertConstructCommandRequired(obj ConstructCommand) error

AssertConstructCommandRequired checks if the required fields are not zero-ed

func AssertCredentialsRequired

func AssertCredentialsRequired(obj Credentials) error

AssertCredentialsRequired checks if the required fields are not zero-ed

func AssertCurrentTickRequired

func AssertCurrentTickRequired(obj CurrentTick) error

AssertCurrentTickRequired checks if the required fields are not zero-ed

func AssertDataReportsRequired

func AssertDataReportsRequired(obj DataReports) error

AssertDataReportsRequired checks if the required fields are not zero-ed

func AssertDataRequired

func AssertDataRequired(obj Data) error

AssertDataRequired checks if the required fields are not zero-ed

func AssertDecommissionCommandRequired

func AssertDecommissionCommandRequired(obj DecommissionCommand) error

AssertDecommissionCommandRequired checks if the required fields are not zero-ed

func AssertDestinationRequired

func AssertDestinationRequired(obj Destination) error

AssertDestinationRequired checks if the required fields are not zero-ed

func AssertEndTurnRequired

func AssertEndTurnRequired(obj EndTurn) error

AssertEndTurnRequired checks if the required fields are not zero-ed

func AssertErrorRequired

func AssertErrorRequired(obj Error) error

AssertErrorRequired checks if the required fields are not zero-ed

func AssertMoveCommandRequired

func AssertMoveCommandRequired(obj MoveCommand) error

AssertMoveCommandRequired checks if the required fields are not zero-ed

func AssertNetWorthRequired

func AssertNetWorthRequired(obj NetWorth) error

AssertNetWorthRequired checks if the required fields are not zero-ed

func AssertPlanetRequired

func AssertPlanetRequired(obj Planet) error

AssertPlanetRequired checks if the required fields are not zero-ed

func AssertPlayerIdRequired

func AssertPlayerIdRequired(obj PlayerId) error

AssertPlayerIdRequired checks if the required fields are not zero-ed

func AssertPlayerRequired

func AssertPlayerRequired(obj Player) error

AssertPlayerRequired checks if the required fields are not zero-ed

func AssertProfilingRequired

func AssertProfilingRequired(obj Profiling) error

AssertProfilingRequired checks if the required fields are not zero-ed

func AssertRecurseAttackCommandRequired

func AssertRecurseAttackCommandRequired(objSlice interface{}) error

AssertRecurseAttackCommandRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of AttackCommand (e.g. [][]AttackCommand), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseCombatRequired

func AssertRecurseCombatRequired(objSlice interface{}) error

AssertRecurseCombatRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Combat (e.g. [][]Combat), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseCommandRequired

func AssertRecurseCommandRequired(objSlice interface{}) error

AssertRecurseCommandRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Command (e.g. [][]Command), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseConstructCommandRequired

func AssertRecurseConstructCommandRequired(objSlice interface{}) error

AssertRecurseConstructCommandRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of ConstructCommand (e.g. [][]ConstructCommand), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseCredentialsRequired

func AssertRecurseCredentialsRequired(objSlice interface{}) error

AssertRecurseCredentialsRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Credentials (e.g. [][]Credentials), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseCurrentTickRequired

func AssertRecurseCurrentTickRequired(objSlice interface{}) error

AssertRecurseCurrentTickRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of CurrentTick (e.g. [][]CurrentTick), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseDataReportsRequired

func AssertRecurseDataReportsRequired(objSlice interface{}) error

AssertRecurseDataReportsRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of DataReports (e.g. [][]DataReports), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseDataRequired

func AssertRecurseDataRequired(objSlice interface{}) error

AssertRecurseDataRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Data (e.g. [][]Data), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseDecommissionCommandRequired

func AssertRecurseDecommissionCommandRequired(objSlice interface{}) error

AssertRecurseDecommissionCommandRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of DecommissionCommand (e.g. [][]DecommissionCommand), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseDestinationRequired

func AssertRecurseDestinationRequired(objSlice interface{}) error

AssertRecurseDestinationRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Destination (e.g. [][]Destination), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseEndTurnRequired

func AssertRecurseEndTurnRequired(objSlice interface{}) error

AssertRecurseEndTurnRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of EndTurn (e.g. [][]EndTurn), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseErrorRequired

func AssertRecurseErrorRequired(objSlice interface{}) error

AssertRecurseErrorRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Error (e.g. [][]Error), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseInterfaceRequired

func AssertRecurseInterfaceRequired(obj interface{}, callback func(interface{}) error) error

AssertRecurseInterfaceRequired recursively checks each struct in a slice against the callback. This method traverse nested slices in a preorder fashion.

func AssertRecurseMoveCommandRequired

func AssertRecurseMoveCommandRequired(objSlice interface{}) error

AssertRecurseMoveCommandRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of MoveCommand (e.g. [][]MoveCommand), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseNetWorthRequired

func AssertRecurseNetWorthRequired(objSlice interface{}) error

AssertRecurseNetWorthRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of NetWorth (e.g. [][]NetWorth), otherwise ErrTypeAssertionError is thrown.

func AssertRecursePlanetRequired

func AssertRecursePlanetRequired(objSlice interface{}) error

AssertRecursePlanetRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Planet (e.g. [][]Planet), otherwise ErrTypeAssertionError is thrown.

func AssertRecursePlayerIdRequired

func AssertRecursePlayerIdRequired(objSlice interface{}) error

AssertRecursePlayerIdRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of PlayerId (e.g. [][]PlayerId), otherwise ErrTypeAssertionError is thrown.

func AssertRecursePlayerRequired

func AssertRecursePlayerRequired(objSlice interface{}) error

AssertRecursePlayerRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Player (e.g. [][]Player), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseProfilingRequired

func AssertRecurseProfilingRequired(objSlice interface{}) error

AssertRecurseProfilingRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Profiling (e.g. [][]Profiling), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseRenameCommandRequired

func AssertRecurseRenameCommandRequired(objSlice interface{}) error

AssertRecurseRenameCommandRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of RenameCommand (e.g. [][]RenameCommand), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseRepairCommandRequired

func AssertRecurseRepairCommandRequired(objSlice interface{}) error

AssertRecurseRepairCommandRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of RepairCommand (e.g. [][]RepairCommand), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseReportsRequired

func AssertRecurseReportsRequired(objSlice interface{}) error

AssertRecurseReportsRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Reports (e.g. [][]Reports), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseResourceRequired

func AssertRecurseResourceRequired(objSlice interface{}) error

AssertRecurseResourceRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Resource (e.g. [][]Resource), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseScoreValueRequired

func AssertRecurseScoreValueRequired(objSlice interface{}) error

AssertRecurseScoreValueRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of ScoreValue (e.g. [][]ScoreValue), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseShipClassRequired

func AssertRecurseShipClassRequired(objSlice interface{}) error

AssertRecurseShipClassRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of ShipClass (e.g. [][]ShipClass), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseShipRequired

func AssertRecurseShipRequired(objSlice interface{}) error

AssertRecurseShipRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Ship (e.g. [][]Ship), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseStaticDataRequired

func AssertRecurseStaticDataRequired(objSlice interface{}) error

AssertRecurseStaticDataRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of StaticData (e.g. [][]StaticData), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseTradeCommandRequired

func AssertRecurseTradeCommandRequired(objSlice interface{}) error

AssertRecurseTradeCommandRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of TradeCommand (e.g. [][]TradeCommand), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseTradeRequired

func AssertRecurseTradeRequired(objSlice interface{}) error

AssertRecurseTradeRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Trade (e.g. [][]Trade), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseTradingResourceAllOfRequired

func AssertRecurseTradingResourceAllOfRequired(objSlice interface{}) error

AssertRecurseTradingResourceAllOfRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of TradingResourceAllOf (e.g. [][]TradingResourceAllOf), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseTradingResourceRequired

func AssertRecurseTradingResourceRequired(objSlice interface{}) error

AssertRecurseTradingResourceRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of TradingResource (e.g. [][]TradingResource), otherwise ErrTypeAssertionError is thrown.

func AssertRecurseValueRequired

func AssertRecurseValueRequired(value reflect.Value, callback func(interface{}) error) error

AssertRecurseValueRequired checks each struct in the nested slice against the callback. This method traverse nested slices in a preorder fashion.

func AssertRecurseWreckRequired

func AssertRecurseWreckRequired(objSlice interface{}) error

AssertRecurseWreckRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of Wreck (e.g. [][]Wreck), otherwise ErrTypeAssertionError is thrown.

func AssertRenameCommandRequired

func AssertRenameCommandRequired(obj RenameCommand) error

AssertRenameCommandRequired checks if the required fields are not zero-ed

func AssertRepairCommandRequired

func AssertRepairCommandRequired(obj RepairCommand) error

AssertRepairCommandRequired checks if the required fields are not zero-ed

func AssertReportsRequired

func AssertReportsRequired(obj Reports) error

AssertReportsRequired checks if the required fields are not zero-ed

func AssertResourceRequired

func AssertResourceRequired(obj Resource) error

AssertResourceRequired checks if the required fields are not zero-ed

func AssertScoreValueRequired

func AssertScoreValueRequired(obj ScoreValue) error

AssertScoreValueRequired checks if the required fields are not zero-ed

func AssertShipClassRequired

func AssertShipClassRequired(obj ShipClass) error

AssertShipClassRequired checks if the required fields are not zero-ed

func AssertShipRequired

func AssertShipRequired(obj Ship) error

AssertShipRequired checks if the required fields are not zero-ed

func AssertStaticDataRequired

func AssertStaticDataRequired(obj StaticData) error

AssertStaticDataRequired checks if the required fields are not zero-ed

func AssertTradeCommandRequired

func AssertTradeCommandRequired(obj TradeCommand) error

AssertTradeCommandRequired checks if the required fields are not zero-ed

func AssertTradeRequired

func AssertTradeRequired(obj Trade) error

AssertTradeRequired checks if the required fields are not zero-ed

func AssertTradingResourceAllOfRequired

func AssertTradingResourceAllOfRequired(obj TradingResourceAllOf) error

AssertTradingResourceAllOfRequired checks if the required fields are not zero-ed

func AssertTradingResourceRequired

func AssertTradingResourceRequired(obj TradingResource) error

AssertTradingResourceRequired checks if the required fields are not zero-ed

func AssertWreckRequired

func AssertWreckRequired(obj Wreck) error

AssertWreckRequired checks if the required fields are not zero-ed

func HashPassword

func HashPassword(password string) (string, error)

func IsPasswordValid

func IsPasswordValid(hash string, pass string) error

func IsZeroValue

func IsZeroValue(val interface{}) bool

IsZeroValue checks if the val is the zero-ed value.

func MaybeGetLoggedPlayerId

func MaybeGetLoggedPlayerId(req *http.Request, sessionManager sessions.Store) *string

func ParseCommands

func ParseCommands(s string) (map[string]Command, error)

func SeasonChanged

func SeasonChanged(game *Game, req *http.Request, sessionManager sessions.Store) bool

Types

type AttackCommand

type AttackCommand struct {
	Target *string `json:"target"`

	Type string `json:"type,omitempty"`
}

func NewAttackCommand

func NewAttackCommand(command Command) *AttackCommand

type Combat

type Combat struct {
	Tick int64 `json:"tick,omitempty"`

	Attacker string `json:"attacker,omitempty"`

	Defender string `json:"defender,omitempty"`

	Killed bool `json:"killed,omitempty"`
}

type Command

type Command struct {
	Type string `json:"type"`

	Target *string `json:"target,omitempty"`

	Destination *Destination `json:"destination,omitempty"`

	Resource *string `json:"resource,omitempty"`

	Amount *int64 `json:"amount,omitempty"`

	ShipClass *string `json:"shipClass,omitempty"`

	Name *string `json:"name,omitempty"`
}

type ConstructCommand

type ConstructCommand struct {
	ShipClass *string `json:"shipClass"`

	Type string `json:"type,omitempty"`
}

func NewConstructCommand

func NewConstructCommand(command Command) *ConstructCommand

type Credentials

type Credentials struct {
	Username string `json:"username"`

	Password string `json:"password"`
}

type CurrentTick

type CurrentTick struct {
	Tick int64 `json:"tick"`

	MinTimeLeftMs int64 `json:"minTimeLeftMs"`

	Season int64 `json:"season"`
}

type Data

type Data struct {
	CurrentTick CurrentTick `json:"currentTick"`

	Planets map[string]Planet `json:"planets"`

	PlayerId *string `json:"playerId,omitempty"`

	Players map[string]Player `json:"players"`

	Ships map[string]Ship `json:"ships"`

	Wrecks map[string]Wreck `json:"wrecks,omitempty"`

	Reports DataReports `json:"reports,omitempty"`
}

type DataReports

type DataReports struct {
	Combat []Combat `json:"combat,omitempty"`

	Trade []Trade `json:"trade,omitempty"`
}

type DecommissionCommand

type DecommissionCommand struct {
	Type string `json:"type,omitempty"`
}

type Destination

type Destination struct {
	Coordinates *[]int64 `json:"coordinates,omitempty"`

	Target *string `json:"target,omitempty"`
}

type EndTurn

type EndTurn struct {
	Tick int64 `json:"tick"`

	Season int64 `json:"season"`
}

type Error

type Error struct {
	Message string `json:"message"`
}

type Game

type Game struct {
	Tick                 CurrentTick
	ResourceNames        map[string]string
	ShipClasses          map[string]ShipClass
	SerializedStaticData []byte
	Ready                *sync.RWMutex
	ReportsReady         *sync.RWMutex
	TickCond             *sync.Cond
	SessionManager       sessions.Store
	Reports              Reports
	// contains filtered or unexported fields
}

func NewGame

func NewGame(db *sql.DB, sessionManager sessions.Store) (*Game, error)

func (*Game) CreatePlayersForUsers

func (game *Game) CreatePlayersForUsers() error

func (*Game) CreateWaypointFromCoordinates

func (game *Game) CreateWaypointFromCoordinates(c []int64) (string, error)

func (*Game) DetermineTarget

func (game *Game) DetermineTarget(d Destination) (string, error)

func (*Game) EndTurn

func (game *Game) EndTurn(userExpectations EndTurn) CurrentTick

func (*Game) GetData

func (game *Game) GetData(playerId *string) (Data, error)

func (*Game) GetGameTickState

func (game *Game) GetGameTickState() CurrentTick

func (*Game) GetHistoricStaticData

func (game *Game) GetHistoricStaticData(season int) (string, error)

func (*Game) GetHistoryData

func (game *Game) GetHistoryData(season int64, tick int64, playerId *string) (Data, error)

func (*Game) GetHistoryReports

func (game *Game) GetHistoryReports(season int64, tick int64) (Reports, error)

func (*Game) GetPlanets

func (game *Game) GetPlanets(resources *map[int]map[string]*TradingResource) (map[string]Planet, error)

func (*Game) GetShips

func (game *Game) GetShips(playerId *string, resources *map[int]map[string]*TradingResource) (map[string]Ship, error)

func (*Game) GetWrecks

func (game *Game) GetWrecks() (map[string]Wreck, error)

func (*Game) Init

func (game *Game) Init() error

func (*Game) MainLoop

func (game *Game) MainLoop(ctx context.Context, wg *sync.WaitGroup)

func (*Game) NextSeason

func (game *Game) NextSeason()

func (*Game) ProcessCommands

func (game *Game) ProcessCommands(commands map[string]Command, user LoggedUser) (map[string]string, error)

func (*Game) SetResourceNames

func (game *Game) SetResourceNames() error

func (*Game) SetShipClasses

func (game *Game) SetShipClasses() error

type ImplResponse

type ImplResponse struct {
	Code int
	Body interface{}
}

ImplResponse response defines an error code with the associated body

func Response

func Response(code int, body interface{}) ImplResponse

Response return a ImplResponse struct filled

type LoggedUser

type LoggedUser struct {
	Username string
	PlayerId string
}

func LoggedUserFromSession

func LoggedUserFromSession(req *http.Request, sessionManager sessions.Store) (LoggedUser, error)

type MoveCommand

type MoveCommand struct {
	Destination *Destination `json:"destination"`

	Type string `json:"type,omitempty"`
}

func NewMoveCommand

func NewMoveCommand(command Command) *MoveCommand

type NetWorth

type NetWorth struct {
	Money int64 `json:"money"`

	Resources int64 `json:"resources"`

	Ships int64 `json:"ships"`

	Total int64 `json:"total"`
}

type Planet

type Planet struct {
	Name string `json:"name"`

	Resources map[string]TradingResource `json:"resources"`

	Position *[]int64 `json:"position"`

	PrevPosition *[]int64 `json:"prevPosition"`
}

type Player

type Player struct {
	Name string `json:"name"`

	Color []int32 `json:"color"`

	NetWorth NetWorth `json:"netWorth"`
}

type PlayerId

type PlayerId struct {
	Id string `json:"id,omitempty"`
}

type Profiling

type Profiling struct {
	Tick int64 `json:"tick,omitempty"`

	Movement int64 `json:"movement,omitempty"`

	Attacks int64 `json:"attacks,omitempty"`

	Trades int64 `json:"trades,omitempty"`

	Recipes int64 `json:"recipes,omitempty"`

	Prices int64 `json:"prices,omitempty"`

	Constructions int64 `json:"constructions,omitempty"`

	Report int64 `json:"report,omitempty"`

	Total int64 `json:"total,omitempty"`

	Overall int64 `json:"overall,omitempty"`

	At int64 `json:"at,omitempty"`
}

type RenameCommand

type RenameCommand struct {
	Name *string `json:"name"`

	Type string `json:"type,omitempty"`
}

func NewRenameCommand

func NewRenameCommand(command Command) *RenameCommand

type RepairCommand

type RepairCommand struct {
	Type string `json:"type,omitempty"`
}

type Reports

type Reports struct {
	Combat []Combat `json:"combat"`

	Trade []Trade `json:"trade"`

	// Profiling information about the game. Used by the visualization website.
	Profiling []Profiling `json:"profiling"`

	// Prices are average across all planets.
	Prices map[string]map[string]int64 `json:"prices"`

	ResourceAmounts map[string]map[string]int64 `json:"resourceAmounts"`

	Scores map[string]ScoreValue `json:"scores"`

	// user
	SeasonScores map[string]map[string]int64 `json:"seasonScores,omitempty"`

	// requested / last season
	Season int64 `json:"season"`

	// requested / last tick in the season
	Tick int64 `json:"tick"`
}

func FilterReportsUpToTick

func FilterReportsUpToTick(fullReports *Reports, season int64, tick int64) Reports

type RequiredError

type RequiredError struct {
	Field string
}

RequiredError indicates that an error has occurred when parsing request parameters

func (*RequiredError) Error

func (e *RequiredError) Error() string

type Resource

type Resource struct {
	Amount int64 `json:"amount"`
}

type ScoreValue

type ScoreValue struct {
	Money map[string]int64 `json:"money,omitempty"`

	Resources map[string]int64 `json:"resources,omitempty"`

	Ships map[string]int64 `json:"ships,omitempty"`

	Total map[string]int64 `json:"total,omitempty"`
}

type Ship

type Ship struct {
	ShipClass string `json:"shipClass"`

	Life int64 `json:"life"`

	Name string `json:"name"`

	Player string `json:"player"`

	Position *[]int64 `json:"position"`

	PrevPosition *[]int64 `json:"prevPosition"`

	Resources map[string]Resource `json:"resources"`

	Command *Command `json:"command,omitempty"`
}

type ShipClass

type ShipClass struct {
	Name string `json:"name"`

	// whether ships of this class are allowed to construct new ships
	Shipyard bool `json:"shipyard"`

	Speed float64 `json:"speed"`

	// maximum number of resources the ship can carry - sum over all types of resources
	CargoCapacity int64 `json:"cargoCapacity"`

	Life int64 `json:"life"`

	Damage int64 `json:"damage"`

	Price int64 `json:"price"`

	// passive regeneration per tick
	Regen int64 `json:"regen"`

	// price for healing repairLife per tick (for repair command)
	RepairPrice int64 `json:"repairPrice"`

	// how much is repaired per tick (for repair command)
	RepairLife int64 `json:"repairLife"`
}

type StaticData

type StaticData struct {
	ShipClasses map[string]ShipClass `json:"shipClasses,omitempty"`

	ResourceNames map[string]string `json:"resourceNames,omitempty"`
}

type Trade

type Trade struct {
	Tick int64 `json:"tick,omitempty"`

	Buyer string `json:"buyer,omitempty"`

	Seller string `json:"seller,omitempty"`

	Resource string `json:"resource,omitempty"`

	Amount int64 `json:"amount,omitempty"`

	Price int64 `json:"price,omitempty"`
}

type TradeCommand

type TradeCommand struct {

	// Positive value means buy, negative sell.
	Amount *int64 `json:"amount"`

	Resource *string `json:"resource"`

	// Any planet or own ship.
	Target *string `json:"target"`

	Type string `json:"type,omitempty"`
}

func NewTradeCommand

func NewTradeCommand(command Command) *TradeCommand

type TradingResource

type TradingResource struct {
	Amount int64 `json:"amount"`

	BuyPrice float64 `json:"buyPrice,omitempty"`

	SellPrice float64 `json:"sellPrice,omitempty"`
}

type TradingResourceAllOf

type TradingResourceAllOf struct {
	BuyPrice float64 `json:"buyPrice,omitempty"`

	SellPrice float64 `json:"sellPrice,omitempty"`
}

type Wreck

type Wreck struct {
	ShipClass string `json:"shipClass"`

	Name string `json:"name"`

	Player string `json:"player"`

	KillTick int64 `json:"killTick"`

	Position *[]int64 `json:"position"`
}

Jump to

Keyboard shortcuts

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