@@ -429,9 +429,12 @@ class GameSummary(Resource):
429429 #: Game completion time
430430 time = int ()
431431
432- #: Players, a dict of :class`PlayerSummary` from the game
432+ #: Players, a list of :class`PlayerSummary` from the game
433433 players = list ()
434434
435+ #: Build orders, a dict of build orders indexed by player id
436+ build_orders = dict ()
437+
435438 #: Map image urls
436439 image_urls = list ()
437440
@@ -442,6 +445,7 @@ def __init__(self, summary_file, filename=None, **options):
442445 super (GameSummary , self ).__init__ (summary_file , filename ,** options )
443446
444447 self .players = list ()
448+ self .build_orders = dict ()
445449 self .image_urls = list ()
446450 self .localization_urls = dict ()
447451
@@ -531,6 +535,37 @@ def __init__(self, summary_file, filename=None, **options):
531535 parsed_hash = utils .parse_hash (hash )
532536 self .image_urls .append (self .base_url_template .format (parsed_hash ['server' ], parsed_hash ['hash' ], parsed_hash ['type' ]))
533537
538+
539+ # Parse build orders
540+
541+ bo_structs = [x [0 ] for x in self .parts [5 :]]
542+ bo_structs .append (self .parts [4 ][0 ][3 :])
543+
544+ # This might not be the most effective way, but it works
545+ for p in self .players :
546+ bo = list ()
547+ for bo_struct in bo_structs :
548+ for order in bo_struct :
549+
550+ if order [0 ][1 ] >> 24 == 0x01 :
551+ # unit
552+ parsed_order = utils .get_unit (order [0 ][1 ])
553+ elif order [0 ][1 ] >> 24 == 0x02 :
554+ # research
555+ parsed_order = utils .get_research (order [0 ][1 ])
556+
557+ for entry in order [1 ][p .pid ]:
558+ bo .append ({
559+ 'supply' : entry [0 ],
560+ 'total_supply' : entry [1 ]& 0xff ,
561+ 'time' : (entry [2 ] >> 8 ) / 16 ,
562+ 'order' : parsed_order ,
563+ 'build_index' : entry [1 ] >> 16 ,
564+ })
565+ bo .sort (key = lambda x : x ['build_index' ])
566+ self .build_orders [p .pid ] = bo
567+
568+
534569 def __str__ (self ):
535570 return "{} - {}:{}:{} {}" .format (time .ctime (self .time ),
536571 int (self .game_length )/ 3600 ,
0 commit comments