Skip to content

Commit 3d16f07

Browse files
committed
Added a script to print build orders of all s2gs files in a folder
1 parent 4eef82c commit 3d16f07

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

sc2reader/resources.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,10 +567,10 @@ def __init__(self, summary_file, filename=None, **options):
567567

568568

569569
def __str__(self):
570-
return "{} - {}:{}:{} {}".format(time.ctime(self.time),
570+
return "{} - {:0>2}:{:0>2}:{:0>2} {}".format(time.ctime(self.time),
571571
int(self.game_length)/3600,
572-
int(self.game_length)/60,
573-
int(self.game_length)%60,
572+
(int(self.game_length)%3600)/60,
573+
(int(self.game_length)%3600)%60,
574574
''.join(p.race[0] for p in self.players))
575575

576576
class MapInfo(Resource):

sc2reader/scripts/sc2boprinter.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
"""
5+
Prints buildorders for all s2gs-files in FOLDER
6+
Usage: python sc2boprinter.py FOLDER
7+
"""
8+
9+
import sys, os
10+
from sc2reader.factories import SC2Factory
11+
12+
def get():
13+
factory = SC2Factory()
14+
15+
res = list()
16+
17+
for file in os.listdir(sys.argv[1]):
18+
if file.rfind('.s2gs') > 0:
19+
res.append(factory.load_game_summary(sys.argv[1] + "\\" + file))
20+
elif file.rfind('.s2mi') > 0:
21+
res.append(factory.load_map_info(sys.argv[1] + "\\" + file))
22+
elif file.rfind('.s2mh') > 0:
23+
res.append(factory.load_map_header(sys.argv[1] + "\\" + file))
24+
25+
return res
26+
27+
res = get()
28+
for r in res:
29+
if r.__class__.__name__ == "GameSummary":
30+
print("= {} =".format(r))
31+
for p in r.players:
32+
print("== {} - {} ==".format(p.race, p.bnetid if not p.is_ai else "AI"))
33+
for order in r.build_orders[p.pid]:
34+
print("{:0>2}:{:0>2} {:<35} {:>2}/{}".format(order['time'] / 60,
35+
order['time'] % 60,
36+
order['order']['name'],
37+
order['supply'],
38+
order['total_supply']))

0 commit comments

Comments
 (0)