rep

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: Apache-2.0 Imports: 12 Imported by: 10

Documentation

Overview

Package rep provides enumerations and types to model data structures of StarCraft II replays (*.SC2Replay) decoded by the s2prot package.

The type that models a replay (and everything in it) is Rep.

For usage example and information sources, see the package doc of s2prot.

Index

Constants

View Source
const (
	// TrackerEvtIDPlayerStats is the ID of the Player Stats tracker event
	TrackerEvtIDPlayerStats = 0

	// TrackerEvtIDUnitBorn is the ID of the Unit Born tracker event
	TrackerEvtIDUnitBorn = 1

	// TrackerEvtIDPlayerSetup is the ID of the Player Setup tracker event
	TrackerEvtIDPlayerSetup = 9
)
View Source
const (
	GmEIdPlayerLeave     = 25  // PlayerLeave game event id [ONLY UP TO BASEBUILD 23260; REPLACED BY USERLEAVE]
	GmEIdCmd             = 27  // CmdEvent game event id
	GmEIdSelDelta        = 28  // SelectionDelta game event id
	GmEIdCtrlGroupUpdate = 29  // ControlGroupUpdate game event id
	GmEIdCamUpdate       = 49  // CameraUpdate game event id
	GmEIdUsrLeave        = 101 // UserLeave game event id [ONLY FROM BASEBUILD 24764; REPLACES PLAYERLEAVE]
)

Game event ids

View Source
const (
	MsgEIdChat = 0 // ChatMessage message event id
	MsgEIdPing = 1 // PingMessage message event id
)

Message event ids

View Source
const (
	// ParserVersion is a Semver2 compatible version of the parser.
	ParserVersion = "v1.3.0"
)
View Source
const (
	TrEIdPlayerSetup = 9 // PlayerSetup tracker event id [ONLY FROM BASEBUILD 27950]
)

Tracker event ids

Variables

View Source
var (
	// ErrInvalidRepFile means invalid replay file.
	ErrInvalidRepFile = errors.New("Invalid SC2Replay file")

	// ErrUnsupportedRepVersion means the replay file is valid but its version is not supported.
	ErrUnsupportedRepVersion = errors.New("Unsupported replay version")

	// ErrDecoding means decoding the replay file failed,
	// Most likely because replay file is invalid, but also might be due to an implementation bug
	ErrDecoding = errors.New("Decoding error")
)
View Source
var (
	GameModeAutoMM       = GameModes[0]
	GameModePrivate      = GameModes[1]
	GameModePublic       = GameModes[2]
	GameModeSinglePlayer = GameModes[3]
	GameModeUnknown      = GameModes[4]
)

Named game modes.

View Source
var (
	GameSpeedSlower  = GameSpeeds[0]
	GameSpeedSlow    = GameSpeeds[1]
	GameSpeedNormal  = GameSpeeds[2]
	GameSpeedFast    = GameSpeeds[3]
	GameSpeedFaster  = GameSpeeds[4]
	GameSpeedUnknown = GameSpeeds[5]
)

Named game speeds.

View Source
var (
	RaceTerran  = Races[0]
	RaceZerg    = Races[1]
	RaceProtoss = Races[2]
	RaceRandom  = Races[3]
	RaceUnknown = Races[4]
)

Named races.

View Source
var (
	ResultUnknown = Results[0]
	ResultVictory = Results[1]
	ResultDefeat  = Results[2]
	ResultTie     = Results[3]
)

Named results.

View Source
var (
	ControlOpen     = Controls[0]
	ControlClosed   = Controls[1]
	ControlHuman    = Controls[2]
	ControlComputer = Controls[3]
	ControlUnknown  = Controls[4]
)

Named controls.

View Source
var (
	ObserveParticipant = Observes[0]
	ObserveSpectator   = Observes[1] // Can only talk to other observers.
	ObserveReferee     = Observes[2] // Can talk to players as well.
	ObserveUnknown     = Observes[3]
)

Named observes.

View Source
var (
	ColorUnknown    = Colors[0]
	ColorRed        = Colors[1]
	ColorBlue       = Colors[2]
	ColorTeal       = Colors[3]
	ColorPurple     = Colors[4]
	ColorYellow     = Colors[5]
	ColorOrange     = Colors[6]
	ColorGreen      = Colors[7]
	ColorLightPink  = Colors[8]
	ColorViolet     = Colors[9]
	ColorLightGray  = Colors[10]
	ColorDarkGreen  = Colors[11]
	ColorBrown      = Colors[12]
	ColorLightGreen = Colors[13]
	ColorDarkGray   = Colors[14]
	ColorPink       = Colors[15]
)

Named colors.

View Source
var (
	LeagueUnknown     = Leagues[0]
	LeagueBronze      = Leagues[1]
	LeagueSilver      = Leagues[2]
	LeagueGold        = Leagues[3]
	LeaguePlatinum    = Leagues[4]
	LeagueDiamond     = Leagues[5]
	LeagueMaster      = Leagues[6]
	LeagueGrandmaster = Leagues[7]
	LeagueUnranked    = Leagues[8]
)

Named leagues.

View Source
var (
	BnetLangEnglish            = BnetLangs[0]
	BnetLangChineseTraditional = BnetLangs[1]
	BnetLangFrench             = BnetLangs[2]
	BnetLangGerman             = BnetLangs[3]
	BnetLangItalian            = BnetLangs[4]
	BnetLangKorean             = BnetLangs[5]
	BnetLangPolish             = BnetLangs[6]
	BnetLangPortuguese         = BnetLangs[7]
	BnetLangRussian            = BnetLangs[8]
	BnetLangSpanish            = BnetLangs[9]
)

Named Battle.net languages.

View Source
var (
	RealmNorthAmerica = Realms[0]
	RealmLatinAmerica = Realms[1]
	RealmChina        = Realms[2]
	RealmEurope       = Realms[3]
	RealmRussia       = Realms[4]
	RealmKorea        = Realms[5]
	RealmTaiwan       = Realms[6]
	RealmSEA          = Realms[7]
	RealmUnknown      = Realms[8]
)

