repcore

package
v1.12.9 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package repcore contains core types and utilities used for modeling StarCraft: Brood War replays.

Index

Constants

This section is empty.

Variables

View Source
var (
	EngineStarCraft = Engines[0]
	EngineBroodWar  = Engines[1]
)

Named engines

View Source
var (
	SpeedSlowest = Speeds[0]
	SpeedSlower  = Speeds[1]
	SpeedSlow    = Speeds[2]
	SpeedNormal  = Speeds[3]
	SpeedFast    = Speeds[4]
	SpeedFaster  = Speeds[5]
	SpeedFastest = Speeds[6]
)

Named speeds

View Source
var (
	GameTypeNone = GameTypes[0]

	GameTypeMelee       = GameTypes[2]
	GameTypeFFA         = GameTypes[3]
	GameType1on1        = GameTypes[4]
	GameTypeCTF         = GameTypes[5]
	GameTypeGreed       = GameTypes[6]
	GameTypeSlaughter   = GameTypes[7]
	GameTypeSuddenDeath = GameTypes[8]
	GameTypeLadder      = GameTypes[9]
	GameTypeUMS         = GameTypes[10]
	GameTypeTeamMelee   = GameTypes[11]
	GameTypeTeamFFA     = GameTypes[12]
	GameTypeTeamCTF     = GameTypes[13]

	GameTypeTvB           = GameTypes[15]
	GameTypeIronManLadder = GameTypes[16]
)

Named valid game types

View Source
var (
	PlayerTypeInactive           = PlayerTypes[0]
	PlayerTypeComputer           = PlayerTypes[1]
	PlayerTypeHuman              = PlayerTypes[2]
	PlayerTypeRescuePassive      = PlayerTypes[3]
	PlayerTypeUnused             = PlayerTypes[4]
	PlayerTypeComputerControlled = PlayerTypes[5]
	PlayerTypeOpen               = PlayerTypes[6]
	PlayerTypeNeutral            = PlayerTypes[7]
	PlayerTypeClosed             = PlayerTypes[8]
)

Named player types

View Source
var (
	RaceZerg    = Races[0]
	RaceTerran  = Races[1]
	RaceProtoss = Races[2]
)

Named races

View Source
var (
	ColorRed         = Colors[0]
	ColorBlue        = Colors[1]
	ColorTeal        = Colors[2]
	ColorPurple      = Colors[3]
	ColorOrange      = Colors[4]
	ColorBrown       = Colors[5]
	ColorWhite       = Colors[6]
	ColorYellow      = Colors[7]
	ColorGreen       = Colors[8]
	ColorPaleYellow  = Colors[9]
	ColorTan         = Colors[10]
	ColorAqua        = Colors[11]
	ColorPaleGreen   = Colors[12]
	ColorBlueishGrey = Colors[13]
	ColorPaleYellow2 = Colors[14] // Same as the other with same name
	ColorCyan        = Colors[15]
	ColorPink        = Colors[16]
	ColorOlive       = Colors[17]
	ColorLime        = Colors[18]
	ColorNavy        = Colors[19]
	ColorDarkAqua    = Colors[20]
	ColorMagenta     = Colors[21]
	ColorGrey        = Colors[22]
	ColorBlack       = Colors[23]
)

Named colors

View Source
var (
	TileSetBadlands      = TileSets[0]
	TileSetSpacePlatform = TileSets[1]
	TileSetInstallation  = TileSets[2]
	TileSetAshworld      = TileSets[3]
	TileSetJungle        = TileSets[4]
	TileSetDesert        = TileSets[5]
	TileSetArctic        = TileSets[6]
	TileSetTwilight      = TileSets[7]
)

Named tile sets

View Source
var (
	PlayerOwnerInactive              = PlayerOwners[0]
	PlayerOwnerComputerGame          = PlayerOwners[1]
	PlayerOwnerOccupiedByHumanPlayer = PlayerOwners[2]
	PlayerOwnerRescuePassive         = PlayerOwners[3]
	PlayerOwnerUnused                = PlayerOwners[4]
	PlayerOwnerComputer              = PlayerOwners[5]
	PlayerOwnerHumanOpenSlot         = PlayerOwners[6]
	PlayerOwnerNeutral               = PlayerOwners[7]
	PlayerOwnerClosedSlot            = PlayerOwners[8]
)

Named player owners

