s2prot: github.com/icza/s2prot/rep Index | Files

package rep

import "github.com/icza/s2prot/rep"

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

Package Files

attrevts.go details.go doc.go header.go initdata.go metadata.go rep.go trackerevts.go types.go

Constants

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
)
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

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

Message event ids

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

Tracker event ids

Variables

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")
)
var (
    GameModeAutoMM       = GameModes[0]
    GameModePrivate      = GameModes[1]
    GameModePublic       = GameModes[2]
    GameModeSinglePlayer = GameModes[3]
    GameModeUnknown      = GameModes[4]
)

Named game modes.

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

Named game speeds.

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

Named races.

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

Named results.

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

Named controls.

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.

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.

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.

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.

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.

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.

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

Named expansion levels.

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.

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"]

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"]

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.

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.

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"]

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.

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"]

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

Races is the slice of all races.

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.

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"]

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"]

func MPQ Uses

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.

type AttrEvts Uses

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

AttrEvts contains game attributes.

func NewAttrEvts Uses

func NewAttrEvts(s s2prot.Struct) AttrEvts

NewAttrEvts creates a new attributes events from the specified Struct.

func (*AttrEvts) GameMode Uses

func (a *AttrEvts) GameMode() *GameMode

GameMode returns the game mode

func (*AttrEvts) MapNamespace Uses

func (a *AttrEvts) MapNamespace() string

MapNamespace returns the map namespace.

func (*AttrEvts) Source Uses

func (a *AttrEvts) Source() string

Source returns the source.

type BnetLang Uses

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 Uses

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 Uses

func (c *CacheHandle) FileName() string

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

func (*CacheHandle) RelativeFile Uses

func (c *CacheHandle) RelativeFile() string

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

func (*CacheHandle) StandardData Uses

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 Uses

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 Uses

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

Control type.

type Details Uses

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

Details describles the game details (overall replay details).

func (*Details) CacheHandles Uses

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

CacheHandles returns the array of cache handles.

func (*Details) CampaignIndex Uses

func (d *Details) CampaignIndex() int64

CampaignIndex returns the campaign index.

func (*Details) DefaultDifficulty Uses

func (d *Details) DefaultDifficulty() int64

DefaultDifficulty returns the default difficulty.

func (*Details) Description Uses

func (d *Details) Description() string

Description returns the description.

func (*Details) Difficulty Uses

func (d *Details) Difficulty() string

Difficulty returns the difficulty.

func (*Details) GameSpeed Uses

func (d *Details) GameSpeed() *GameSpeed

GameSpeed returns the game speed.

func (*Details) ImageFilePath Uses

func (d *Details) ImageFilePath() string

ImageFilePath returns the image file path.

func (*Details) IsBlizzardMap Uses

func (d *Details) IsBlizzardMap() bool

IsBlizzardMap tells if the map is an official Blizzard map.

func (*Details) MapFileName Uses

func (d *Details) MapFileName() string

MapFileName returns the name of the map file.

func (*Details) Matchup Uses

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 Uses

func (d *Details) MiniSave() bool

MiniSave returns if mini save.

func (*Details) ModPaths Uses

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

ModPaths returns the mod paths.

func (*Details) Players Uses

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

Players returns the list of players.

func (*Details) RestartAsTransitionMap Uses

func (d *Details) RestartAsTransitionMap() bool

RestartAsTransitionMap returns if restart as transition map.

func (*Details) ThumbnailFile Uses

func (d *Details) ThumbnailFile() string

ThumbnailFile returns the map thumbnail file name.

func (*Details) Time Uses

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

Time returns the replay date+time.

func (*Details) TimeLocalOffset Uses

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

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

func (*Details) TimeUTC Uses

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

TimeUTC returns the replay date+time - localOffset

func (*Details) Title Uses

func (d *Details) Title() string

Title returns the map name.

type Enum Uses

type Enum struct {
    Name string
}

Enum is the base of enum-like types.

func (Enum) String Uses

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 Uses

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 Uses

type GameDescription struct {
    s2prot.Struct

    GameOptions GameOptions
    // contains filtered or unexported fields
}

GameDescription is the game description

func (*GameDescription) CacheHandles Uses

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

CacheHandles returns the array of cache handles.

func (*GameDescription) DefaultAIBuild Uses

func (g *GameDescription) DefaultAIBuild() int64

DefaultAIBuild returns the default AI build.

func (*GameDescription) DefaultDifficulty Uses

func (g *GameDescription) DefaultDifficulty() int64

DefaultDifficulty returns the default difficulty.

func (*GameDescription) ExpLevel Uses

