Skip to content
Jerome Leclanche edited this page Sep 25, 2015 · 8 revisions

The HSReplay XML format

HSReplay is a Hearthstone replay format based on the Power.log file format.

The main.py script can process one or more games as input from a Power.log or output_log.txt file, and output a valid HSReplay XML document.

The basics:

  • The root element is <HSReplay> and carries a version attribute (for the spec), and optionally a build attribute for the Hearthstone build.
  • Each game is contained within a <Game> tag.
  • All non-root tags may have a ts attribute, which denotes the timestamp at which the action happened. This tag is entirely optional, and may be omitted on any number of tags. The timestamp may be one of three formats:
  • hh:mm:ss.mmmmmmm (eg. 10:25:12.6444350), as output by the original Power.log
  • hh:mm:ss (eg. 10:25:12)
  • A UNIX epoch with second resolution (eg. 1440150278). Note that it is generally impossible to get the full datetime from the Power.log file, hence why this isn't default.

For validation, a DTD is available in the repository: https://github.com/HearthSim/HSReplay/blob/master/powerlog.dtd

Entity IDs

All entity entities (as denoted by the DTD) represent and entity ID. This is a numeric ID which should point to an entity's id which has been previously declared in the id attribute of a GameEntity, Player or FullEntity element. If the entity ID is not fully numeric, it is the nickname of a player. This is not recommended but an unfortunate consequence of the structuring of Power.log. The Player's entity ID may be obtained through the ENTITY_ID TagChange which happens early during a game's creation.

Game Tags

Some elements can contain a GameTag as a tag attribute. This is a GameTag. It must expressed as a numeric value. The full list of enums supported by the game is available in the HearthSim/python-hearthstone repository. Tag values should always be integers. Non-integer values for tag GameTag values is reserved for possible future use. The Power.log format outputs human-readable string values for some tag types. Code to parse those back into their numeric format is available here.

Tag list

Data

GameEntity

Defines a base Game entity at the beginning of a game. The equivalent of GameEntity in Power.log. Has a required id attribute, equivalent to the EntityID (supposedly will always be 1). In full games, should always be the first child of the Game element. Contains any number of Tag tags.

Player

Defines a Player entity at the beginning of a game. Has a required id and playerID attribute, as set by Power.log. Has optional accountHi and accountLo attributes. Has optional name attribute which can be guessed with stateful parsing of the log files. Contains any number of Tag tags.

FullEntity

Defines a card entity. Has a required id attribute. Has an optional cardID attribute. Contains any number of Tag tags. If the cardID attribute is not set, the card is considered hidden until a ShowEntity matching it is received.

ShowEntity

Discovers a previously-hidden card entity. The cardID attribute is expected. The entity attribute is required. Contains any number of Tag elements.

HideEntity

The opposite of ShowEntity, hides a previously-revealed card entity. This is expected to set a GameTag on the entity attribute through the tag and value attributes.

Action

A container for a game action (an event in the game). The entity attribute is required. The type attribute is required and contains the type of action. The index attribute is optional and defaults to -1 (which may then be ignored), and contains the index at which the action was performed. The target contains an entity ID and defaults to 0. Can contain any amount of TagChange, MetaData or nested Action tags.

TagChange

Defines a change in the value of a game tag. The required entity attribute points to the entity in question. The required tag attribute is a game tag. The required value attribute contains the new value of the tag.

Tag

Contains a tag/value pair, as defined in the GameTags section. Both the tag and value attributes are required.

MetaData

Contains a META_DATA token of information. The meta, data and info attributes are all required and correspond to their respective attributes in Power.log. The data attribute is supposedly an entity ID.

Player Choices

Some player input involves choices. This is seen every game during mulligan, as well as with Druid "Choose One" cards as well as Tracking. This subsystem may not be omitted.

Choices

Represents a set of choices the player has. The type attribute is required and represents, using a numeric ChoiceType value, the type of choice the player has (MULLIGAN lets you choose more than one card, while GENERIC only lets you choose one). The min and max attributes represent the minimum and maximum index of the choices and may be omitted. The entity attribute is required and represents the choosing player's entity ID. The source attribute is required and represents the entity ID of the source of the choice (1 for mulligans, iow the Game entity). The playerID attribute is required and represents the player ID of the choosing player. Contains one or more Choice elements.

SendChoices

Represents a set of choices the player chose. Contains one or more Choice elements. The entity and type attributes are both required and function like in Choices.

Choice

Represents a single choice, either proposed in Choices or chosen in SendChoices. The entity and index attributes are both required.

Player Options

Player options are the available options during a player's turn. There are multiple types of options and they are indexed from 0. Option #0 is always END_TURN. Options may be omitted entirely from the log, but should not be omitted arbitrarily.

Options

Contains any number of Option tags available to the player. The id attribute is optional, although recommended, and represents the sequential option ID as played in the game.

Option

Represents a single option. Both the index attribute and the type attribute are required. The entity attribute is required except for the END_TURN option type. May contain any number of Target or SubOption elements.

SubOption

Represents a sub-option for the option. The entity and index attributes are both required. May contain any number of Target elements.

Target

Represents an available target for the option or sub-option. The entity and index attributes are both required. May not contain any sub-elements.

SendOption

This standalone tag represents an option being sent. The option attribute represents the index of the option that was picked. The position attribute defaults to 0 and may be omitted if it is default. The subOption attribute may be omitted if no sub-option was picked (equal to -1). The target attribute represents an entity ID, and may be omitted if no target was picked (equal to 0).