Skip to content

Commit cf288a6

Browse files
committed
All upgrades added to build order parsing
Fixed some thing in sc2boprinter.py
1 parent 3d16f07 commit cf288a6

File tree

2 files changed

+126
-50
lines changed

2 files changed

+126
-50
lines changed

sc2reader/constants.py

Lines changed: 100 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -155,52 +155,123 @@
155155
'E55BB0': 'Pink'
156156
}
157157

158-
# Obviously not complete
159-
# TODO: Complete this!
160158
BUILD_ORDER_UPGRADES = {
161159
# Protoss
162160

163161
## Forge
164162
0x2902 : 'Protoss Ground Weapons Level 1',
165-
0x2a02 : 'Protoss Ground Weapons Level 2', #extrapolated
166-
0x2b02 : 'Protoss Ground Weapons Level 3', #extrapolated
167-
168-
## Twilight
169-
0x5902 : 'Blink',
170-
# Charge
171-
163+
0x2a02 : 'Protoss Ground Weapons Level 2',
164+
0x2b02 : 'Protoss Ground Weapons Level 3',
165+
0x2c02 : 'Protoss Ground Armor Level 1',
166+
0x2d02 : 'Protoss Ground Armor Level 2',
167+
0x2e02 : 'Protoss Ground Armor Level 3',
168+
0x2f02 : 'Protoss Shields Level 1',
169+
0x3002 : 'Protoss Shields Level 2',
170+
0x3102 : 'Protoss Shields Level 3',
171+
## Robo bay
172+
0x3202 : 'Gravitic Boosters',
173+
0x3302 : 'Gravitic Drive',
174+
0x3402 : 'Extended Thermal Lance',
172175
## Cyber core
176+
0x5002 : 'Protoss Air Weapons Level 1',
177+
0x5102 : 'Protoss Air Weapons Level 2',
178+
0x5202 : 'Protoss Air Weapons Level 3',
179+
0x5302 : 'Protoss Air Armor Level 1',
180+
0x5402 : 'Protoss Air Armor Level 2',
181+
0x5502 : 'Protoss Air Armor Level 3',
173182
0x5602 : 'Warp Gate Research',
174183
0x5702 : 'Hallucination',
175-
# Air Weapons 1-3
176-
# Air Armor 1-3
177-
# Hallucination
178-
179-
## Robo bay
180-
# Obs, speed
181-
# Prism, speed
182-
0x3402 : 'Extended Thermal Lance',
184+
## Twilight
185+
0x5802 : 'Charge',
186+
0x5902 : 'Blink',
187+
## Fleet Beacon
188+
0x0302 : 'Graviton Catapult',
189+
0x7102 : 'Anion Pulse-Crystals',
183190

184-
#Zerg
185-
## Pool
186-
0x4402 : 'Metabolic Boost',
187-
# Adrenal glands
191+
#Zerg
188192

193+
## Roach Warren
194+
0x0402 : 'Gial Reconstitution',
195+
0x0502 : 'Tunneling Claws',
196+
## Ultralisk Cavern
197+
0x0602 : 'Chitinous Plating',
189198
## Evo. chamber
190-
199+
0x3702 : 'Zerg Melee Attacks Level 1',
200+
0x3802 : 'Zerg Melee Attacks Level 2',
201+
0x3902 : 'Zerg Melee Attacks Level 3',
191202
0x3a02 : 'Zerg Ground Carapace Level 1',
192-
0x3b02 : 'Zerg Ground Carapace Level 2', #extrapolated
193-
0x3c02 : 'Zerg Ground Carapace Level 3', #extrapolated
203+
0x3b02 : 'Zerg Ground Carapace Level 2',
204+
0x3c02 : 'Zerg Ground Carapace Level 3',
194205
0x3d02 : 'Zerg Missile Attacks Level 1',
195-
0x3e02 : 'Zerg Missile Attacks Level 2', #extrapolated
196-
0x3f02 : 'Zerg Missile Attacks Level 3', #extrapolated
197-
206+
0x3e02 : 'Zerg Missile Attacks Level 2',
207+
0x3f02 : 'Zerg Missile Attacks Level 3',
198208
## Lair
209+
0x4002 : 'Pneumatized Carapace',
210+
0x4102 : 'Ventral Sacs',
199211
0x4202 : 'Burrow',
200-
212+
## Pool
213+
0x4302 : 'Adrenal Glands',
214+
0x4402 : 'Metabolic Boost',
215+
## Hydra den
216+
0x4502 : 'Grooved Spines',
217+
## Spire
218+
0x4602 : 'Zerg Flyer Attacks Level 1',
219+
0x4702 : 'Zerg Flyer Attacks Level 2',
220+
0x4802 : 'Zerg Flyer Attacks Level 3',
221+
0x4902 : 'Zerg Flyer Carapace Level 1',
222+
0x4a02 : 'Zerg Flyer Carapace Level 2',
223+
0x4b02 : 'Zerg Flyer Carapace Level 3',
224+
## Infestation pit
225+
0x4c02 : 'Pathogen Glands',
226+
0x7202 : 'Neural Parasite',
227+
## Baneling Nest
228+
0x4d02 : 'Centrifugal Hooks',
229+
201230
#Terran
231+
## Engineering bay
232+
0x702 : 'Hi-Sec Auto Tracking',
233+
0x802 : 'Terran Building Armor',
234+
0x902 : 'Terran Infantry Weapons Level 1',
235+
0xa02 : 'Terran Infantry Weapons Level 2',
236+
0xb02 : 'Terran Infantry Weapons Level 3',
237+
0xc02 : 'Neosteel Frame',
238+
0xd02 : 'Terran Infantry Armor Level 1',
239+
0xe02 : 'Terran Infantry Armor Level 2',
240+
0xf02 : 'Terran Infantry Armor Level 3',
241+
## Barracks tech lab
242+
0x1002 : 'Nitro Packs',
243+
0x1102 : 'Stimpack',
244+
0x1202 : 'Combat Shields',
245+
0x1302 : 'Concussive Shells',
202246
## Factory tech lab
203-
0x1402 : 'Siege Tech'
247+
0x1402 : 'Siege Tech',
248+
0x1502 : 'Infernal Pre-igniter',
249+
0x7002 : '250mm Strike Cannons',
250+
## Starport tech lab
251+
0x1602 : 'Cloaking Field',
252+
0x1702 : 'Caduceus Reactor',
253+
0x1902 : 'Seeker Missile',
254+
0x1a02 : 'Durable Materials',
255+
0x4e02 : 'Corvid Reactor',
256+
## Fusion Core
257+
0x1802 : 'Behemoth Reactor',
258+
0x4f02 : 'Weapon Refit',
259+
## Ghost Academy
260+
0x1b02 : 'Personal Cloaking',
261+
0x1c02 : 'Moebiue Reactor',
262+
## Armory
263+
0x1d02 : 'Terran Vehicle Plating Level 1',
264+
0x1e02 : 'Terran Vehicle Plating Level 2',
265+
0x1f02 : 'Terran Vehicle Plating Level 3',
266+
0x2002 : 'Terran Vehicle Weapons Level 1',
267+
0x2102 : 'Terran Vehicle Weapons Level 2',
268+
0x2202 : 'Terran Vehicle Weapons Level 3',
269+
0x2302 : 'Terran Ship Plating Level 1',
270+
0x2402 : 'Terran Ship Plating Level 2',
271+
0x2502 : 'Terran Ship Plating Level 3',
272+
0x2602 : 'Terran Ship Weapons Level 1',
273+
0x2702 : 'Terran Ship Weapons Level 2',
274+
0x2802 : 'Terran Ship Weapons Level 3'
204275
}
205276

