11from __future__ import absolute_import
22
33import zlib
4+ import pprint
45import hashlib
56from datetime import datetime
67from StringIO import StringIO
@@ -396,18 +397,30 @@ def read_game_strings(self):
396397 elif parts [0 ] == 'DocInfo/DescLong' :
397398 self .description = parts [1 ]
398399
400+ s2gsmap = [[4 , "Average Unspent Resources" ],
401+ [5 , "Resource Collection Rate" ],
402+ [6 , "Workers Created" ],
403+ [7 , "Units Trained" ],
404+ [8 , "Killed Unit Count" ],
405+ [9 , "Structure Built" ],
406+ ]
407+
399408class GameSummary (Resource ):
400- url_template = 'http://{0}.depot.battle.net:1119/{1}.s2ma '
409+ url_template = 'http://{0}.depot.battle.net:1119/{1}.s2gs '
401410 def __init__ (self , summary_file , filename = None , ** options ):
402411 super (GameSummary , self ).__init__ (summary_file , filename ,** options )
403412 self .data = zlib .decompress (summary_file .read ()[16 :])
404413 self .parts = list ()
405414 buffer = utils .ReplayBuffer (self .data )
406415 while buffer .left :
407416 part = buffer .read_data_struct ()
408- print str (part )+ "\n \n \n "
409- self .parts .append (buffer .read_data_struct ())
410- print len (self .parts )
417+ # print str(part)+"\n\n\n"
418+ self .parts .append (part )
419+ # print len(self.parts)
420+ # pprint.PrettyPrinter(indent=2).pprint(self.parts)
421+ for index , name in s2gsmap :
422+ for player in [0 , 1 ]:
423+ print "Player" , player , name , self .parts [3 ][0 ][index ][1 ][player ][0 ][0 ]
411424
412425class MatchInfo (Resource ):
413426 url_template = 'http://{0}.depot.battle.net:1119/{1}.s2ma'
@@ -420,4 +433,4 @@ class MatchHistory(Resource):
420433 url_template = 'http://{0}.depot.battle.net:1119/{1}.s2ma'
421434 def __init__ (self , history_file , filename = None , ** options ):
422435 super (MatchHistory , self ).__init__ (history_file , filename ,** options )
423- self .data = utils .ReplayBuffer (history_file ).read_data_struct ()
436+ self .data = utils .ReplayBuffer (history_file ).read_data_struct ()
0 commit comments