示例#1
0
def printGameSummary(filepath, arguments):
    summary = sc2reader.load_game_summary(filepath)

    if arguments.map:
        print("   Map:      {0}".format(summary.map_name))
    if arguments.length:
        print("   Length:   {0} minutes".format(summary.game_length))
    if arguments.date:
        print("   Date:     {0}".format(summary.start_time))
    if arguments.teams:
        lineups = [team.lineup for team in summary.teams]
        print("   Teams:    {0}".format("v".join(lineups)))
        for team in summary.teams:
            print("      Team {0}\t{1}".format(team.number, team.players[0]))
            for player in team.players[1:]:
                print("              \t{0}".format(player))
    if arguments.builds:
        for player in summary.players:
            print("\n== {0} ==\n".format(player))
            for order in summary.build_orders[player.pid]:
                msg = "  {0:0>2}:{1:0>2}  {2:<35} {3:0>2}/{4}"
                print(
                    msg.format(order.time / 60, order.time % 60, order.order,
                               order.supply, order.total_supply))
        print("")
示例#2
0
def test_another_HotS_s2gs():
    summary = sc2reader.load_game_summary("test_s2gs/hots2.s2gs")
    assert summary.players[0].enemies_destroyed == 14575
    assert summary.players[0].time_supply_capped == 50
    assert summary.players[0].idle_production_time == 4438
    assert summary.players[0].resources_spent == 25450
    assert summary.players[0].apm == 204
    assert summary.players[0].workers_active_graph.as_points()[8][1] == 25
    assert summary.players[0].upgrade_spending_graph.as_points()[8][1] == 300
    assert summary.expansion == 'HotS'
示例#3
0
def test_another_HotS_s2gs():
    summary = sc2reader.load_game_summary("test_s2gs/hots2.s2gs")
    assert summary.players[0].enemies_destroyed == 14575
    assert summary.players[0].time_supply_capped == 50
    assert summary.players[0].idle_production_time == 4438
    assert summary.players[0].resources_spent == 25450
    assert summary.players[0].apm == 204
    assert summary.players[0].workers_active_graph.as_points()[8][1] == 25
    assert summary.players[0].upgrade_spending_graph.as_points()[8][1] == 300
    assert summary.expansion == 'HotS'
示例#4
0
 def test_another_HotS_s2gs(self):
     summary = sc2reader.load_game_summary("test_s2gs/hots2.s2gs")
     self.assertEqual(summary.players[0].enemies_destroyed, 14575)
     self.assertEqual(summary.players[0].time_supply_capped, 50)
     self.assertEqual(summary.players[0].idle_production_time, 4438)
     self.assertEqual(summary.players[0].resources_spent, 25450)
     self.assertEqual(summary.players[0].apm, 204)
     self.assertEqual(summary.players[0].workers_active_graph.as_points()[8][1], 25)
     self.assertEqual(summary.players[0].upgrade_spending_graph.as_points()[8][1], 300)
     self.assertEqual(summary.expansion, "HotS")
示例#5
0
def printGameSummary(filepath, arguments):
    summary = sc2reader.load_game_summary(filepath)
    print "{0} minute {1} game played on {2}".format(summary.game_length, summary.real_type, summary.map_name)
    for p in summary.players:
        print("== {0} - {1}/{2} ==".format(p.play_race, p.region, p.bnetid if not p.is_ai else "AI"))
        for order in summary.build_orders[p.pid]:
            print("  {0:0>2}:{1:0>2}  {2:<35} {3:0>2}/{4}".format(order.time / 60,
                                                              order.time % 60,
                                                              order.order,
                                                              order.supply,
                                                              order.total_supply))
        print
示例#6
0
 def test_another_HotS_s2gs(self):
     summary = sc2reader.load_game_summary("test_s2gs/hots2.s2gs")
     self.assertEqual(summary.players[0].enemies_destroyed, 14575)
     self.assertEqual(summary.players[0].time_supply_capped, 50)
     self.assertEqual(summary.players[0].idle_production_time, 4438)
     self.assertEqual(summary.players[0].resources_spent, 25450)
     self.assertEqual(summary.players[0].apm, 204)
     self.assertEqual(
         summary.players[0].workers_active_graph.as_points()[8][1], 25)
     self.assertEqual(
         summary.players[0].upgrade_spending_graph.as_points()[8][1], 300)
     self.assertEqual(summary.expansion, 'HotS')
