client

package
v0.0.0-...-9c133fc Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2021 License: MIT Imports: 23 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	LadderGamePort   = 0
	LadderStartPort  = 0
	LadderServer     = ""
	LadderOpponentID = ""
	MapName          = Random1v1Map()
)
View Source
var (
	LaunchPortStart = 8168
)
View Source
var Maps2021season1 = []string{
	"DeathAura506",
	"EternalEmpire506",
	"EverDream506",
	"GoldenWall506",
	"IceandChrome506",
	"PillarsofGold506",
	"Submarine506",
}
View Source
var Maps2021season2 = []string{
	"2000AtmospheresAIE",
	"BlackburnAIE",
	"JagannathaAIE",
	"LightshadeAIE",
	"OxideAIE",
	"RomanticideAIE",
}
View Source
var MaxMessageSize = 10 * 1024 * 1024

MaxMessageSize is the largest protobuf message that can be sent without getting disconnected. The gorilla/websocket implementation fragments messages above it's write buffer size and the SC2 game doesn't seem to be able to deal with these messages. There is not a check in place to prevent large messages from being sent and warnings will be printed if a message size exceeds half of this limit. The default is now 10MB (up from 4kb) but can be overrided by modifying this value before connecting to SC2.

Functions

func LoadSettings

func LoadSettings() bool

func MapPath

func MapPath() string

func NewComputer

func NewComputer(race api.Race, difficulty api.Difficulty, build api.AIBuild) *api.PlayerSetup

func NewParticipant

func NewParticipant(race api.Race, name string) *api.PlayerSetup

func ProcessPathForBuild

func ProcessPathForBuild(build uint32) string

func Random1v1Map

func Random1v1Map() string

Random1v1Map returns a random map name from the current 1v1 ladder map pool.

func Set

func Set(name, value string)

Set changes the default value of a command line flag.

func SetConnectTimeout

func SetConnectTimeout(timeout time.Duration)

SetConnectTimeout sets how long to wait for a connection to the game.

func SetExecutable

func SetExecutable(exePath string)

SetExecutable sets the default executable path to use.

func SetGameVersion

func SetGameVersion(baseBuild uint32, dataVersion string)

SetGameVersion specifies a specific base game and data version to use when launching.

func SetInterfaceOptions

func SetInterfaceOptions(options *api.InterfaceOptions)

SetInterfaceOptions sets the interface launch options when starting a game.

func SetMap

func SetMap(name string)

SetMap sets the map to use (via flag)

func SetRealtime

func SetRealtime()

SetRealtime sets the default realtime option to enabled.

func StartProcess

func StartProcess(path string, args []string) int

Types

type Client

type Client struct {
	api.ResponsePing

	Status api.Status

	Realtime bool
	// contains filtered or unexported fields
}

func (*Client) Action

func (c *Client) Action(action api.RequestAction) (*api.ResponseAction, error)

func (*Client) AvailableMaps

func (c *Client) AvailableMaps() (*api.ResponseAvailableMaps, error)

func (*Client) Connect

func (c *Client) Connect(address string, port int, timeout time.Duration) error

func (*Client) CreateGame

func (c *Client) CreateGame(createGame api.RequestCreateGame) (*api.ResponseCreateGame, error)

func (*Client) Data

func (c *Client) Data(data api.RequestData) (*api.ResponseData, error)

func (*Client) Debug

func (c *Client) Debug(debug api.RequestDebug) error

func (*Client) Dial

func (c *Client) Dial(address string, port int) error

func (*Client) GameInfo

func (c *Client) GameInfo() (*api.ResponseGameInfo, error)

func (*Client) JoinGame

func (c *Client) JoinGame(joinGame api.RequestJoinGame) (*api.ResponseJoinGame, error)

func (*Client) LeaveGame

func (c *Client) LeaveGame() error

func (*Client) MapCommand

func (c *Client) MapCommand(mapCommand api.RequestMapCommand) (*api.ResponseMapCommand, error)

func (*Client) ObsAction

func (c *Client) ObsAction(obsAction api.RequestObserverAction) error

func (*Client) Observation

func (c *Client) Observation(observation api.RequestObservation) (*api.ResponseObservation, error)

func (*Client) Ping

func (c *Client) Ping() (*api.ResponsePing, error)

func (*Client) Query

func (c *Client) Query(query api.RequestQuery) (*api.ResponseQuery, error)

func (*Client) QuickLoad

func (c *Client) QuickLoad() error

func (*Client) QuickSave

func (c *Client) QuickSave() error

func (*Client) Quit

func (c *Client) Quit() error

func (*Client) ReplayInfo

func (c *Client) ReplayInfo(replayInfo api.RequestReplayInfo) (*api.ResponseReplayInfo, error)

func (*Client) Request

func (c *Client) Request(r *api.Request) (*api.Response, error)

func (*Client) RequestCreateGame

func (c *Client) RequestCreateGame(mapPath string, players []*api.PlayerSetup, realtime bool) error

func (*Client) RequestJoinGame

func (c *Client) RequestJoinGame(setup *api.PlayerSetup, options *api.InterfaceOptions, ports Ports) error

func (*Client) RestartGame

func (c *Client) RestartGame() (*api.ResponseRestartGame, error)

func (*Client) SaveMap

func (c *Client) SaveMap(saveMap api.RequestSaveMap) (*api.ResponseSaveMap, error)

func (*Client) SaveReplay

func (c *Client) SaveReplay() (*api.ResponseSaveReplay, error)

func (*Client) StartReplay

func (c *Client) StartReplay(startReplay api.RequestStartReplay) (*api.ResponseStartReplay, error)

func (*Client) Step

func (c *Client) Step(step api.RequestStep) (*api.ResponseStep, error)

func (*Client) TryConnect

func (c *Client) TryConnect(address string, port int) error

type GameConfig

type GameConfig struct {
	Client *Client
	// contains filtered or unexported fields
}

func LaunchAndJoin

func LaunchAndJoin(bot, cpu *api.PlayerSetup) *GameConfig

func NewGameConfig

func NewGameConfig(participants ...*api.PlayerSetup) *GameConfig

func (*GameConfig) Connect

func (config *GameConfig) Connect(port int)

func (*GameConfig) CreateGame

func (config *GameConfig) CreateGame(mapPath string) bool

func (*GameConfig) JoinGame

func (config *GameConfig) JoinGame() bool

func (*GameConfig) LaunchAndAttach

func (config *GameConfig) LaunchAndAttach(path string, c *Client) ProcessInfo

func (*GameConfig) LaunchProcess

func (config *GameConfig) LaunchProcess(client *Client) ProcessInfo

func (*GameConfig) LaunchStarcraft

func (config *GameConfig) LaunchStarcraft()

func (*GameConfig) SetupPorts

func (config *GameConfig) SetupPorts(startPort int)

func (*GameConfig) StartGame

func (config *GameConfig) StartGame(mapPath string)

type Ports

type Ports struct {
	ServerPorts *api.PortSet
	ClientPorts []*api.PortSet
	SharedPort  int32
}

type ProcessInfo

type ProcessInfo struct {
	Path string
	PID  int
	Port int
}

Jump to

Keyboard shortcuts

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