Named realms.

View Source
var (
	RegionUnknown     = Regions[0]
	RegionUS          = Regions[1]
	RegionEU          = Regions[2]
	RegionKR          = Regions[3]
	RegionSEA         = Regions[4]
	RegionCN          = Regions[5]
	RegionPublicTest  = Regions[6]
	RegionPublicTest2 = Regions[7]
)

Named regions.

View Source
var (
	ExpLevelLotV    = ExpLevels[0]
	ExpLevelHotS    = ExpLevels[1]
	ExpLevelWoL     = ExpLevels[2]
	ExpLevelUnknown = ExpLevels[3]
)

Named expansion levels.

View Source
var BnetLangs = []*BnetLang{
	{Enum{"English"}, "en"},
	{Enum{"Chinese (Traditional)"}, "zn"},
	{Enum{"French"}, "fr"},
	{Enum{"German"}, "de"},
	{Enum{"Italian"}, "it"},
	{Enum{"Korean"}, "ko"},
	{Enum{"Polish"}, "pl"},
	{Enum{"Portuguese"}, "pt"},
	{Enum{"Russian"}, "ru"},
	{Enum{"Spanish"}, "es"},
}

BnetLangs is the slice of all Battle.net languages.

View Source
var Colors = []*Color{
	{Enum: Enum{"Unknown"}, RGB: [3]byte{0, 0, 0}},
	{Enum: Enum{"Red"}, RGB: [3]byte{180, 20, 30}},
	{Enum: Enum{"Blue"}, RGB: [3]byte{0, 66, 255}},
	{Enum: Enum{"Teal"}, RGB: [3]byte{28, 167, 234}},
	{Enum: Enum{"Purple"}, RGB: [3]byte{84, 0, 129}},
	{Enum: Enum{"Yellow"}, RGB: [3]byte{235, 225, 41}},
	{Enum: Enum{"Orange"}, RGB: [3]byte{254, 138, 14}},
	{Enum: Enum{"Green"}, RGB: [3]byte{22, 128, 0}},
	{Enum: Enum{"Light Pink"}, RGB: [3]byte{204, 166, 252}},
	{Enum: Enum{"Violet"}, RGB: [3]byte{31, 1, 201}},
	{Enum: Enum{"Light Gray"}, RGB: [3]byte{82, 84, 148}},
	{Enum: Enum{"Dark Green"}, RGB: [3]byte{16, 98, 70}},
	{Enum: Enum{"Brown"}, RGB: [3]byte{78, 42, 4}},
	{Enum: Enum{"Light Green"}, RGB: [3]byte{150, 255, 145}},
	{Enum: Enum{"Dark Gray"}, RGB: [3]byte{35, 35, 35}},
	{Enum: Enum{"Pink"}, RGB: [3]byte{229, 91, 176}},
}

Colors is the slice of all colors, index used in InitData["lobbyState"]["slots"]["colorPref"]["color"]

View Source
var Controls = []*Control{
	{Enum{"Open"}, "Open"},
	{Enum{"Closed"}, "Clsd"},
	{Enum{"Human"}, "Humn"},
	{Enum{"Computer"}, "Comp"},
	{Enum{"Unknown"}, ""},
}

Controls is the slice of all control, index used in InitData["lobbyState"]["slots"]["control"] and in Details["playerList"]["control"]

View Source
var ExpLevels = []*ExpLevel{
	{Enum{"LotV"}, "Legacy of the Void", "d92dfc48c484c59154270b924ad7d57484f2ab9a47621c7ab16431bf66c53b40"},
	{Enum{"HotS"}, "Heart of the Swarm", "66093832128453efffbb787c80b7d3eec1ad81bde55c83c930dea79c4e505a04"},
	{Enum{"WoL"}, "Wings of Liberty", "421c8aa0f3619b652d23a2735dfee812ab644228235e7a797edecfe8b67da30e"},
	{Enum{"Unknown"}, "Unknown", ""},
}

ExpLevels is the slice of all expansion levels.

View Source
var GameModes = []*GameMode{
	{Enum{"AutoMM"}, "Amm"},
	{Enum{"Private"}, "Priv"},
	{Enum{"Public"}, "Pub"},
	{Enum{"Single Player"}, ""},
	{Enum{"Unknown"}, "<>"},
}

GameModes is the slice of all game modes.

View Source
var GameSpeeds = []*GameSpeed{
	{Enum{"Slower"}, "Slor", 60},
	{Enum{"Slow"}, "Slow", 45},
	{Enum{"Normal"}, "Norm", 36},
	{Enum{"Fast"}, "Fast", 30},
	{Enum{"Faster"}, "Fasr", 26},
	{Enum{"Unknown"}, "", 26},
}

GameSpeeds is the slice of all game speeds, index is used in Details["gameSpeed"]

View Source
var Leagues = []*League{
	{Enum{"Unknown"}, '-'},
	{Enum{"Bronze"}, 'B'},
	{Enum{"Silver"}, 'S'},
	{Enum{"Gold"}, 'G'},
	{Enum{"Platinum"}, 'P'},
	{Enum{"Diamond"}, 'D'},
	{Enum{"Master"}, 'M'},
	{Enum{"Grandmaster"}, 'R'},
	{Enum{"Unranked"}, 'U'},
}

Leagues is the slice of all leagues.

View Source
var Observes = []*Observe{
	{Enum{"Participant"}},
	{Enum{"Spectator"}},
	{Enum{"Referee"}},
	{Enum{"Unknown"}},
}

Observes is the slice of all observes, index used in InitData["lobbyState"]["slots"]["observe"] and in Details["playerList"]["observe"]

View Source
var Races = []*Race{
	{Enum{"Terran"}, 'T'},
	{Enum{"Zerg"}, 'Z'},
	{Enum{"Protoss"}, 'P'},
	{Enum{"Random"}, 'R'},
	{Enum{"Unknown"}, '-'},
}