func (g *GameDescription) ExpLevel() *ExpLevel

ExpLevel returns the expansion level of the replay.

func (*GameDescription) GameCacheName Uses

func (g *GameDescription) GameCacheName() string

GameCacheName returns the game cache name.

func (*GameDescription) GameSpeed Uses

func (g *GameDescription) GameSpeed() *GameSpeed

GameSpeed returns the game speed.

func (*GameDescription) GameType Uses

func (g *GameDescription) GameType() int64

GameType returns the game type.

func (*GameDescription) HasExtensionMod Uses

func (g *GameDescription) HasExtensionMod() bool

HasExtensionMod returns if the game has extension mod.

func (*GameDescription) HasNonBlizzardExtensionMod Uses

func (g *GameDescription) HasNonBlizzardExtensionMod() bool

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

func (*GameDescription) IsBlizzardMap Uses

func (g *GameDescription) IsBlizzardMap() bool

IsBlizzardMap tells if the map is an official Blizzard map.

func (*GameDescription) IsCoopMode Uses

func (g *GameDescription) IsCoopMode() bool

IsCoopMode tells if the game is coop mode.

func (*GameDescription) IsPremadeFFA Uses

func (g *GameDescription) IsPremadeFFA() bool

IsPremadeFFA tells if the game is pre-made FFA.

func (*GameDescription) MapAuthorName Uses

func (g *GameDescription) MapAuthorName() string

MapAuthorName returns the name of the map author.

func (*GameDescription) MapFileName Uses

func (g *GameDescription) MapFileName() string

MapFileName returns the name of the map file.

func (*GameDescription) MapFileSyncChecksum Uses

func (g *GameDescription) MapFileSyncChecksum() int64

MapFileSyncChecksum returns the map file sync checksum.

func (*GameDescription) MapSizeX Uses

func (g *GameDescription) MapSizeX() int64

MapSizeX returns the map width.

func (*GameDescription) MapSizeY Uses

func (g *GameDescription) MapSizeY() int64

MapSizeY returns the map height.

func (*GameDescription) MaxColors Uses

func (g *GameDescription) MaxColors() int64

MaxColors returns the max colors.

func (*GameDescription) MaxControls Uses

func (g *GameDescription) MaxControls() int64

MaxControls returns the max controls.

func (*GameDescription) MaxObservers Uses

func (g *GameDescription) MaxObservers() int64

MaxObservers returns the max observers.

func (*GameDescription) MaxPlayers Uses

func (g *GameDescription) MaxPlayers() int64

MaxPlayers returns the max players.

func (*GameDescription) MaxRaces Uses

func (g *GameDescription) MaxRaces() int64

MaxRaces returns the max races.

func (*GameDescription) MaxTeams Uses

func (g *GameDescription) MaxTeams() int64

MaxTeams returns the max teams.

func (*GameDescription) MaxUsers Uses

func (g *GameDescription) MaxUsers() int64

MaxUsers returns the max users.

func (*GameDescription) ModFileSyncChecksum Uses

func (g *GameDescription) ModFileSyncChecksum() int64

ModFileSyncChecksum returns the mod file sync checksum.

func (*GameDescription) RandomValue Uses

func (g *GameDescription) RandomValue() int64

RandomValue returns the random value.

func (*GameDescription) Region Uses

func (g *GameDescription) Region() *Region

Region returns the region of the replay.

func (*GameDescription) SlotDescriptions Uses

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

SlotDescriptions returns the array of slot descriptions.

type GameMode Uses

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

GameMode is the game mode type

type GameOptions Uses

type GameOptions struct {
    s2prot.Struct
}

GameOptions is the game options

func (*GameOptions) AdvancedSharedControl Uses

func (g *GameOptions) AdvancedSharedControl() bool

AdvancedSharedControl returns if advanced shared control.

func (*GameOptions) Amm Uses

func (g *GameOptions) Amm() bool

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

func (*GameOptions) BattleNet Uses

func (g *GameOptions) BattleNet() bool

BattleNet returns if game was played on Battle.net.

func (*GameOptions) ClientDebugFlags Uses

func (g *GameOptions) ClientDebugFlags() int64

ClientDebugFlags returns the client debug flags.

func (*GameOptions) CompetitiveOrRanked Uses

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 Uses

func (g *GameOptions) Cooperative() bool

Cooperative returns if cooperative.

func (*GameOptions) Fog Uses

func (g *GameOptions) Fog() int64

Fog returns the fog.

func (*GameOptions) HeroDuplicatesAllowed Uses

func (g *GameOptions) HeroDuplicatesAllowed() bool

HeroDuplicatesAllowed returns if hero duplicates are allowed.