View Source
var (
	PlayerSideZerg               = PlayerSides[0]
	PlayerSideTerran             = PlayerSides[1]
	PlayerSideProtoss            = PlayerSides[2]
	PlayerSideInvalidIndependent = PlayerSides[3]
	PlayerSideInvalidNeutral     = PlayerSides[4]
	PlayerSideUserSelectable     = PlayerSides[5]
	PlayerSideRandomForced       = PlayerSides[6]
	PlayerSideInactive           = PlayerSides[7]
)

Named player sides

View Source
var Colors = []*Color{
	{Enum{"Red"}, 0x00, 0xf40404, []byte{0xf5, 0xf4, 0x74, 0x3f, 0x81, 0x80, 0x80, 0x3c, 0x81, 0x80, 0x80, 0x3c, 0x00, 0x00, 0x80, 0x3f}},
	{Enum{"Blue"}, 0x01, 0x0c48cc, []byte{0xc1, 0xc0, 0x40, 0x3d, 0x91, 0x90, 0x90, 0x3e, 0xcd, 0xcc, 0x4c, 0x3f, 0x00, 0x00, 0x80, 0x3f}},
	{Enum{"Teal"}, 0x02, 0x2cb494, []byte{0xb1, 0xb0, 0x30, 0x3e, 0xb5, 0xb4, 0x34, 0x3f, 0x95, 0x94, 0x14, 0x3f, 0x00, 0x00, 0x80, 0x3f}},
	{Enum{"Purple"}, 0x03, 0x88409c, []byte{0x89, 0x88, 0x08, 0x3f, 0x81, 0x80, 0x80, 0x3e, 0x9d, 0x9c, 0x1c, 0x3f, 0x00, 0x00, 0x80, 0x3f}},
	{Enum{"Orange"}, 0x04, 0xf88c14, []byte{0xf9, 0xf8, 0x78, 0x3f, 0x8d, 0x8c, 0x0c, 0x3f, 0xa1, 0xa0, 0xa0, 0x3d, 0x00, 0x00, 0x80, 0x3f}},
	{Enum{"Brown"}, 0x05, 0x703014, []byte{0xe1, 0xe0, 0xe0, 0x3e, 0xc1, 0xc0, 0x40, 0x3e, 0xa1, 0xa0, 0xa0, 0x3d, 0x00, 0x00, 0x80, 0x3f}},
	{Enum{"White"}, 0x06, 0xcce0d0, []byte{0xcd, 0xcc, 0x4c, 0x3f, 0xe1, 0xe0, 0x60, 0x3f, 0xd1, 0xd0, 0x50, 0x3f, 0x00, 0x00, 0x80, 0x3f}},
	{Enum{"Yellow"}, 0x07, 0xfcfc38, []byte{0xfd, 0xfc, 0x7c, 0x3f, 0xfd, 0xfc, 0x7c, 0x3f, 0xe1, 0xe0, 0x60, 0x3e, 0x00, 0x00, 0x80, 0x3f}},
	{Enum{"Green"}, 0x08, 0x088008, []byte{0x81, 0x80, 0x00, 0x3d, 0x81, 0x80, 0x00, 0x3f, 0x81, 0x80, 0x00, 0x3d, 0x00, 0x00, 0x80, 0x3f}},
	{Enum{"Pale Yellow"}, 0x09, 0xfcfc7c, []byte{0xfd, 0xfc, 0x7c, 0x3f, 0xfd, 0xfc, 0x7c, 0x3f, 0xf9, 0xf8, 0xf8, 0x3e, 0x00, 0x00, 0x80, 0x3f}},
	{Enum{"Tan"}, 0x0a, 0xecc4b0, []byte{0xed, 0xec, 0x6c, 0x3f, 0xc5, 0xc4, 0x44, 0x3f, 0xb1, 0xb0, 0x30, 0x3f, 0x00, 0x00, 0x80, 0x3f}},
	{Enum{"Aqua"}, 0x0b, 0x4068d4, nil},
	{Enum{"Pale Green"}, 0x0c, 0x74a47c, []byte{0xe9, 0xe8, 0xe8, 0x3e, 0xa5, 0xa4, 0x24, 0x3f, 0xf9, 0xf8, 0xf8, 0x3e, 0x00, 0x00, 0x80, 0x3f}},
	{Enum{"Blueish Grey"}, 0x0d, 0x9090b8, []byte{0xe5, 0xe4, 0xe4, 0x3e, 0x91, 0x90, 0x10, 0x3f, 0xb9, 0xb8, 0x38, 0x3f, 0x00, 0x00, 0x80, 0x3f}},
	{Enum{"Pale Yellow2"}, 0x0e, 0xfcfc7c, nil},
	{Enum{"Cyan"}, 0x0f, 0x00e4fc, []byte{0x00, 0x00, 0x00, 0x00, 0xe5, 0xe4, 0x64, 0x3f, 0xfd, 0xfc, 0x7c, 0x3f, 0x00, 0x00, 0x80, 0x3f}},
	{Enum{"Pink"}, 0x10, 0xffc4e4, []byte{0x00, 0x00, 0x80, 0x3f, 0xc5, 0xc4, 0x44, 0x3f, 0xe5, 0xe4, 0x64, 0x3f, 0x00, 0x00, 0x80, 0x3f}},
	{Enum{"Olive"}, 0x11, 0x787800, []byte{0x81, 0x80, 0x00, 0x3f, 0x81, 0x80, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f}},
	{Enum{"Lime"}, 0x12, 0xd2f53c, []byte{0xd3, 0xd2, 0x52, 0x3f, 0xf6, 0xf5, 0x75, 0x3f, 0xf1, 0xf0, 0x70, 0x3e, 0x00, 0x00, 0x80, 0x3f}},
	{Enum{"Navy"}, 0x13, 0x0000e6, []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x81, 0x80, 0x00, 0x3f, 0x00, 0x00, 0x80, 0x3f}},
	{Enum{"Dark Aqua"}, 0x14, 0x4068d4, []byte{0x81, 0x80, 0x80, 0x3e, 0xd1, 0xd0, 0xd0, 0x3e, 0xd5, 0xd4, 0x54, 0x3f, 0x00, 0x00, 0x80, 0x3f}},
	{Enum{"Magenta"}, 0x15, 0xf032e6, []byte{0xf1, 0xf0, 0x70, 0x3f, 0xc9, 0xc8, 0x48, 0x3e, 0xe7, 0xe6, 0x66, 0x3f, 0x00, 0x00, 0x80, 0x3f}},
	{Enum{"Grey"}, 0x16, 0x808080, []byte{0x81, 0x80, 0x00, 0x3f, 0x81, 0x80, 0x00, 0x3f, 0x81, 0x80, 0x00, 0x3f, 0x00, 0x00, 0x80, 0x3f}},
	{Enum{"Black"}, 0x17, 0x3c3c3c, []byte{0xf1, 0xf0, 0x70, 0x3e, 0xf1, 0xf0, 0x70, 0x3e, 0xf1, 0xf0, 0x70, 0x3e, 0x00, 0x00, 0x80, 0x3f}},
}