Races is the slice of all races.

View Source
var Realms = []*Realm{
	{Enum{"North America"}},
	{Enum{"Latin America"}},
	{Enum{"China"}},
	{Enum{"Europe"}},
	{Enum{"Russia"}},
	{Enum{"Korea"}},
	{Enum{"Taiwan"}},
	{Enum{"SEA"}},
	{Enum{"Unknown"}},
}

Realms is the slice of all realms.

View Source
var Regions = []*Region{
	{Enum{"Unknown"}, "", mustPU("http://unknown.depot.battle.net:1119/"), mustPU("http://unknown.battle.net/"),
		[]*Realm{},
		[]*BnetLang{BnetLangEnglish}},
	{Enum{"US"}, "US", mustPU("https://us-s2-depot.classic.blizzard.com/"), mustPU("http://us.battle.net/"),
		[]*Realm{RealmNorthAmerica, RealmLatinAmerica},
		[]*BnetLang{BnetLangEnglish, BnetLangSpanish, BnetLangPortuguese}},
	{Enum{"Europe"}, "EU", mustPU("https://eu-s2-depot.classic.blizzard.com/"), mustPU("http://eu.battle.net/"),
		[]*Realm{RealmEurope, RealmRussia},
		[]*BnetLang{BnetLangEnglish, BnetLangGerman, BnetLangFrench, BnetLangSpanish, BnetLangRussian, BnetLangItalian, BnetLangPolish}},
	{Enum{"Korea"}, "KR", mustPU("https://kr-s2-depot.classic.blizzard.com/"), mustPU("http://kr.battle.net/"),
		[]*Realm{RealmKorea, RealmTaiwan},
		[]*BnetLang{BnetLangKorean, BnetLangChineseTraditional}},
	{Enum{"SEA"}, "SG", mustPU("http://sg.depot.battle.net:1119/"), mustPU("http://sea.battle.net/"),
		[]*Realm{RealmSEA},
		[]*BnetLang{BnetLangEnglish}},
	{Enum{"China"}, "CN", mustPU("http://cn-s2-depot.battlenet.com.cn/"), mustPU("http://www.battlenet.com.cn/"),
		[]*Realm{RealmChina},
		[]*BnetLang{BnetLangChineseTraditional}},
	{Enum{"Public Test"}, "XX", mustPU("http://xx.depot.battle.net:1119/"), mustPU("http://us.battle.net/"),
		[]*Realm{},
		[]*BnetLang{BnetLangEnglish}},
	{Enum{"Public Test"}, "XX", mustPU("http://xx.depot.battle.net:1119/"), mustPU("http://us.battle.net/"),
		[]*Realm{},
		[]*BnetLang{BnetLangEnglish}},
}

Regions is the slice of all regions, index used in Details["playerList"]["toon"]["region"]

View Source
var Results = []*Result{
	{Enum{"Unknown"}, '-'},
	{Enum{"Victory"}, 'V'},
	{Enum{"Defeat"}, 'D'},
	{Enum{"Tie"}, 'T'},
}

Results is the slice of all results, index used in Details["playerList"]["result"]

Functions

func MPQ added in v1.2.0

func MPQ(r *Rep) *mpq.MPQ

MPQ gives access to the underlying MPQ parser of the rep. Intentionally not a method of Rep to not urge its use.

Types

type AttrEvts added in v1.1.0

type AttrEvts struct {
	s2prot.Struct
	// contains filtered or unexported fields
}

AttrEvts contains game attributes.

func NewAttrEvts added in v1.2.0

func NewAttrEvts(s s2prot.Struct) AttrEvts

NewAttrEvts creates a new attributes events from the specified Struct.

func (*AttrEvts) GameMode added in v1.1.0

func (a *AttrEvts) GameMode() *GameMode

GameMode returns the game mode

func (*AttrEvts) MapNamespace added in v1.1.0

func (a *AttrEvts) MapNamespace() string

MapNamespace returns the map namespace.

func (*AttrEvts) Source added in v1.1.0

func (a *AttrEvts) Source() string

Source returns the source.

type BnetLang

type BnetLang struct {
	Enum
	Code string // 2-letter language code, the way it appears in URLs.
}

BnetLang is the type of Battle.net website language.

type CacheHandle

type CacheHandle struct {
	Type   string  // Type of the resource, file extension.
	Region *Region // Region the resouce poins to.
	Digest string  // Hexadecimal representation of the SHA-256 digest of the content of the denoted resource.
}

CacheHandle is the identifier of a remote resource. A cache hande is a dependency.

func (*CacheHandle) FileName

func (c *CacheHandle) FileName() string

FileName returns the file name denoted by the cache handle (with extension).

func (*CacheHandle) RelativeFile

func (c *CacheHandle) RelativeFile() string

RelativeFile returns the file denoted by the cache handle relative to the local cache folder.

func (*CacheHandle) StandardData

func (c *CacheHandle) StandardData() string

StandardData returns the content of the resource denoted by the cache handle if this is a standard data.

type Color

type Color struct {
	Enum
	RGB     [3]byte // Color value, RGB components.
	Darker  [3]byte // Darker version of the color's RGB values.
	Lighter [3]byte // Lighter versions of the color's RGB values.
	// contains filtered or unexported fields
}

Color type.

type Control

type Control struct {
	Enum
	// contains filtered or unexported fields
}

Control type.

type Details

type Details struct {
	s2prot.Struct
	// contains filtered or unexported fields
}

Details describles the game details (overall replay details).

func (*Details) CacheHandles

func (d *Details) CacheHandles() []*CacheHandle

CacheHandles returns the array of cache handles.

func (*Details) CampaignIndex

func (d *Details) CampaignIndex() int64

CampaignIndex returns the campaign index.

func (*Details) DefaultDifficulty

func (d *Details) DefaultDifficulty() int64

DefaultDifficulty returns the default difficulty.

