Skip to content

Commit fe2a376

Browse files
committed
Load attributes from a new data file.
Also adds a new script sc2attributes which can be used to load new attributes from any s2gs file.
1 parent 0391466 commit fe2a376

File tree

6 files changed

+1168
-133
lines changed

6 files changed

+1168
-133
lines changed

sc2reader/constants.py

Lines changed: 6 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -140,130 +140,10 @@
140140
},
141141
}
142142

143-
""" Still unknown
144-
bbe: 3, 5, 7, 10, 15, 20, 25, 30
145-
"""
146-
LOBBY_PROPERTIES = {
147-
# Default seems to be the only value possible.
148-
# This arcade entry is just a hunch, need to confirm with an arcade game
149-
0x03E8: ("???", {
150-
'Dflt': 'Default'
151-
}),
152-
0x03E9: ("Arcade", {
153-
'no':'no',
154-
'yes':'yes'
155-
}),
156143

157-
0x01F4: ("Controller", {
158-
'Humn': 'Human',
159-
'Comp': 'Computer',
160-
'Open': 'Open',
161-
'Clsd': 'Closed',
162-
}),
163-
164-
0x07D1: ("Game Mode", {
165-
'1v1': '1v1',
166-
'2v2': '2v2',
167-
'3v3': '3v3',
168-
'4v4': '4v4',
169-
'5v5': '5v5',
170-
'6v6': '6v6',
171-
'FFA': 'FFA',
172-
}),
173-
174-
0x07D0: ("Team Count", lambda value: value), #T1,2,3,4,5,6, or Custom
175-
0x07D2: ("Teams1v1", lambda value: int(value[1:])),
176-
0x07D3: ("Teams2v2", lambda value: int(value[1:])),
177-
0x07D4: ("Teams3v3", lambda value: int(value[1:])),
178-
0x07D5: ("Teams4v4", lambda value: int(value[1:])),
179-
0x07D6: ("TeamsFFA", lambda value: int(value[1:])),
180-
0x07D7: ("Teams5v5", lambda value: int(value[1:])),
181-
0x07D8: ("Teams6v6", lambda value: int(value[1:])),
182-
183-
0x07DB: ("2 Teams", lambda value: int(value[1:])),
184-
0x07DC: ("3 Teams", lambda value: int(value[1:])),
185-
0x07DD: ("4 Teams", lambda value: int(value[1:])),
186-
0x07DE: ("5 Teams", lambda value: int(value[1:])),
187-
188-
0x07E1: ("FFA Teams", lambda value: int(value[1:])),
189-
0x07E2: ("Custom Teams", lambda value: int(value[1:])),
190-
191-
0x0FA0: ("Game Privacy", {
192-
'Norm': 'Normal',
193-
'NoBO': 'No Build Order',
194-
'NoMH': 'No Match History',
195-
}),
196-
197-
0x0BB8: ("Game Speed", {
198-
'Slor': 'Slower',
199-
'Slow': 'Slow',
200-
'Norm': 'Normal',
201-
'Fast': 'Fast',
202-
'Fasr': 'Faster',
203-
}),
204-
0x0BB9: ("Race", {
205-
'Terr': 'Terran',
206-
'Zerg': 'Zerg',
207-
'Prot': 'Protoss',
208-
'RAND': 'Random',
209-
}),
210-
0x0BBA: ("Color", {
211-
'tc01': "Red",
212-
'tc02': "Blue",
213-
'tc03': "Teal",
214-
'tc04': "Purple",
215-
'tc05': "Yellow",
216-
'tc06': "Orange",
217-
'tc07': "Green",
218-
'tc08': "Light Pink",
219-
'tc09': "Violet",
220-
'tc10': "Light Grey",
221-
'tc11': "Dark Green",
222-
'tc12': "Brown",
223-
'tc13': "Light Green",
224-
'tc14': "Dark Grey",
225-
'tc15': "Pink",
226-
'tc16': "??",
227-
}),
228-
0x0BBB: ("Handicap", {
229-
'50': '50',
230-
'60': '60',
231-
'70': '70',
232-
'80': '80',
233-
'90': '90',
234-
'100': '100',
235-
}),
236-
0x0BBC: ("Difficulty", {
237-
'VyEy': 'Very easy',
238-
'Easy': 'Easy',
239-
'Medi': 'Medium',
240-
'MdHd': 'Hard',
241-
'Hard': 'Harder',
242-
'HdVH': 'Very Hard',
243-
'VyHd': 'Elite',
244-
'ChVi': 'Cheater 1 (Vision)',
245-
'ChRe': 'Cheater 2 (Resources)',
246-
'Insa': 'Cheater 3 (Insane)',
247-
}),
248-
249-
250-
0x0BBF: ("Participant Role", {
251-
'Part':'Participant',
252-
'Watc':'Observer'
253-
}),
254-
255-
0x0BC0: ("Watcher Type", {
256-
'Obs': 'Observer',
257-
'Ref':'Referee'
258-
}),
259-
0x0BC1: ("Category", {
260-
'Priv': 'Private',
261-
'Pub': 'Public',
262-
'Amm': 'Ladder',
263-
'': 'Single',
264-
}),
265-
0x0BC2: ("Locked Alliances", {
266-
'no':'unlocked',
267-
'yes':'locked',
268-
})
269-
}
144+
import pkgutil, json
145+
attributes_json = pkgutil.get_data('sc2reader.data', 'attributes.json')
146+
attributes_dict = json.loads(attributes_json)
147+
LOBBY_PROPERTIES = dict()
148+
for key, value in attributes_dict.get('attributes',dict()).items():
149+
LOBBY_PROPERTIES[int(key)] = value

0 commit comments

Comments
 (0)