-
Notifications
You must be signed in to change notification settings - Fork 86
Datastructure
Data structures in sc2reader (draft) Basing this half on sc2reader, half on obslib; just to get a clear and concise external interface
The main function to read a replay has the following signature:
Replay read (string location, read_details=True, read_messages=True, read_events=True, processors=DEFAULT_PROCESSORS)
In the default run, the entire replay file is read and processed with a couple of default processors.
- basic is the header which contains the StarCraft2 version which created the replay and the length of the replay. This data is always read.
- details are the player and game details; it entails the players, matchup, teams, map and play date.
- messages are all in-game chat elements.
- events are all game events, this is the actual data needed for replaying the game.
If any of these keyword arguments gets switched of, the corresponding attributes on the objects will not be available.
processors is a list of post-processing objects which puzzle together more aspects of the game by analysing the game events. A good example is the calculation of APM, which is not recorded in the game events, but is calculated from them.
TODO Which default processors?
These are the objects which the default read uses.
Main class representing a replay file. Replays can be partially loaded, in which case not all attributes are available.
Base: always available
Version info
-
tupleversion Tuple with version numbers (major, minor, revision, build number). -
stringrelease String created from version (major.minor.revision.build).convenience -
integerbuild Build number which created the replay file.convenience
Duration/Length
-
integerframes Length of replay in frames (1/16th of a game second). -
integerseconds Length of replay in game seconds.convenience -
tuplelength Length of replay in (minutes, seconds) tuple.convenience
Details attributes
-
stringmap Name of the map played on. This will get normalised to the English name of the map (if known). -
datetimeplayed datetime instance of time the game started (localised, containing timezone info). -
stringformat (1v1,2v2,3v3,4v4,ffa) Format of the game. -
stringtype (public,private,ladder,singleplayer) Type of the game; public and private are custom maps, ladder is also known as AMM (automatic match maker). -
stringspeed (slower,slow,normal,fast,faster) Speed of the game. -
stringrealm (NA,EU,KR,SEA,PTR) Realm/gateway on which the game was played.
Matchup attributes
-
listteams List containing the teams playing in this game; teams are again lists ofPlayerinstances. Team lists are ordered according to the game (index 0 is team 1, etc.). -
listclients List containing all clients in this game (Clientinstances), contains players, observers and referees. -
listplayers List containing the players in this game (Playerinstances).convenience -
listobservers List containing the observers in this game (Observerinstances).convenience -
listreferees (??) List containing the referees in this game (Refereeinstances).convenience
Matchup properties convenience
-
stringrace_matchup String containing the first letters of the races joined with 'v', for example:ZvPorZTvPp. Lowercase indicates random was chosen as race. -
stringteam_matchup String containing the names of the players in teams, for example:ShadesOfGraylin vs. fizzgigorPlayer A, Player B vs. Player C, Player D. -
stringgame_filename Suggested filename for this replay; format isY.M.D.hhmm.<team_matchup>.<map>.sc2replay. Team matchup is a compressed version (A+B+C.vs.D+E+F).
Message attributes
-
listmessages List containing all in-game messages (Messageinstances).
Event attributes
-
listevents List containing all game events (Eventinstances).
...
Base class for players, observers and referees.
-
stringname Name used by the client in the replay. -
Replayreplay Replay this client is part of.convenience
...
extends Client
extends Client
extends Client
-
stringrace (Terran,Protoss,Zerg) Actual race played in game. -
booleanis_random Indicates this player chose random race in lobby. -
integerteam Team number (1-based).
Battle.net information
-
integeruser_id Battle.net user id. -
integersubregion Battle.net user subregion. -
stringrealm (NA,EU,KR,SEA) Realm/gateway of player (same as replay).convenience -
stringprofile_url URL to battle.net profile.convenience
Event-based attributes
-
listabilities_used List of (integerframe,stringability, [listobjects]) tuples indicating ability use? -
listobjects List ofGameObjectinstances indicating the units and buildings the player selected during play. -
Selectionselection Object representing all selections during gameplay;Selectionis a dict-like object with frame as key. -
listhotkeys List ofSelectionobjects representing hotkeys 0-9.
Selectable object in the game like a unit or building.
-
Playerplayer (optional) Player owning this object. -
tupleobserved (integer,integer) tuple denoting when object was first and last seen. -
TimeDictobject_type ATimeDictdictionary containing information about which object type (morphs, upgrades) this object had at a specific frame.
-
booleanalive_at (integerframe) -
booleanalive_between (integerfrom,integerto)
Selection is a subclass of dict and uses an integer frame as key. It interpolates the data, so querying a frame between set keys X and Y results in the data set for X.
Selection keeps all data (in values) ordered by object id. This is based on the internal ordering used in the replay file.
Class methods are used as helper-functions on selections represented by lists (do not modify anything on Selection instances)
-
listreplace (listselection,listindexes) Replace selection with just the indexes given in indexes; for example selection [4,5,6] with indexes [1,2] yields [5,6]. -
listdeselect (listselection,listindexes) Deselect objects on indexes in selection; for example selection [4,5,6] with indexes [1,2] yields [4]. -
listmask (listselection,listmask) Deselect objects on the mask in selection; for example selection [4,5,6] with mask [True,False,True] yields [4,6].
Events are in-game events like selecting units or moving the camera.
-
Clientclient (optional) Client owning this object. If not set, the event was global. -
integerframe Time the event occurred.
Messages are handled outside of other events in the replay file.
-
integersent Frame the message was sent. -
ClientsenderClientwhich sent the message. -
stringtarget (all,allies) Target of the message. -
stringmessage Contents of the message.
These describe what the built-in (possibly optional) post-processors add to the model. I think processors should have their own docs (except for ones in the default processor list, because they modify the structures by default :-))
TODO ... adds winner attributes ... also: winner might be recorded in replayfile somewhere?
TODO ... adds apm, aps and other APM attributes ...
TODO ... figures out which client recorded the replay ...
TODO ... adds compositions to Player objects ...
TODO ... adds hotkey setup to Player objects
TODO ... adds some fancy probabilities/hack detects to Player objects or Event objects ...