func (*Details) Description

func (d *Details) Description() string

Description returns the description.

func (*Details) Difficulty

func (d *Details) Difficulty() int64

Difficulty returns the difficulty.

func (*Details) GameSpeed

func (d *Details) GameSpeed() *GameSpeed

GameSpeed returns the game speed.

func (*Details) ImageFilePath

func (d *Details) ImageFilePath() string

ImageFilePath returns the image file path.

func (*Details) IsBlizzardMap

func (d *Details) IsBlizzardMap() bool

IsBlizzardMap tells if the map is an official Blizzard map.

func (*Details) MapFileName

func (d *Details) MapFileName() string

MapFileName returns the name of the map file.

func (*Details) Matchup added in v1.1.0

func (d *Details) Matchup() string

Matchup returns the matchup, the race letters of players in team order, inserting 'v' between different teams, e.g. "PvT" or "PTZvZTP".

func (*Details) MiniSave

func (d *Details) MiniSave() bool

MiniSave returns if mini save.

func (*Details) ModPaths

func (d *Details) ModPaths() interface{}

ModPaths returns the mod paths.

func (*Details) Players

func (d *Details) Players() []Player

Players returns the list of players.

func (*Details) RestartAsTransitionMap

func (d *Details) RestartAsTransitionMap() bool

RestartAsTransitionMap returns if restart as transition map.

func (*Details) ThumbnailFile

func (d *Details) ThumbnailFile() string

ThumbnailFile returns the map thumbnail file name.

func (*Details) Time

func (d *Details) Time() time.Time

Time returns the replay date+time.

func (*Details) TimeLocalOffset

func (d *Details) TimeLocalOffset() time.Duration

TimeLocalOffset returns the local time offset of the playing who saved the replay.

func (*Details) TimeUTC added in v1.5.0

func (d *Details) TimeUTC() time.Time

TimeUTC returns the replay date+time - localOffset

func (*Details) Title

func (d *Details) Title() string

Title returns the map name.

type Enum

type Enum struct {
	Name string
}

Enum is the base of enum-like types.

func (Enum) String

func (e Enum) String() string

String returns the string representation of the enum (the name). Defined with value receiver so this gets called even if a non-pointer is printed.

type ExpLevel added in v1.1.0

type ExpLevel struct {
	Enum
	FullName string // Full (long) name of the expansion level
	Digest   string // Cache handle digest that identifies (defines) the expansion level
}

ExpLevel is the type of Expansion level.

type GameDescription

type GameDescription struct {
	s2prot.Struct

	GameOptions GameOptions
	// contains filtered or unexported fields
}

GameDescription is the game description

func (*GameDescription) CacheHandles

func (g *GameDescription) CacheHandles() []*CacheHandle

CacheHandles returns the array of cache handles.

func (*GameDescription) DefaultAIBuild

func (g *GameDescription) DefaultAIBuild() int64

DefaultAIBuild returns the default AI build.

func (*GameDescription) DefaultDifficulty

func (g *GameDescription) DefaultDifficulty() int64

DefaultDifficulty returns the default difficulty.

func (*GameDescription) ExpLevel added in v1.1.0

func (g *GameDescription) ExpLevel() *ExpLevel

ExpLevel returns the expansion level of the replay.

func (*GameDescription) GameCacheName

func (g *GameDescription) GameCacheName() string

GameCacheName returns the game cache name.

func (*GameDescription) GameSpeed

func (g *GameDescription) GameSpeed() *GameSpeed

GameSpeed returns the game speed.

func (*GameDescription) GameType

func (g *GameDescription) GameType() int64

GameType returns the game type.

func (*GameDescription) HasExtensionMod

func (g *GameDescription) HasExtensionMod() bool

HasExtensionMod returns if the game has extension mod.

func (*GameDescription) HasNonBlizzardExtensionMod

func (g *GameDescription) HasNonBlizzardExtensionMod() bool

HasNonBlizzardExtensionMod returns if the game has non-Blizzard extension mod.

func (*GameDescription) IsBlizzardMap

func (g *GameDescription) IsBlizzardMap() bool

IsBlizzardMap tells if the map is an official Blizzard map.

func (*GameDescription) IsCoopMode

func (g *GameDescription) IsCoopMode() bool

IsCoopMode tells if the game is coop mode.

func (*GameDescription) IsPremadeFFA

func (g *GameDescription) IsPremadeFFA() bool

IsPremadeFFA tells if the game is pre-made FFA.

func (*GameDescription) MapAuthorName

func (g *GameDescription) MapAuthorName() string

MapAuthorName returns the name of the map author.

func (*GameDescription) MapFileName

func (g *GameDescription) MapFileName() string

MapFileName returns the name of the map file.

func (*GameDescription) MapFileSyncChecksum

func (g *GameDescription) MapFileSyncChecksum() int64

MapFileSyncChecksum returns the map file sync checksum.

func (*GameDescription) MapSizeX

func (g *GameDescription) MapSizeX() int64

MapSizeX returns the map width.

func (*GameDescription) MapSizeY

func (g *GameDescription) MapSizeY() int64

MapSizeY returns the map height.

func (*GameDescription) MaxColors

func (g *GameDescription) MaxColors() int64

MaxColors returns the max colors.

func (*GameDescription) MaxControls

func (g *GameDescription) MaxControls() int64

MaxControls returns the max controls.

func (*GameDescription) MaxObservers

func (g *GameDescription) MaxObservers() int64

MaxObservers returns the max observers.

func (*GameDescription) MaxPlayers

func (g *GameDescription) MaxPlayers() int64

MaxPlayers returns the max players.

func (*GameDescription) MaxRaces

func (g *GameDescription) MaxRaces() int64

MaxRaces returns the max races.

func (*GameDescription) MaxTeams

func (g *GameDescription) MaxTeams() int64

MaxTeams returns the max teams.

func (*GameDescription) MaxUsers

func (g *GameDescription) MaxUsers() int64