示例#7
0
def printGameSummary(filepath, arguments):
    summary = sc2reader.load_game_summary(filepath)
    print "{0} minute {1} game played on {2}".format(summary.game_length,
                                                     summary.real_type,
                                                     summary.map_name)
    for p in summary.players:
        print("== {0} - {1}/{2} ==".format(p.play_race, p.region,
                                           p.bnetid if not p.is_ai else "AI"))
        for order in summary.build_orders[p.pid]:
            print("  {0:0>2}:{1:0>2}  {2:<35} {3:0>2}/{4}".format(
                order.time / 60, order.time % 60, order.order, order.supply,
                order.total_supply))
        print
示例#8
0
def main():
    global decisions

    parser = argparse.ArgumentParser(description="Recursively parses replay files, inteded for debugging parse issues.")
    parser.add_argument('folders', metavar='folder', type=str, nargs='+', help="Path to a folder")
    args = parser.parse_args()

    scripts_dir = os.path.dirname(os.path.abspath(__file__))
    data_path = os.path.normpath(os.path.join(scripts_dir, '..', 'data', 'attributes.json'))

    attributes = dict()
    if os.path.exists(data_path):
        with open(data_path, 'r') as data_file:
            data = json.load(data_file)
            attributes = data.get('attributes', attributes)
            decisions = pickle.loads(data.get('decisions', '(dp0\n.'))

    for folder in args.folders:
        for path in sc2reader.utils.get_files(folder, extension='s2gs'):
            try:
                summary = sc2reader.load_game_summary(path)
                for prop in summary.parts[0][5]:
                    group_key = prop[0][1]
                    group_name = summary.translations['enUS'][group_key]
                    attribute_values = dict()
                    if str(group_key) in attributes:
                        attribute_name, attribute_values = attributes[str(group_key)]
                        if attribute_name != group_name:
                            group_name = get_choice(group_key, attribute_name, group_name)

                    for value in prop[1]:
                        value_key = value[0].strip("\x00 ").replace(' v ', 'v')
                        value_name = summary.lang_sheets['enUS'][value[1][0][1]][value[1][0][2]]
                        if str(value_key) in attribute_values:
                            attribute_value_name = attribute_values[str(value_key)]
                            if value_name != attribute_value_name:
                                value_name = get_choice((group_key, value_key), attribute_value_name, value_name)

                        attribute_values[str(value_key)] = value_name

                    attributes["{0:0>4}".format(group_key)] = (group_name, attribute_values)
            except Exception as e:
                if isinstance(e, KeyboardInterrupt):
                    raise
                else:
                    traceback.print_exc()

    with open(data_path, 'w') as data_file:
        data = dict(attributes=attributes, decisions=pickle.dumps(decisions))
        json.dump(data, data_file, indent=2, sort_keys=True)
示例#9
0
def main():
    global decisions

    parser = argparse.ArgumentParser(description="Recursively parses replay files, inteded for debugging parse issues.")
    parser.add_argument('folders', metavar='folder', type=str, nargs='+', help="Path to a folder")
    args = parser.parse_args()

    scripts_dir = os.path.dirname(os.path.abspath(__file__))
    data_path = os.path.normpath(os.path.join(scripts_dir,'..','data','attributes.json'))

    attributes = dict()
    if os.path.exists(data_path):
        with open(data_path, 'r') as data_file:
            data = json.load(data_file)
            attributes = data.get('attributes', attributes)
            decisions = pickle.loads(data.get('decisions', '(dp0\n.'))

    for folder in args.folders:
        for path in sc2reader.utils.get_files(folder,extension='s2gs'):
            try:
                summary = sc2reader.load_game_summary(path)
                for prop in summary.parts[0][5]:
                    group_key = prop[0][1]
                    group_name = summary.translations['enUS'][group_key]
                    attribute_values = dict()
                    if str(group_key) in attributes:
                        attribute_name, attribute_values = attributes[str(group_key)]
                        if attribute_name != group_name:
                            group_name = get_choice(group_key, attribute_name, group_name)

                    for value in prop[1]:
                        value_key = value[0].strip("\x00 ").replace(' v ','v')
                        value_name = summary.lang_sheets['enUS'][value[1][0][1]][value[1][0][2]]
                        if str(value_key) in attribute_values:
                            attribute_value_name = attribute_values[str(value_key)]
                            if value_name != attribute_value_name:
                                value_name = get_choice((group_key, value_key), attribute_value_name, value_name)

                        attribute_values[str(value_key)] = value_name

                    attributes["{0:0>4}".format(group_key)] = (group_name, attribute_values)
            except Exception as e:
                if isinstance(e, KeyboardInterrupt):
                    raise
                else:
                    traceback.print_exc()

    with open(data_path,'w') as data_file:
        data = dict(attributes=attributes,decisions=pickle.dumps(decisions))
        json.dump(data, data_file, indent=2, sort_keys=True)