func (*GameOptions) LockTeams Uses

func (g *GameOptions) LockTeams() bool

LockTeams returns if teams are locked.

func (*GameOptions) NoVictoryOrDefeat Uses

func (g *GameOptions) NoVictoryOrDefeat() bool

NoVictoryOrDefeat returns if no victory or defeat.

func (*GameOptions) Observers Uses

func (g *GameOptions) Observers() int64

Observers returns the observers.

func (*GameOptions) Practice Uses

func (g *GameOptions) Practice() bool

Practice returns if practice.

func (*GameOptions) RandomRaces Uses

func (g *GameOptions) RandomRaces() bool

RandomRaces returns if random races.

func (*GameOptions) TeamsTogether Uses

func (g *GameOptions) TeamsTogether() bool

TeamsTogether returns if teams together.

func (*GameOptions) UserDifficulty Uses

func (g *GameOptions) UserDifficulty() int64

UserDifficulty returns the user difficulty.

type GameSpeed Uses

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 Uses

func (h *Header) BaseBuild() int64

BaseBuild returns the base build.

func (*Header) DataBuildNum Uses

func (h *Header) DataBuildNum() int64

DataBuildNum returns the data build number.

func (*Header) Duration Uses

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

Duration returns the game duration.

func (*Header) Loops Uses

func (h *Header) Loops() int64

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

func (*Header) NgdpRootKey Uses

func (h *Header) NgdpRootKey() string

NgdpRootKey returns the data ngdp root key.

func (*Header) ReplayCompatibilityHash Uses

func (h *Header) ReplayCompatibilityHash() string

ReplayCompatibilityHash returns the replay compatibility hash.

func (*Header) Signature Uses

func (h *Header) Signature() string

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

func (*Header) Type Uses

func (h *Header) Type() int64

Type returns the type.

func (*Header) UseScaledTime Uses

func (h *Header) UseScaledTime() bool

UseScaledTime returns whether scaled time is used.

func (*Header) Version Uses

func (h *Header) Version() Version

Version returns the version of the replay.

func (*Header) VersionString Uses

func (h *Header) VersionString() string

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

type InitData Uses

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 Uses

func NewInitData(s s2prot.Struct) InitData

NewInitData creates a new init data from the specified Struct.

type League Uses

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 Uses

type LobbyState struct {
    s2prot.Struct

    Slots []Slot
}

LobbyState is the lobby state

func (*LobbyState) DefaultAIBuild Uses

func (l *LobbyState) DefaultAIBuild() int64

DefaultAIBuild returns the default AI build.

func (*LobbyState) DefaultDifficulty Uses

func (l *LobbyState) DefaultDifficulty() int64

DefaultDifficulty returns the default difficulty.

func (*LobbyState) GameDuration Uses

func (l *LobbyState) GameDuration() int64

GameDuration returns the game duration.

func (*LobbyState) HostUserID Uses

func (l *LobbyState) HostUserID() int64

HostUserID returns the host user ID.

func (*LobbyState) IsSinglePlayer Uses

func (l *LobbyState) IsSinglePlayer() bool

IsSinglePlayer tells if game is single player.

func (*LobbyState) MaxObservers Uses

func (l *LobbyState) MaxObservers() int64

MaxObservers returns the max observers.

func (*LobbyState) MaxUsers Uses

func (l *LobbyState) MaxUsers() int64

MaxUsers returns the max users.

func (*LobbyState) Phase Uses

func (l *LobbyState) Phase() int64

Phase returns the phase.

func (*LobbyState) PickedMapTag Uses

func (l *LobbyState) PickedMapTag() int64

PickedMapTag returns the picked map tag.

func (*LobbyState) RandomSeed Uses

func (l *LobbyState) RandomSeed() int64

RandomSeed returns the random seed.

type MetaPlayer Uses

type MetaPlayer struct {
    s2prot.Struct
}

MetaPlayer describes a player in the metadata section.

func (*MetaPlayer) APM Uses

func (m *MetaPlayer) APM() float64

APM returns the player's APM value.

func (*MetaPlayer) AssignedRace Uses

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 Uses

func (m *MetaPlayer) MMR() float64

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

func (*MetaPlayer) PlayerID Uses

func (m *MetaPlayer) PlayerID() int64

PlayerID returns the player ID.

func (*MetaPlayer) Result Uses

func (m *MetaPlayer) Result() string

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

func (*MetaPlayer) SelectedRace Uses

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 Uses

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

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

func (*Metadata) BaseBuild Uses

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 Uses

func (m *Metadata) DataBuild() string

DataBuild returns the data build version string.

