@@ -424,6 +424,7 @@ class GameSummary(Resource):
424424 1001 : ('unknown3' , {'sey' :'yes' , 'on' :'no' }), #yes/no
425425 1000 : ('unknown4' , {'tlfD' :'Default' }), #Dflt
426426 2000 : ('unknown5' , {'2t' :'t2' , '3t' :'t3' , 'AFF' :'FFA' , 'tsuC' :'Custom' }), #t2/t3/FFA/Cust
427+ 3007 : ('unknown6' , {'traP' :'Part' }),
427428 3009 : ('lobby_type' , GAME_TYPE_CODES ) #Priv/Pub/Amm (Auto MatchMaking)
428429 }
429430 lobby_player_keys = {
@@ -432,7 +433,12 @@ class GameSummary(Resource):
432433 3003 : ('energy' , {'05' :'50' ,'06' :'60' ,'07' :'70' ,'08' :'80' ,'09' :'90' ,'001' :'100' }),
433434 3002 : ('color' , TEAM_COLOR_CODES ),
434435 3004 : ('difficulty' , DIFFICULTY_CODES ),
435- 3008 : ('nonplayer_mode' , {'sbO' :'Observer' ,'feR' :'Ref' }) #Obs/Ref
436+ 3008 : ('nonplayer_mode' , {'sbO' :'Observer' ,'feR' :'Ref' }), #Obs/Ref
437+
438+ #Team properties
439+ 2012 : ('team_t3' , {'1T' :'T1' , '2T' :'T2' , '3T' :'T3' }),
440+
441+
436442 }
437443
438444 #: Game speed
@@ -446,6 +452,9 @@ class GameSummary(Resource):
446452
447453 #: Lobby properties
448454 lobby_properties = dict ()
455+
456+ #: Lobby player properties
457+ lobby_player_properties = dict ()
449458
450459 #: Game completion time
451460 time = int ()
@@ -456,6 +465,9 @@ class GameSummary(Resource):
456465 #: Teams, a dict of pids
457466 teams = dict ()
458467
468+ #: Winners, a list of the pids of the winning players
469+ winners = list ()
470+
459471 #: Build orders, a dict of build orders indexed by player id
460472 build_orders = dict ()
461473
@@ -473,7 +485,9 @@ def __init__(self, summary_file, filename=None, **options):
473485 self .image_urls = list ()
474486 self .localization_urls = dict ()
475487 self .lobby_properties = dict ()
488+ self .lobby_player_properties = dict ()
476489 self .teams = dict ()
490+ self .winners = list ()
477491
478492 self .data = zlib .decompress (summary_file .read ()[16 :])
479493 self .parts = list ()
@@ -497,24 +511,7 @@ def __init__(self, summary_file, filename=None, **options):
497511 self .game_length = self .game_length_ingame / GAME_SPEED_FACTOR [self .game_speed ]
498512
499513 # parse lobby properties
500- lobby_template = dict ()
501- for prop in self .parts [0 ][5 ]:
502- if not prop [0 ][1 ] in self .lobby_keys :
503- continue
504- lobby_template [prop [0 ][1 ]] = [o [0 ].strip ('\x00 ' ) for o in prop [1 ]]
505- for prop in self .parts [0 ][6 ][6 ]:
506- if not prop [0 ][1 ] in lobby_template :
507- continue
508- key = self .lobby_keys [prop [0 ][1 ]][0 ]
509- val = lobby_template [prop [0 ][1 ]][prop [1 ][0 ]]
510- self .lobby_properties [key ] = self .lobby_keys [prop [0 ][1 ]][1 ][utils .reverse_str (val )]
511-
512- # Prepare player lobby properties
513- lobby_player_template = dict ()
514- for prop in self .parts [0 ][5 ]:
515- if not prop [0 ][1 ] in self .lobby_player_keys :
516- continue
517- lobby_player_template [prop [0 ][1 ]] = [o [0 ].strip ().strip ('\x00 ' ) for o in prop [1 ]]
514+ (self .lobby_properties , self .lobby_player_properties ) = utils .get_lobby_properties (self .parts )
518515
519516 # Parse player structs, 16 is the maximum amount of players
520517 for i in range (16 ):
@@ -526,7 +523,11 @@ def __init__(self, summary_file, filename=None, **options):
526523
527524 player = PlayerSummary (player_struct [0 ][0 ])
528525 player .race = RACE_CODES ['' .join (reversed (player_struct [2 ]))]
529- player .teamid = player_struct [1 ][0 ]
526+ # I haven't found how to get the teams yet
527+ player .teamid = 0
528+ player .is_winner = (player_struct [1 ][0 ] == 0 )
529+ if player .is_winner :
530+ self .winners .append (player .pid )
530531
531532 # Is the player an ai?
532533 if type (player_struct [0 ][1 ]) == type (int ()):
@@ -544,21 +545,11 @@ def __init__(self, summary_file, filename=None, **options):
544545 # { 0: 3405691582L, 1: 11402158793782460416L}
545546 player .unknown2 = player_struct [0 ][1 ][1 ]
546547
547- # Parse lobby properties
548- player .lobby_properties = dict ()
549- for prop in self .parts [0 ][6 ][6 ]:
550- if not prop [0 ][1 ] in lobby_player_template :
551- continue
552- key = self .lobby_player_keys [prop [0 ][1 ]][0 ]
553- val = lobby_player_template [prop [0 ][1 ]][prop [1 ][player .pid ][0 ]]
554- player .lobby_properties [key ] = self .lobby_player_keys [prop [0 ][1 ]][1 ][utils .reverse_str (val )]
555-
556548 self .players [player .pid ] = player
557549 if not player .teamid in self .teams :
558550 self .teams [player .teamid ] = list ()
559551 self .teams [player .teamid ].append (player .pid )
560552
561-
562553 # Parse graph and stats stucts, for each player
563554 for pid in self .players :
564555 p = self .players [pid ]
@@ -631,7 +622,9 @@ def __str__(self):
631622 int (self .game_length )/ 3600 ,
632623 (int (self .game_length )% 3600 )/ 60 ,
633624 (int (self .game_length )% 3600 )% 60 ,
634- '' .join (self .players [p ].race [0 ] for p in self .players ))
625+ 'v' .join ('' .join (self .players [p ].race [0 ] for p in self .teams [tid ]) for tid in self .teams ))
626+
627+
635628
636629class MapInfo (Resource ):
637630 url_template = 'http://{0}.depot.battle.net:1119/{1}.s2mi'
0 commit comments