MaxUsers returns the max users.

func (*GameDescription) ModFileSyncChecksum

func (g *GameDescription) ModFileSyncChecksum() int64

ModFileSyncChecksum returns the mod file sync checksum.

func (*GameDescription) RandomValue

func (g *GameDescription) RandomValue() int64

RandomValue returns the random value.

func (*GameDescription) Region added in v1.1.0

func (g *GameDescription) Region() *Region

Region returns the region of the replay.

func (*GameDescription) SlotDescriptions

func (g *GameDescription) SlotDescriptions() []SlotDescription

SlotDescriptions returns the array of slot descriptions.

type GameMode added in v1.1.0

type GameMode struct {
	Enum
	// contains filtered or unexported fields
}

GameMode is the game mode type

type GameOptions

type GameOptions struct {
	s2prot.Struct
}

GameOptions is the game options

func (*GameOptions) AdvancedSharedControl

func (g *GameOptions) AdvancedSharedControl() bool

AdvancedSharedControl returns if advanced shared control.

func (*GameOptions) Amm

func (g *GameOptions) Amm() bool

Amm returns if AMM (AutoMM - Automated Match Making).

func (*GameOptions) BattleNet

func (g *GameOptions) BattleNet() bool

BattleNet returns if game was played on Battle.net.

func (*GameOptions) ClientDebugFlags

func (g *GameOptions) ClientDebugFlags() int64

ClientDebugFlags returns the client debug flags.

func (*GameOptions) CompetitiveOrRanked

func (g *GameOptions) CompetitiveOrRanked() bool

CompetitiveOrRanked returns if game is competitive or if that property is not present if ranked. Competitive means either ranked or unranked. Before competitive there was no unraked type (so ranked="ladder").

func (*GameOptions) Cooperative

func (g *GameOptions) Cooperative() bool

Cooperative returns if cooperative.

func (*GameOptions) Fog

func (g *GameOptions) Fog() int64

Fog returns the fog.

func (*GameOptions) HeroDuplicatesAllowed

func (g *GameOptions) HeroDuplicatesAllowed() bool

HeroDuplicatesAllowed returns if hero duplicates are allowed.

func (*GameOptions) LockTeams

func (g *GameOptions) LockTeams() bool

LockTeams returns if teams are locked.

func (*GameOptions) NoVictoryOrDefeat

func (g *GameOptions) NoVictoryOrDefeat() bool

NoVictoryOrDefeat returns if no victory or defeat.

func (*GameOptions) Observers

func (g *GameOptions) Observers() int64

Observers returns the observers.

func (*GameOptions) Practice

func (g *GameOptions) Practice() bool

Practice returns if practice.

func (*GameOptions) RandomRaces

func (g *GameOptions) RandomRaces() bool

RandomRaces returns if random races.

func (*GameOptions) TeamsTogether

func (g *GameOptions) TeamsTogether() bool

TeamsTogether returns if teams together.

func (*GameOptions) UserDifficulty

func (g *GameOptions) UserDifficulty() int64

UserDifficulty returns the user difficulty.

type GameSpeed

type GameSpeed struct {
	Enum

	RelSpeed int // Relative speed compared to Normal
	// contains filtered or unexported fields
}

GameSpeed is the game speed type

type Header struct {
	s2prot.Struct
	// contains filtered or unexported fields
}

Header describes the replay header (replay game version and length).

func (*Header) BaseBuild

func (h *Header) BaseBuild() int64

BaseBuild returns the base build.

func (*Header) DataBuildNum

func (h *Header) DataBuildNum() int64

DataBuildNum returns the data build number.

func (*Header) Duration

func (h *Header) Duration() time.Duration

Duration returns the game duration.

func (*Header) Loops

func (h *Header) Loops() int64

Loops returns the elapsed game loops (game length in loops).

func (*Header) NgdpRootKey

func (h *Header) NgdpRootKey() string

NgdpRootKey returns the data ngdp root key.

func (*Header) ReplayCompatibilityHash

func (h *Header) ReplayCompatibilityHash() string

ReplayCompatibilityHash returns the replay compatibility hash.

func (*Header) Signature

func (h *Header) Signature() string

Signature returns the header signature. Should always be "StarCratII replay\u001b11".

func (*Header) Type

func (h *Header) Type() int64

Type returns the type.

func (*Header) UseScaledTime

func (h *Header) UseScaledTime() bool

UseScaledTime returns whether scaled time is used.

func (*Header) Version

func (h *Header) Version() Version

Version returns the version of the replay.

func (*Header) VersionString

func (h *Header) VersionString() string

VersionString returns the full version string in the form of "major.minor.revision.build".

type InitData

type InitData struct {
	s2prot.Struct

	GameDescription GameDescription `json:"-"` // Game description
	LobbyState      LobbyState      `json:"-"` // Lobby state
	UserInitDatas   []UserInitData  `json:"-"` // Array User init data structs
}

InitData describes the init data (the initial lobby).

func NewInitData added in v1.2.0

func NewInitData(s s2prot.Struct) InitData

NewInitData creates a new init data from the specified Struct.

type League

type League struct {
	Enum
	Letter rune // League letter (first character of the English name except 'R' for LeagueGrandmaster and '-' for Unknown)
}

League type.

type LobbyState

type LobbyState struct {
	s2prot.Struct

	Slots []Slot
}

LobbyState is the lobby state

func (*LobbyState) DefaultAIBuild

func (l *LobbyState) DefaultAIBuild() int64

DefaultAIBuild returns the default AI build.

func (*LobbyState) DefaultDifficulty

func (l *LobbyState) DefaultDifficulty() int64

DefaultDifficulty returns the default difficulty.

func (*LobbyState) GameDuration

func (l *LobbyState) GameDuration() int64

GameDuration returns the game duration.

func (*LobbyState) HostUserID

func (l *LobbyState) HostUserID() int64

HostUserID returns the host user ID.

func (*LobbyState) IsSinglePlayer