Colors is an enumeration of the possible colors

View Source
var Engines = []*Engine{
	{Enum{"StarCraft"}, 0x00, "SC"},
	{Enum{"Brood War"}, 0x01, "BW"},
}

Engines is an enumeration of the possible engines

View Source
var GameTypes = []*GameType{
	{Enum{"None"}, 0x00, "None"},
	{Enum{"Custom"}, 0x01, "Custom"},
	{Enum{"Melee"}, 0x02, "Melee"},
	{Enum{"Free For All"}, 0x03, "FFA"},
	{Enum{"One on One"}, 0x04, "1on1"},
	{Enum{"Capture The Flag"}, 0x05, "CTF"},
	{Enum{"Greed"}, 0x06, "Greed"},
	{Enum{"Slaughter"}, 0x07, "Slaughter"},
	{Enum{"Sudden Death"}, 0x08, "Sudden Death"},
	{Enum{"Ladder"}, 0x09, "Ladder"},
	{Enum{"Use map settings"}, 0x0a, "UMS"},
	{Enum{"Team Melee"}, 0x0b, "Team Melee"},
	{Enum{"Team Free For All"}, 0x0c, "Team FFA"},
	{Enum{"Team Capture The Flag"}, 0x0d, "Team CTF"},
	{UnknownEnum(0x0e), 0x0e, "Unk"},
	{Enum{"Top vs Bottom"}, 0x0f, "TvB"},
	{Enum{"Iron Man Ladder"}, 0x10, "Iron Man Ladder"},
}

GameTypes is an enumeration of the possible game types

View Source
var PlayerOwners = []*PlayerOwner{
	{Enum{"Inactive"}, 0x00},
	{Enum{"Computer (game)"}, 0x01},
	{Enum{"Occupied by Human Player"}, 0x02},
	{Enum{"Rescue Passive"}, 0x03},
	{Enum{"Unused"}, 0x04},
	{Enum{"Computer"}, 0x05},
	{Enum{"Human (Open Slot)"}, 0x06},
	{Enum{"Neutral"}, 0x07},
	{Enum{"Closed slot"}, 0x08},
}