206277
# TODO: Not sure if this is a complete mapping

sc2reader/scripts/sc2boprinter.py

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,38 @@
66
Usage: python sc2boprinter.py FOLDER
77
"""
88

9-
import sys, os
9+
import sys, os, argparse
1010
from sc2reader.factories import SC2Factory
1111

12-
def get():
12+
def get(dir):
1313
factory = SC2Factory()
1414

1515
res = list()
1616

17-
for file in os.listdir(sys.argv[1]):
17+
for file in os.listdir(dir):
1818
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-
19+
res.append(factory.load_game_summary(os.path.join(dir, file)))
20+
2521
return res
22+
def main():
23+
parser = argparse.ArgumentParser(description="Prints build orders from all s2gs files in FOLDER")
24+
parser.add_argument('path', metavar='filename', type=str, nargs=1,
25+
help="Path to a folder")
26+
27+
args = parser.parse_args()
28+
res = get(args.path[0])
29+
for r in res:
30+
if r.__class__.__name__ == "GameSummary":
31+
print("\n"+"-"*40+"\n")
32+
print("= {} =".format(r))
33+
for p in r.players:
34+
print("== {} - {} ==".format(p.race, p.bnetid if not p.is_ai else "AI"))
35+
for order in r.build_orders[p.pid]:
36+
print("{:0>2}:{:0>2} {:<35} {:>2}/{}".format(order['time'] / 60,
37+
order['time'] % 60,
38+
order['order']['name'],
39+
order['supply'],
40+
order['total_supply']))
2641

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']))
42+
if __name__ == '__main__':
43+
main()

0 commit comments

Comments
 (0)