Skip to content

Commit 065d009

Browse files
committed
Updated extract.py, build order parsing completed
1 parent 205e46d commit 065d009

File tree

1 file changed

+41
-8
lines changed

1 file changed

+41
-8
lines changed

extract.py

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,42 @@
3434
]
3535
# Obviously not complete
3636
abilities = {
37+
# Protoss
38+
## Twilight
39+
0x5902 : 'Blink',
40+
# Charge
41+
42+
## Cyber core
3743
0x5602 : 'Warp Gate',
44+
0x5702 : 'Hallucination',
45+
# Air Weapons 1-3
46+
# Air Armor 1-3
47+
# Hallucination
48+
49+
## Robo bay
50+
# Obs, speed
51+
# Prism, speed
3852
0x3402 : 'Extended Thermal Lance',
53+
54+
#Zerg
55+
## Pool
3956
0x4402 : 'Metabolic Boost',
57+
# Adrenal glands
4058

59+
## Evo. chamber
60+
0x3a02 : 'Zerg Ground Carapace Level 1',
61+
0x3b02 : 'Zerg Ground Carapace Level 2', #extrapolated
62+
0x3c02 : 'Zerg Ground Carapace Level 3', #extrapolated
63+
0x3d02 : 'Zerg Missile Attacks Level 1',
64+
0x3e02 : 'Zerg Missile Attacks Level 2', #extrapolated
65+
0x3f02 : 'Zerg Missile Attacks Level 3', #extrapolated
66+
67+
## Lair
68+
0x4202 : 'Burrow',
69+
70+
#Terran
71+
## Factory tech lab
72+
0x1402 : 'Siege tech'
4173
}
4274
lobby_properties = {
4375
3000 : 'game_speed',
@@ -60,10 +92,7 @@
6092
}
6193

6294
def getRealm(str):
63-
if str == '\x00\x00S2':
64-
return "EU"
65-
66-
return "?"
95+
return ""
6796
def loadPlayerPropTemplate(prop_struct):
6897
ret = dict()
6998
for prop in prop_struct:
@@ -164,13 +193,13 @@ def toUnit(bo_unit):
164193
#print(hex(flip_int(bo_unit, 4)))
165194
i = ((bo_unit & 0xff) << 8) | 0x01
166195
if bo_unit >> 24 == 1:
167-
return {'name':unitData.type(i).name, 'id':hex(i)}
196+
return {'name':unitData.type(i).name, 'type':hex(i), 'id':hex(bo_unit)}
168197
return None
169198
def toAbility(bo_ability):
170199
#print(hex(flip_int(bo_unit, 4)))
171200
i = ((bo_ability & 0xff) << 8) | 0x02
172201
if bo_ability >> 24 == 2:
173-
return {'name':abilities[i] if i in abilities else "Unknown ability", 'type':hex(i), 'id':hex(bo_ability)}
202+
return {'name':abilities[i] if i in abilities else "Unknown ability ({})".format(hex(i)), 'type':hex(i), 'id':hex(bo_ability)}
174203

175204
return None
176205
def getBuildOrder(unit_structs, index):
@@ -184,6 +213,7 @@ def getBuildOrder(unit_structs, index):
184213
elif u[0][1] >> 24 == 2:
185214
unit = toAbility(u[0][1])
186215
if not unit:
216+
print("Unknown code {}".format(u))
187217
continue
188218
for entry in u[1][index]:
189219
bo.append({
@@ -217,6 +247,7 @@ def getBuildOrderOthers(struct):
217247

218248
def getBuildOrders(data):
219249
unit_structs = [x[0] for x in data[5:]]
250+
unit_structs.append(data[4][0][3:])
220251
players = {}
221252
for i in range(15):
222253
bo = getBuildOrder(unit_structs, i)
@@ -246,11 +277,13 @@ def main():
246277
pprint.PrettyPrinter(indent=2).pprint(getBuildOrders(data))
247278
elif arg == "bo2":
248279
bos = getBuildOrders(data)[0]
280+
players = getPlayers(data)
249281
for p in bos:
282+
print("== {} - {} ==".format(players[p]['race'], players[p]['id']))
250283
for u in bos[p]:
251-
print("{}:{} {} {}/{}".format(u['time'] / 60,
284+
print("{:0>2}:{:0>2} {:<25} {:>2}/{}".format(u['time'] / 60,
252285
u['time'] % 60,
253-
u['unit']['name'],
286+
u['order']['name'],
254287
u['supply'],
255288
u['total_supply']))
256289
main()

0 commit comments

Comments
 (0)