PlayerOwners is an enumeration of the possible player owners

View Source
var PlayerSides = []*PlayerSide{
	{Enum{"Zerg"}, 0x00},
	{Enum{"Terran"}, 0x01},
	{Enum{"Protoss"}, 0x02},
	{Enum{"Invalid (Independent)"}, 0x03},
	{Enum{"Invalid (Neutral)"}, 0x04},
	{Enum{"User Selectable"}, 0x05},
	{Enum{"Random (Forced)"}, 0x06},
	{Enum{"Inactive"}, 0x07},
}

PlayerSides is an enumeration of the possible player sides

View Source
var PlayerTypes = []*PlayerType{
	{Enum{"Inactive"}, 0x00},
	{Enum{"Computer"}, 0x01},
	{Enum{"Human"}, 0x02},
	{Enum{"Rescue Passive"}, 0x03},
	{Enum{"(Unused)"}, 0x04},
	{Enum{"Computer Controlled"}, 0x05},
	{Enum{"Open"}, 0x06},
	{Enum{"Neutral"}, 0x07},
	{Enum{"Closed"}, 0x08},
}

PlayerTypes is an enumeration of the possible player types

View Source
var Races = []*Race{
	{Enum{"Zerg"}, 0x00, "zerg", 'Z'},
	{Enum{"Terran"}, 0x01, "ran", 'T'},
	{Enum{"Protoss"}, 0x02, "toss", 'P'},
}

Races is an enumeration of the possible races

View Source
var Speeds = []*Speed{
	{Enum{"Slowest"}, 0x00},
	{Enum{"Slower"}, 0x01},
	{Enum{"Slow"}, 0x02},
	{Enum{"Normal"}, 0x03},
	{Enum{"Fast"}, 0x04},
	{Enum{"Faster"}, 0x05},
	{Enum{"Fastest"}, 0x06},
}

Speeds is an enumeration of the possible speeds

View Source
var TileSets = []*TileSet{
	{Enum{"Badlands"}, 0x00},
	{Enum{"Space Platform"}, 0x01},
	{Enum{"Installation"}, 0x02},
	{Enum{"Ashworld"}, 0x03},
	{Enum{"Jungle"}, 0x04},
	{Enum{"Desert"}, 0x05},
	{Enum{"Arctic"}, 0x06},
	{Enum{"Twilight"}, 0x07},
}

TileSets is an enumeration of the possible tile sets

Functions

This section is empty.

Types

type Color

type Color struct {
	Enum

	// ID as it appears in replays
	ID uint32

	// RGB is the red, green, blue component of the color
	RGB uint32
	// contains filtered or unexported fields
}

Color describes a color.

func ColorByFootprint added in v1.5.1

func ColorByFootprint(footprint []byte) *Color

ColorByFootprint returns the Color for a given footprint. nil is returned if one is not found for the given footprint.

func ColorByID

func ColorByID(ID uint32) *Color

ColorByID returns the Color for a given ID. A new Color with Unknown name is returned if one is not found for the given ID (preserving the unknown ID).

type Engine

type Engine struct {
	Enum

	// ID as it appears in replays
	ID byte

	// ShortName is a shorter name
	ShortName string
}

Engine is the StarCraft engine / extension.

func EngineByID

func EngineByID(ID byte) *Engine

EngineByID returns the Engine for a given ID. A new Engine with Unknown name is returned if one is not found for the given ID (preserving the unknown ID).

type Enum

type Enum struct {
	// Name of the entity
	Name string
}

Enum is the base / common part of enum types.

func UnknownEnum

func UnknownEnum(ID any) Enum

UnknownEnum constructs a new Enum for an unknown entity with a name:

"Unknown 0xID"

ID must be an integer number.

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 used.

type Frame

type Frame int32

Frame is the basic time unit in StarCraft. There are approximately ~23.81 frames in a second; 1 frame = 0.042 second = 42 ms to be exact.

func Duration2Frame added in v1.4.0

func Duration2Frame(d time.Duration) Frame

Duration2Frame converts a Duration value to Frame.

func (Frame) Duration

func (f Frame) Duration() time.Duration

Duration returns the frame as a time.Duration value.

func (Frame) Milliseconds

func (f Frame) Milliseconds() int64

Milliseconds returns the time equivalent to the frames in milliseconds.

func (Frame) Seconds

func (f Frame) Seconds() float64

Seconds returns the time equivalent to the frames in seconds.