func (*Metadata) DurationSec Uses

func (m *Metadata) DurationSec() float64

DurationSec returns the game duration in seconds.

func (*Metadata) GameVersion Uses

func (m *Metadata) GameVersion() string

GameVersion returns the game version string.

func (*Metadata) Players Uses

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

Players returns the list of meta players.

func (*Metadata) Title Uses

func (m *Metadata) Title() string

Title returns the map name.

type Observe Uses

type Observe struct {
    Enum
}

Observe type.

type Player Uses

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 Uses

func (p *Player) Control() *Control

Control returns the control.

func (*Player) Handicap Uses

func (p *Player) Handicap() int64

Handicap returns the handicap.

func (*Player) Hero Uses

func (p *Player) Hero() string

Hero returns the hero.

func (*Player) Observe Uses

func (p *Player) Observe() *Observe

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

func (*Player) Race Uses

func (p *Player) Race() *Race

Race returns the race.

func (*Player) RaceString Uses

func (p *Player) RaceString() string

RaceString returns the localized race string.

func (*Player) Result Uses

func (p *Player) Result() *Result

Result returns the game result.

func (*Player) TeamID Uses

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 Uses

func (p *Player) WorkingSetSlotID() int64

WorkingSetSlotID returns the working set slot ID.

type PlayerDesc Uses

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 Uses

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

Race type.

type Realm Uses

type Realm struct {
    Enum
}

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

type Region Uses

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 Uses

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

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

type Rep Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

func (r *Rep) Close() error

Close closes the Rep and its resources.

type Result Uses

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

Result type.

type Slot Uses

type Slot struct {
    s2prot.Struct
}

Slot describes a slot

func (*Slot) AIBuild Uses

func (s *Slot) AIBuild() int64

AIBuild returns the AI build.

func (*Slot) Artifacts Uses

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

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

func (*Slot) ColorPrefColor Uses

func (s *Slot) ColorPrefColor() *Color

ColorPrefColor returns the color preference color.

func (*Slot) Commander Uses

func (s *Slot) Commander() string

Commander returns the commander.

func (*Slot) CommanderLevel Uses

func (s *Slot) CommanderLevel() int64

CommanderLevel returns the commander level.

func (*Slot) CommanderMasteryLevel Uses

func (s *Slot) CommanderMasteryLevel() int64

CommanderMasteryLevel returns the commander mastery level.

func (*Slot) CommanderMasteryTalents Uses

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

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

func (*Slot) Control Uses

func (s *Slot) Control() *Control

Control returns the control.

func (*Slot) Difficulty Uses

func (s *Slot) Difficulty() int64

Difficulty returns the difficulty.

func (*Slot) Handicap Uses

func (s *Slot) Handicap() int64

Handicap returns the handicap.

func (*Slot) HasSilencePenalty Uses

func (s *Slot) HasSilencePenalty() bool

HasSilencePenalty returns if there is slience penalty.

func (*Slot) Hero Uses

func (s *Slot) Hero() string

Hero returns the hero.

func (*Slot) Licenses Uses

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

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

func (*Slot) LogoIndex Uses

func (s *Slot) LogoIndex() int64

LogoIndex returns the logo index.

func (*Slot) Mount Uses

func (s *Slot) Mount() string

Mount returns the mount.

func (*Slot) Observe Uses

func (s *Slot) Observe() *Observe

Observe returns the observe.

func (*Slot) RacePrefRace Uses

func (s *Slot) RacePrefRace() *Race

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

func (*Slot) Rewards Uses

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

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

func (*Slot) Skin Uses

func (s *Slot) Skin() string

Skin returns the skin.

func (*Slot) TandemID Uses

func (s *Slot) TandemID() int64

TandemID returns the tandem ID.

func (*Slot) TandemLeaderUserID Uses

func (s *Slot) TandemLeaderUserID() int64

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

func (*Slot) TeamID Uses

func (s *Slot) TeamID() int64

TeamID returns the team ID.

func (*Slot) ToonHandle Uses

func (s *Slot) ToonHandle() string

ToonHandle returns the toon handle.

func (*Slot) UserID Uses

func (s *Slot) UserID() int64

UserID returns the user ID.

func (*Slot) WorkingSetSlotID Uses

func (s *Slot) WorkingSetSlotID() int64

WorkingSetSlotID returns the working set slot ID.

type SlotDescription Uses

type SlotDescription struct {
    s2prot.Struct
}

SlotDescription is the slot description

func (*SlotDescription) AllowedAIBuilds Uses

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

AllowedAIBuilds returns the allowed AI builds bitmap.

func (*SlotDescription) AllowedColors Uses

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

