|
39 | 39 | 0x4402 : 'Metabolic Boost', |
40 | 40 |
|
41 | 41 | } |
| 42 | +lobby_properties = { |
| 43 | + 3000 : 'game_speed', |
| 44 | + 2001 : 'game_type', #1v1/2v2/3v3/4v4/5v5/6v6/FFA |
| 45 | + 3010 : 'unknown1', #yes/no |
| 46 | + 3006 : 'unknown2', #3/5/7/10/15/20/25/30 |
| 47 | + 1001 : 'unknown3', #yes/no |
| 48 | + 1000 : 'unknown4', #Dflt |
| 49 | + 2000 : 'unknown5', #t2/t3/FFA/Cust |
| 50 | + 3009 : 'lobby_type' #Priv/Pub/Amm (Auto MatchMaking) |
| 51 | + |
| 52 | +} |
| 53 | +player_properties = { |
| 54 | + 500 : 'slot_state', #Clsd/Open/Humn/Comp |
| 55 | + 3001 : 'race', |
| 56 | + 3003 : 'energy', |
| 57 | + 3002 : 'color', |
| 58 | + 3004 : 'difficulty', |
| 59 | + 3008 : 'nonplayer_mode' #Obs/Ref |
| 60 | +} |
42 | 61 |
|
43 | 62 | def getRealm(str): |
44 | 63 | if str == '\x00\x00S2': |
45 | 64 | return "EU" |
46 | 65 |
|
47 | 66 | return "?" |
| 67 | +def loadPlayerPropTemplate(prop_struct): |
| 68 | + ret = dict() |
| 69 | + for prop in prop_struct: |
| 70 | + if not prop[0][1] in player_properties: |
| 71 | + continue |
| 72 | + |
| 73 | + ret[prop[0][1]] = [o[0] for o in prop[1]] |
| 74 | + return ret |
| 75 | +def loadLobbyPropTemplate(prop_struct): |
| 76 | + ret = dict() |
| 77 | + for prop in prop_struct: |
| 78 | + if not prop[0][1] in lobby_properties: |
| 79 | + continue |
| 80 | + ret[prop[0][1]] = [o[0] for o in prop[1]] |
| 81 | + return ret |
| 82 | +def getLobbyProperties(prop_struct, prop_template): |
| 83 | + ret = dict() |
| 84 | + for p in prop_struct: |
| 85 | + if not p[0][1] in prop_template: |
| 86 | + continue |
| 87 | + ret[lobby_properties[p[0][1]]] =( |
| 88 | + prop_template[p[0][1]][p[1][0]]) |
| 89 | + return ret |
| 90 | + |
| 91 | +def getLobby(data): |
| 92 | + props = loadLobbyPropTemplate(data[0][5]) |
| 93 | + |
| 94 | + return { |
| 95 | + 'properties':getLobbyProperties(data[0][6][6], props) |
| 96 | + } |
| 97 | + |
| 98 | +def getPlayerProperties(pindex, prop_struct, prop_template): |
| 99 | + ret = dict() |
| 100 | + for p in prop_struct: |
| 101 | + if not p[0][1] in prop_template: |
| 102 | + continue |
| 103 | + ret[player_properties[p[0][1]]] =( |
| 104 | + prop_template[p[0][1]][p[1][pindex][0]]) |
| 105 | + return ret |
| 106 | + |
48 | 107 | def getPlayers(data): |
| 108 | + |
| 109 | + props = loadPlayerPropTemplate(data[0][5]) |
| 110 | + |
49 | 111 | players = [] |
50 | 112 | parr = data[0][3] |
51 | 113 | for i in range(16): |
52 | 114 | if not (parr[i][0][1] == 0): |
53 | | - players.append(getPlayer(data, i)) |
| 115 | + player = getPlayer(data, i) |
| 116 | + player['properties'] = getPlayerProperties(i, data[0][6][6], props) |
| 117 | + players.append(player) |
54 | 118 |
|
55 | 119 | return players |
56 | 120 | def getIncomeGraph(data, index): |
@@ -174,6 +238,8 @@ def main(): |
174 | 238 |
|
175 | 239 | if arg == "players": |
176 | 240 | pprint.PrettyPrinter(indent=2).pprint(getPlayers(data)) |
| 241 | + elif arg == "lobby": |
| 242 | + pprint.PrettyPrinter(indent=2).pprint(getLobby(data)) |
177 | 243 | elif arg == "pprint": |
178 | 244 | pprint.PrettyPrinter(indent=2).pprint(data) |
179 | 245 | elif arg == "bo": |
|
0 commit comments