func (Frame) String added in v1.2.0

func (f Frame) String() string

String returns a human-friendly mm:ss representation, e.g. "03:12", or if the frame represents bigger than an hour: "1:02:03".

type GameType

type GameType struct {
	Enum

	// ID as it appears in replays
	ID uint16

	// ShortName is a shorter name
	ShortName string
}

GameType is the game type.

func GameTypeByID

func GameTypeByID(ID uint16) *GameType

GameTypeByID returns the GameType for a given ID. A new GameType with Unknown name is returned if one is not found for the given ID (preserving the unknown ID).

type IneffKind added in v1.3.1

type IneffKind byte

IneffKind classifies commands if and why they are ineffective.

const (
	// IneffKindEffective means the command is considered effective.
	IneffKindEffective IneffKind = iota

	// IneffKindUnitQueueOverflow means the command is ineffective due to unit queue overflow
	IneffKindUnitQueueOverflow

	// IneffKindFastCancel means the command is ineffective due to too fast cancel
	IneffKindFastCancel

	// IneffKindFastRepetition means the command is ineffective due to too fast repetition
	IneffKindFastRepetition

	// IneffKindFastReselection means the command is ineffective due to too fast selection change
	// or reselection
	IneffKindFastReselection

	// IneffKindRepetition means the command is ineffective due to repetition
	IneffKindRepetition

	// IneffKindRepetitionHotkeyAddAssign means the command is ineffective due to
	// repeating the same hotkey add or assign
	IneffKindRepetitionHotkeyAddAssign
)

func (IneffKind) Effective added in v1.3.1

func (k IneffKind) Effective() bool

Effective tells if the IneffKind represents Effective, that is, it's equal to IneffKindEffective.

func (IneffKind) String added in v1.3.1

func (k IneffKind) String() string

String returns a short string description.

type PlayerOwner added in v1.7.2

type PlayerOwner struct {
	Enum

	// ID as it appears in replays
	ID uint8
}

PlayerOwner describes a player owner.

func PlayerOwnerByID added in v1.7.2

func PlayerOwnerByID(ID uint8) *PlayerOwner

PlayerOwnerByID returns the PlayerOwner for a given ID. A new PlayerOwner with Unknown name is returned if one is not found for the given ID (preserving the unknown ID).

type PlayerSide added in v1.7.2

type PlayerSide struct {
	Enum

	// ID as it appears in replays
	ID uint8
}

PlayerSide describes a player side (race).

func PlayerSideByID added in v1.7.2

func PlayerSideByID(ID uint8) *PlayerSide

PlayerSideByID returns the PlayerSide for a given ID. A new PlayerSide with Unknown name is returned if one is not found for the given ID (preserving the unknown ID).

type PlayerType

type PlayerType struct {
	Enum

	// ID as it appears in replays
	ID byte
}

PlayerType describes a player (slot) type.

func PlayerTypeByID

func PlayerTypeByID(ID byte) *PlayerType

PlayerTypeByID returns the PlayerType for a given ID. A new PlayerType with Unknown name is returned if one is not found for the given ID (preserving the unknown ID).

type Point

type Point struct {
	// X and Y coordinates of the point
	// 1 Tile is 32 units (pixel)
	X, Y uint16
}

Point describes a point in the map.

func (Point) String

func (p Point) String() string

String returns a string representation of the point in the format:

"x=X, y=Y"

type Race

type Race struct {
	Enum

	// ID as it appears in replays
	ID byte

	// ShortName is a shorter name
	ShortName string

	// Letter is the letter of the race (first letter of its name)
	Letter rune
}

Race describes a race.

func RaceByID

func RaceByID(ID byte) *Race

RaceByID returns the Race for a given ID. A new Race with Unknown name is returned if one is not found for the given ID (preserving the unknown ID).

type Speed

type Speed struct {
	Enum

	// ID as it appears in replays
	ID byte
}

Speed is the game speed.

func SpeedByID

func SpeedByID(ID byte) *Speed

SpeedByID returns the Speed for a given ID. A new Speed with Unknown name is returned if one is not found for the given ID (preserving the unknown ID).

type TileSet

type TileSet struct {
	Enum

	// ID as it appears in replays
	ID uint16
}

TileSet describes a tile set.

func TileSetByID

func TileSetByID(ID uint16) *TileSet

TileSetByID returns the TileSet for a given ID. A new TileSet with Unknown name is returned if one is not found for the given ID (preserving the unknown ID).

Jump to

Keyboard shortcuts

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