AllowedColors returns the allowed colors bitmap.

func (*SlotDescription) AllowedControls Uses

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

AllowedControls returns the allowed controls bitmap.

func (*SlotDescription) AllowedDifficulty Uses

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

AllowedDifficulty returns the allowed difficulty bitmap.

func (*SlotDescription) AllowedObserveTypes Uses

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

AllowedObserveTypes returns the allowed observe types bitmap.

func (*SlotDescription) AllowedRaces Uses

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

AllowedRaces returns the allowed races bitmap.

type Toon Uses

type Toon struct {
    s2prot.Struct
}

Toon - a unique identifier (of a player)

func (*Toon) ID Uses

func (t *Toon) ID() int64

ID returns the ID.

func (*Toon) ProgramID Uses

func (t *Toon) ProgramID() string

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

func (*Toon) Realm Uses

func (t *Toon) Realm() *Realm

Realm returns the realm.

func (*Toon) RealmID Uses

func (t *Toon) RealmID() int64

RealmID returns the realm ID.

func (*Toon) Region Uses

func (t *Toon) Region() *Region

Region returns the region.

func (*Toon) RegionID Uses

func (t *Toon) RegionID() int64

RegionID returns the region ID.

func (Toon) String Uses

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 Uses

func (t *Toon) URL() string

URL returns the starcraft2.com url

type TrackerEvts Uses

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 Uses

type UserInitData struct {
    s2prot.Struct

     *CacheHandle // Cache handle of the clan logo image resource
}

UserInitData describes user initial data

func (*UserInitData) ClanTag Uses

func (u *UserInitData) ClanTag() string

ClanTag returns the clan tag.

func (*UserInitData) CombinedRaceLevels Uses

func (u *UserInitData) CombinedRaceLevels() int64

CombinedRaceLevels returns the combined race levels.

func (*UserInitData) CustomInterface Uses

func (u *UserInitData) CustomInterface() bool

CustomInterface tells if custom interface.

func (*UserInitData) Examine Uses

func (u *UserInitData) Examine() bool

Examine tells if examine.

func (*UserInitData) Hero Uses

func (u *UserInitData) Hero() string

Hero returns the hero.

func (*UserInitData) HighestLeague Uses

func (u *UserInitData) HighestLeague() *League

HighestLeague returns the highest league.

func (*UserInitData) MMR Uses

func (u *UserInitData) MMR() int64

MMR returns the mmr for the handle if set

func (*UserInitData) Mount Uses

func (u *UserInitData) Mount() string

Mount returns the mount.

func (*UserInitData) Name Uses

func (u *UserInitData) Name() string

Name returns the name.

func (*UserInitData) Observe Uses

func (u *UserInitData) Observe() *Observe

Observe returns the observe.

func (*UserInitData) RacePreferenceRace Uses

func (u *UserInitData) RacePreferenceRace() int64

RacePreferenceRace returns the race preference race.

func (*UserInitData) RandomSeed Uses

func (u *UserInitData) RandomSeed() int64

RandomSeed returns the random seed.

func (*UserInitData) Skin Uses

func (u *UserInitData) Skin() string

Skin returns the skin.

func (*UserInitData) TeamPreferenceTeam Uses

func (u *UserInitData) TeamPreferenceTeam() int64

TeamPreferenceTeam returns the team preference team.

func (*UserInitData) TestAuto Uses

func (u *UserInitData) TestAuto() bool

TestAuto tells if test auto.

func (*UserInitData) TestMap Uses

func (u *UserInitData) TestMap() bool

TestMap tells if test map.

func (*UserInitData) TestType Uses

func (u *UserInitData) TestType() int64

TestType returns the test type.

func (*UserInitData) ToonHandle Uses

func (u *UserInitData) ToonHandle() string

ToonHandle returns the toon handle.

type Version Uses

type Version struct {
    s2prot.Struct
}

Version of the replay.

func (*Version) BaseBuild Uses

func (v *Version) BaseBuild() int64

BaseBuild returns the base build part of the version.

func (*Version) Build Uses

func (v *Version) Build() int64

Build returns the build part of the version.

func (*Version) Flags Uses

func (v *Version) Flags() int64

Flags returns the flags part of the version.

func (*Version) Major Uses

func (v *Version) Major() int64

Major returns the major part of the version.

func (*Version) Minor Uses

func (v *Version) Minor() int64

Minor returns the minor part of the version.

func (*Version) Revision Uses

func (v *Version) Revision() int64

Revision returns the revision part of the version.

Package rep imports 12 packages (graph) and is imported by 1 packages. Updated 2020-12-20. Refresh now. Tools for package owners.