func (l *LobbyState) IsSinglePlayer() bool

IsSinglePlayer tells if game is single player.

func (*LobbyState) MaxObservers

func (l *LobbyState) MaxObservers() int64

MaxObservers returns the max observers.

func (*LobbyState) MaxUsers

func (l *LobbyState) MaxUsers() int64

MaxUsers returns the max users.

func (*LobbyState) Phase

func (l *LobbyState) Phase() int64

Phase returns the phase.

func (*LobbyState) PickedMapTag

func (l *LobbyState) PickedMapTag() int64

PickedMapTag returns the picked map tag.

func (*LobbyState) RandomSeed

func (l *LobbyState) RandomSeed() int64

RandomSeed returns the random seed.

type MetaPlayer

type MetaPlayer struct {
	s2prot.Struct
}

MetaPlayer describes a player in the metadata section.

func (*MetaPlayer) APM

func (m *MetaPlayer) APM() float64

APM returns the player's APM value.

func (*MetaPlayer) AssignedRace

func (m *MetaPlayer) AssignedRace() string

AssignedRace returns the race string that was assigned to the player. It's a 4-letter prefix of the race (no Random), e.g. "Prot", "Terr", "Zerg".

func (*MetaPlayer) MMR

func (m *MetaPlayer) MMR() float64

MMR returns the player's (race-specific) MMR value.

func (*MetaPlayer) PlayerID

func (m *MetaPlayer) PlayerID() int64

PlayerID returns the player ID.

func (*MetaPlayer) Result

func (m *MetaPlayer) Result() string

Result returns the result string. "Win" for win, "Loss" for loss, "Undecided" if unknown.

func (*MetaPlayer) SelectedRace

func (m *MetaPlayer) SelectedRace() string

SelectedRace returns the player's selected race string. It's a 4-letter prefix of the race, e.g. "Rand", "Prot", "Terr", "Zerg".

type Metadata

type Metadata struct {
	s2prot.Struct
	// contains filtered or unexported fields
}

Metadata describes the game metadata (calculated, confirmed results).

func (*Metadata) BaseBuild

func (m *Metadata) BaseBuild() string

BaseBuild returns the base build version string. This has a "Base" prefix to the base build number.

func (*Metadata) DataBuild

func (m *Metadata) DataBuild() string

DataBuild returns the data build version string.

func (*Metadata) DurationSec

func (m *Metadata) DurationSec() float64

DurationSec returns the game duration in seconds.

func (*Metadata) GameVersion

func (m *Metadata) GameVersion() string

GameVersion returns the game version string.

func (*Metadata) Players

func (m *Metadata) Players() []MetaPlayer

Players returns the list of meta players.

func (*Metadata) Title

func (m *Metadata) Title() string

Title returns the map name.

type Observe

type Observe struct {
	Enum
}

Observe type.

type Player

type Player struct {
	s2prot.Struct

	Name  string  // Name of the player. Contains optional clan tag.
	Toon  Toon    // Toon of the player. This is a unique identifier.
	Color [4]byte // Color of the player, ARGB components. A=255 means completely opaque, A=0 means completely transparent.
	// contains filtered or unexported fields
}

Player (participant of the game). Includes computers players but excludes observers.

func (*Player) Control

func (p *Player) Control() *Control

Control returns the control.

func (*Player) Handicap

func (p *Player) Handicap() int64

Handicap returns the handicap.

func (*Player) Hero

func (p *Player) Hero() string

Hero returns the hero.

func (*Player) Observe

func (p *Player) Observe() *Observe

Observe returns the observe. Not always accurate! Observe from slot (init data) should be used instead!

func (*Player) Race

func (p *Player) Race() *Race

Race returns the race.

func (*Player) RaceString

func (p *Player) RaceString() string

RaceString returns the localized race string.

func (*Player) Result

func (p *Player) Result() *Result

Result returns the game result.

func (*Player) TeamID

func (p *Player) TeamID() int64

TeamID returns the team ID. Not always accurate! Team ID from slot (init data) should be used instead!

func (*Player) WorkingSetSlotID

func (p *Player) WorkingSetSlotID() int64

WorkingSetSlotID returns the working set slot ID.

type PlayerDesc added in v1.2.0

type PlayerDesc struct {
	// PlayerID is the ID of the player this PlayerDesc belongs to.
	PlayerID int64

	// SlotID is the slot ID of the player
	SlotID int64

	// UserID is the user ID of the player
	UserID int64

	// Start location of the player
	StartLocX, StartLocY int64

	// StartDir is the start direction of the player, expressed in clock,
	// e.g. 1 o'clock, 3 o'clock etcc, in range of 1..12
	StartDir int32

	// SQ (Spending Quotient) of the player
	SQ int32

	// SupplyCappedPercent is the supply-capped percent of the player
	SupplyCappedPercent int32
}

PlayerDesc contains calculated, derived data from tracker events.

type Race

type Race struct {
	Enum
	Letter rune // Race letter (first character of the English name)
}

Race type.

type Realm

type Realm struct {
	Enum
}

Realm is the type of SC2 Realm (sub-region).

type Region

type Region struct {
	Enum
	Code      string      // 2-letter region code
	DepotURL  *url.URL    // Region's depot server URL
	BnetURL   *url.URL    // Region's Battle.net website
	Realms    []*Realm    // Realms of the region, index+1 used in Details["playerList"]["toon"]["realm"]
	BnetLangs []*BnetLang // Available languages of the region's web page, first is the default language
}

Region is the type of SC2 Region.

func (*Region) Realm

func (r *Region) Realm(realmID int64) *Realm

Realm returns the realm of the region specified by its code.

type Rep

