util — Utility Functions

Contains a number of useful functions.

metrics.util.convert_to_gametime_r(replay, real_time_s)[source]

Converts the real time of a point in the replay to the internally calculated game time.

Parameters:
  • replay (sc2reader.replay) – The sc2reader replay object from which to convert the real time to.
  • real_time_s (int) – The real time in the replay in seconds.
Returns:

The game time in seconds.

Return type:

int

metrics.util.convert_to_realtime_r(replay, game_time_s)[source]

Converts the internally calculated game time of a point in the replay to the real time, as can be seen when watching a replay.

Parameters:
  • replay (sc2reader.replay) – The sc2reader replay object from which to convert the real time to.
  • game_time_s (int) – The game time internally calculated in the replay in seconds.
Returns:

The real time in seconds.

Return type:

int

metrics.util.is_hallucinated(unit)[source]

A special function used to bypass a bug found in sc2reader.Data.Unit.hallucinated, where the hallucinated property was not returning a correct boolean.

Parameters:unit (sc2reader.Data.Unit) – The Unit object.
Returns:True if the unit is hallucinated, False if it was not.
Return type:bool