示例#10
0
def printGameSummary(filepath, arguments):
    summary = sc2reader.load_game_summary(filepath)

    if arguments.map:
        print("   Map:      {0}".format(summary.map_name))
    if arguments.length:
        print("   Length:   {0} minutes".format(summary.game_length))
    if arguments.date:
        print("   Date:     {0}".format(summary.start_time))
    if arguments.teams:
        lineups = [team.lineup for team in summary.teams]
        print("   Teams:    {0}".format("v".join(lineups)))
        for team in summary.teams:
            print("      Team {0}\t{1}".format(team.number, team.players[0]))
            for player in team.players[1:]:
                print("              \t{0}".format(player))
    if arguments.builds:
        for player in summary.players:
            print("\n== {0} ==\n".format(player))
            for order in summary.build_orders[player.pid]:
                msg = "  {0:0>2}:{1:0>2}  {2:<35} {3:0>2}/{4}"
                print(msg.format(order.time / 60, order.time % 60, order.order, order.supply, order.total_supply))
        print("")
示例#11
0
import sc2reader

hots_hashes = open('/tmp/hotshash.txt','rb')
byend = {}
for hots_hash in hots_hashes:
    url = "http://xx.depot.battle.net:1119/{}.s2gs".format(hots_hash.strip())
    print "Getting {}".format(url)
    summary = sc2reader.load_game_summary(url)
    byend[summary.end_time] = hots_hash
latest_hash = byend[sorted(byend.keys())[-1]]
print latest_hash
示例#12
0
 def test_a_WoL_s2gs(self):
     summary = sc2reader.load_game_summary("test_s2gs/s2gs1.s2gs")
     self.assertEqual(summary.players[0].resource_collection_rate, 1276)
     self.assertEqual(summary.players[0].build_order[0].order, 'Probe')
     self.assertEqual(summary.expansion, 'WoL')
示例#13
0
def test_a_HotS_s2gs():
    summary = sc2reader.load_game_summary("test_s2gs/hots1.s2gs")
    assert summary.players[0].resource_collection_rate == 1599
    assert summary.players[0].build_order[0].order == 'SCV'
    assert summary.expansion == 'HotS'
示例#14
0
def test_a_WoL_s2gs():
    summary = sc2reader.load_game_summary("test_s2gs/s2gs1.s2gs")
    assert summary.players[0].resource_collection_rate == 1276
    assert summary.players[0].build_order[0].order == 'Probe'
    assert summary.expansion == 'WoL'
示例#15
0
 def test_a_HotS_s2gs(self):
     summary = sc2reader.load_game_summary("test_s2gs/hots1.s2gs")
     self.assertEqual(summary.players[0].resource_collection_rate, 1599)
     self.assertEqual(summary.players[0].build_order[0].order, 'SCV')
     self.assertEqual(summary.expansion, 'HotS')
示例#16
0
def test_a_HotS_s2gs():
    summary = sc2reader.load_game_summary("test_s2gs/hots1.s2gs")
    assert summary.players[0].resource_collection_rate == 1599
    assert summary.players[0].build_order[0].order == 'SCV'
    assert summary.expansion == 'HotS'
示例#17
0
def test_a_WoL_s2gs():
    summary = sc2reader.load_game_summary("test_s2gs/s2gs1.s2gs")
    assert summary.players[0].resource_collection_rate == 1276
    assert summary.players[0].build_order[0].order == 'Probe'
    assert summary.expansion == 'WoL'
示例#18
0
import sc2reader

hots_hashes = open('/tmp/hotshash.txt', 'rb')
byend = {}
for hots_hash in hots_hashes:
    url = "http://xx.depot.battle.net:1119/{}.s2gs".format(hots_hash.strip())
    print "Getting {}".format(url)
    summary = sc2reader.load_game_summary(url)
    byend[summary.end_time] = hots_hash
latest_hash = byend[sorted(byend.keys())[-1]]
print latest_hash
示例#19
0
 def test_a_WoL_s2gs(self):
     summary = sc2reader.load_game_summary("test_s2gs/s2gs1.s2gs")
     self.assertEqual(summary.players[0].resource_collection_rate, 1276)
     self.assertEqual(summary.players[0].build_order[0].order, "Probe")
     self.assertEqual(summary.expansion, "WoL")
示例#20
0
 def test_a_HotS_s2gs(self):
     summary = sc2reader.load_game_summary("test_s2gs/hots1.s2gs")
     self.assertEqual(summary.players[0].resource_collection_rate, 1599)
     self.assertEqual(summary.players[0].build_order[0].order, "SCV")
     self.assertEqual(summary.expansion, "HotS")