type Rep struct {
	Header   Header   // Replay header (replay game version and length)
	Details  Details  // Game details (overall replay details)
	InitData InitData // Replay init data (the initial lobby)
	AttrEvts AttrEvts // Attributes events

	Metadata Metadata // Game metadata (calculated, confirmed results)

	GameEvts    []s2prot.Event // Game events
	MessageEvts []s2prot.Event // Message events
	TrackerEvts *TrackerEvts   // Tracker events

	GameEvtsErr    bool // Tells if decoding game events had errors
	MessageEvtsErr bool // Tells if decoding message events had errors
	TrackerEvtsErr bool // Tells if decoding tracker events had errors
	// contains filtered or unexported fields
}

Rep describes a replay.

func New

func New(input io.ReadSeeker) (*Rep, error)

New returns a new Rep using the specified io.ReadSeeker as the SC2Replay file source. All types of events are decoded from the replay. The returned Rep must be closed with the Close method!

ErrInvalidRepFile is returned if the input is not a valid SC2Replay file content.

ErrUnsupportedRepVersion is returned if the input is a valid SC2Replay file but its version is not supported.

ErrDecoding is returned if decoding the replay fails. This is most likely because the input is invalid, but also might be due to an implementation bug.

func NewEvts

func NewEvts(input io.ReadSeeker, game, message, tracker bool) (*Rep, error)

NewEvts returns a new Rep using the specified io.ReadSeeker as the SC2Replay file source, only the specified types of events decoded. The game, message and tracker tells if game events, message events and tracker events are to be decoded. Replay header, init data, details, attributes events and game metadata are always decoded. The returned Rep must be closed with the Close method!

ErrInvalidRepFile is returned if the input is not a valid SC2Replay file content.

ErrUnsupportedRepVersion is returned if the input is a valid SC2Replay file but its version is not supported.

ErrDecoding is returned if decoding the replay fails. This is most likely because the input is invalid, but also might be due to an implementation bug.

func NewFromFile

func NewFromFile(name string) (*Rep, error)

NewFromFile returns a new Rep constructed from a file. All types of events are decoded from the replay. The returned Rep must be closed with the Close method!

ErrInvalidRepFile is returned if the specified name does not denote a valid SC2Replay file.

ErrUnsupportedRepVersion is returned if the file exists and is a valid SC2Replay file but its version is not supported.

ErrDecoding is returned if decoding the replay fails. This is most likely because the replay file is invalid, but also might be due to an implementation bug.

func NewFromFileEvts

func NewFromFileEvts(name string, game, message, tracker bool) (*Rep, error)

NewFromFileEvts returns a new Rep constructed from a file, only the specified types of events decoded. The game, message and tracker tells if game events, message events and tracker events are to be decoded. Replay header, init data, details, attributes events and game metadata are always decoded. The returned Rep must be closed with the Close method!

ErrInvalidRepFile is returned if the specified name does not denote a valid SC2Replay file.

ErrUnsupportedRepVersion is returned if the file exists and is a valid SC2Replay file but its version is not supported.

ErrDecoding is returned if decoding the replay fails. This is most likely because the replay file is invalid, but also might be due to an implementation bug.

func (*Rep) Close

func (r *Rep) Close() error

Close closes the Rep and its resources.

type Result

type Result struct {
	Enum
	Letter rune // Result letter (first character of the name)
}

Result type.

type Slot

type Slot struct {
	s2prot.Struct
}

Slot describes a slot

func (*Slot) AIBuild

func (s *Slot) AIBuild() int64

AIBuild returns the AI build.

func (*Slot) Artifacts

func (s *Slot) Artifacts() []interface{}

Artifacts returns the array of artifacts. The array has elements of type string.

func (*Slot) ColorPrefColor

func (s *Slot) ColorPrefColor() *Color

ColorPrefColor returns the color preference color.

func (*Slot) Commander

func (s *Slot) Commander() string

Commander returns the commander.

func (*Slot) CommanderLevel

func (s *Slot) CommanderLevel() int64

CommanderLevel returns the commander level.

func (*Slot) CommanderMasteryLevel

func (s *Slot) CommanderMasteryLevel() int64

CommanderMasteryLevel returns the commander mastery level.

func (*Slot) CommanderMasteryTalents

func (s *Slot) CommanderMasteryTalents() []interface{}

CommanderMasteryTalents returns the array of commander mastery talents. The array has elements of type int64.

func (*Slot) Control

func (s *Slot) Control() *Control

Control returns the control.

func (*Slot) Difficulty

func (s *Slot) Difficulty() int64

Difficulty returns the difficulty.

func (*Slot) Handicap

func (s *Slot) Handicap() int64

Handicap returns the handicap.

func (*Slot) HasSilencePenalty

func (s *Slot) HasSilencePenalty() bool

HasSilencePenalty returns if there is slience penalty.

func (*Slot) Hero

func (s *Slot) Hero() string

Hero returns the hero.

func (*Slot) Licenses

func (s *Slot) Licenses() []interface{}

Licenses returns the array of licenses. The array has elements of type int64.

func (*Slot) LogoIndex

func (s *Slot) LogoIndex() int64

LogoIndex returns the logo index.

func (*Slot) Mount

func (s *Slot) Mount() string

Mount returns the mount.

func (*Slot) Observe

func (s *Slot) Observe() *Observe

Observe returns the observe.

func (*Slot) RacePrefRace

func (s *Slot) RacePrefRace() *Race

RacePrefRace returns the race preference race. This may be RaceRandom.

func (*Slot) Rewards

func (s *Slot) Rewards() []interface{}

Rewards returns the array of rewards. The array has elements of type int64.

func (*Slot) Skin

func (s *Slot) Skin() string

Skin returns the skin.

func (*Slot) TandemID

func (s *Slot) TandemID() int64

TandemID returns the tandem ID.

func (*Slot) TandemLeaderUserID

func (s *Slot) TandemLeaderUserID() int64

TandemLeaderUserID returns the tandem leader user ID (in case of Archon mode games).

func (*Slot) TeamID

func (s *Slot) TeamID() int64

TeamID returns the team ID.

func (*Slot) ToonHandle

func (s *Slot) ToonHandle() string

ToonHandle returns the toon handle.

func (*Slot) UserID

