Skip to content

Commit 843ffb4

Browse files
committed
Found the actual completion time and game length
1 parent a2060a4 commit 843ffb4

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

sc2reader/resources.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -420,11 +420,14 @@ class GameSummary(Resource):
420420
#: Game speed
421421
game_speed = str()
422422

423-
#: ? time, unknown what this represents, but it's close to game completion time
424-
#: unix
425-
time1 = int()
426-
#: time2 seems to be more accurate than time1
427-
time2 = int()
423+
#: Game length (real-time)
424+
game_length = int()
425+
426+
#: Game length (in-game)
427+
game_length_ingame = int()
428+
429+
#: Game completion time
430+
time = int()
428431

429432
#: Players, a dict of :class`PlayerSummary` from the game
430433
players = list()
@@ -455,11 +458,13 @@ def __init__(self, summary_file, filename=None, **options):
455458
# time struct looks like this:
456459
# { 0: 11987, 1: 283385849, 2: 1334719793L}
457460
# 0, 1 might be an adjustment of some sort
458-
self.time1 = self.parts[0][2][2]
461+
self.unknown_time = self.parts[0][2][2]
459462

460463
# this one is alone
461-
# but there is an int above it @ parts[0][7]
462-
self.time2 = self.parts[0][8]
464+
self.time = self.parts[0][8]
465+
466+
self.game_length_ingame = self.parts[0][7]
467+
self.game_length = self.game_length_ingame / GAME_SPEED_FACTOR[self.game_speed]
463468

464469
# Parse player structs, 16 is the maximum amount of players
465470
for i in range(16):
@@ -527,8 +532,11 @@ def __init__(self, summary_file, filename=None, **options):
527532
self.image_urls.append(self.base_url_template.format(parsed_hash['server'], parsed_hash['hash'], parsed_hash['type']))
528533

529534
def __str__(self):
530-
return "{} - {}".format(time.ctime(self.time2),
531-
''.join(p.race[0] for p in self.players))
535+
return "{} - {}:{}:{} {}".format(time.ctime(self.time),
536+
int(self.game_length)/3600,
537+
int(self.game_length)/60,
538+
int(self.game_length)%60,
539+
''.join(p.race[0] for p in self.players))
532540

533541
class MapInfo(Resource):
534542
url_template = 'http://{0}.depot.battle.net:1119/{1}.s2mi'

0 commit comments

Comments
 (0)