func (s *Slot) UserID() int64

UserID returns the user ID.

func (*Slot) WorkingSetSlotID

func (s *Slot) WorkingSetSlotID() int64

WorkingSetSlotID returns the working set slot ID.

type SlotDescription

type SlotDescription struct {
	s2prot.Struct
}

SlotDescription is the slot description

func (*SlotDescription) AllowedAIBuilds

func (s *SlotDescription) AllowedAIBuilds() s2prot.BitArr

AllowedAIBuilds returns the allowed AI builds bitmap.

func (*SlotDescription) AllowedColors

func (s *SlotDescription) AllowedColors() s2prot.BitArr

AllowedColors returns the allowed colors bitmap.

func (*SlotDescription) AllowedControls

func (s *SlotDescription) AllowedControls() s2prot.BitArr

AllowedControls returns the allowed controls bitmap.

func (*SlotDescription) AllowedDifficulty

func (s *SlotDescription) AllowedDifficulty() s2prot.BitArr

AllowedDifficulty returns the allowed difficulty bitmap.

func (*SlotDescription) AllowedObserveTypes

func (s *SlotDescription) AllowedObserveTypes() s2prot.BitArr

AllowedObserveTypes returns the allowed observe types bitmap.

func (*SlotDescription) AllowedRaces

func (s *SlotDescription) AllowedRaces() s2prot.BitArr

AllowedRaces returns the allowed races bitmap.

type Toon

type Toon struct {
	s2prot.Struct
}

Toon - a unique identifier (of a player)

func (*Toon) ID

func (t *Toon) ID() int64

ID returns the ID.

func (*Toon) ProgramID

func (t *Toon) ProgramID() string

ProgramID returns the program ID, always "S2", leading zeros will be stripped.

func (*Toon) Realm

func (t *Toon) Realm() *Realm

Realm returns the realm.

func (*Toon) RealmID

func (t *Toon) RealmID() int64

RealmID returns the realm ID.

func (*Toon) Region

func (t *Toon) Region() *Region

Region returns the region.

func (*Toon) RegionID

func (t *Toon) RegionID() int64

RegionID returns the region ID.

func (Toon) String

func (t Toon) String() string

String returns a string representation of the Toon, the same format as used in InitData["lobbyState"]["slots"]["toonHandle"]:

regionId-programId-reamId-playerId

Using value receiver as Player.Toon is not a pointer (and so printing Player.Toon will call this method).

func (*Toon) URL added in v1.5.0

func (t *Toon) URL() string

URL returns the starcraft2.com url

type TrackerEvts added in v1.2.0

type TrackerEvts struct {
	// Evts contains the tracker events
	Evts []s2prot.Event

	// PIDPlayerDescMap is a PlayerDesc map mapped from player ID.
	PIDPlayerDescMap map[int64]*PlayerDesc

	// ToonPlayerDescMap is a PlayerDesc map mapped from toon.
	ToonPlayerDescMap map[string]*PlayerDesc `json:"-"`
}

TrackerEvts contains tracker events and some metrics and data calculated from them.

type UserInitData

type UserInitData struct {
	s2prot.Struct

}

UserInitData describes user initial data

func (*UserInitData) ClanTag

func (u *UserInitData) ClanTag() string

ClanTag returns the clan tag.

func (*UserInitData) CombinedRaceLevels

func (u *UserInitData) CombinedRaceLevels() int64

CombinedRaceLevels returns the combined race levels.

func (*UserInitData) CustomInterface

func (u *UserInitData) CustomInterface() bool

CustomInterface tells if custom interface.

func (*UserInitData) Examine

func (u *UserInitData) Examine() bool

Examine tells if examine.

func (*UserInitData) Hero

func (u *UserInitData) Hero() string

Hero returns the hero.

func (*UserInitData) HighestLeague

func (u *UserInitData) HighestLeague() *League

HighestLeague returns the highest league.

func (*UserInitData) MMR added in v1.5.0

func (u *UserInitData) MMR() int64

MMR returns the mmr for the handle if set

func (*UserInitData) Mount

func (u *UserInitData) Mount() string

Mount returns the mount.

func (*UserInitData) Name

func (u *UserInitData) Name() string

Name returns the name.

func (*UserInitData) Observe

func (u *UserInitData) Observe() *Observe

Observe returns the observe.

func (*UserInitData) RacePreferenceRace

func (u *UserInitData) RacePreferenceRace() int64

RacePreferenceRace returns the race preference race.

func (*UserInitData) RandomSeed

func (u *UserInitData) RandomSeed() int64

RandomSeed returns the random seed.

func (*UserInitData) Skin

func (u *UserInitData) Skin() string

Skin returns the skin.

func (*UserInitData) TeamPreferenceTeam

func (u *UserInitData) TeamPreferenceTeam() int64

TeamPreferenceTeam returns the team preference team.

func (*UserInitData) TestAuto

func (u *UserInitData) TestAuto() bool

TestAuto tells if test auto.

func (*UserInitData) TestMap

func (u *UserInitData) TestMap() bool

TestMap tells if test map.

func (*UserInitData) TestType

func (u *UserInitData) TestType() int64

TestType returns the test type.

func (*UserInitData) ToonHandle

func (u *UserInitData) ToonHandle() string

ToonHandle returns the toon handle.

type Version

type Version struct {
	s2prot.Struct
}

Version of the replay.

func (*Version) BaseBuild

func (v *Version) BaseBuild() int64

BaseBuild returns the base build part of the version.

func (*Version) Build

func (v *Version) Build() int64

Build returns the build part of the version.

func (*Version) Flags

func (v *Version) Flags() int64

Flags returns the flags part of the version.

func (*Version) Major

func (v *Version) Major() int64

Major returns the major part of the version.

func (*Version) Minor

func (v *Version) Minor() int64

Minor returns the minor part of the version.

func (*Version) Revision

func (v *Version) Revision() int64

Revision returns the revision part of the version.

Jump to

Keyboard shortcuts

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