Skip to content

Commit e74da7b

Browse files
committed
feat(SpellAuraStat): Change logic to handle multiple entries with the same id_parent
1 parent 6f18789 commit e74da7b

1 file changed

Lines changed: 17 additions & 22 deletions

File tree

scripts/parsers/SpellAuraStat.py

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,23 @@
2121

2222
with open(os.path.join(generatedDir, 'SpellEffect.csv')) as csvfile:
2323
reader = list(csv.DictReader(csvfile, escapechar='\\'))
24-
reader = sorted(reader, key=lambda d: (int(d['id_parent']), -int(d['sub_type'])))
24+
# group by id_parent
25+
effects_by_parent = {}
26+
for row in reader:
27+
parent_id = int(row['id_parent'])
28+
if parent_id > 0 and int(row['type']) == 6:
29+
effects_by_parent.setdefault(parent_id, []).append(row)
30+
31+
# iterate through effects_by_parent and check for wanted sub-types
2532
with open(os.path.join(addonEnumDir, 'SpellAuraStat.lua'), 'w', encoding='utf-8') as file:
2633
file.write('HeroDBC.DBC.SpellAuraStat = {\n')
27-
current = 0
28-
for _, row in enumerate(reader):
29-
if int(row['id_parent']) > 0 and current != int(row['id_parent']) and int(row['type']) == 6:
30-
current = int(row['id_parent'])
31-
# Attribute (29)
32-
# Modify Total Stat% (137)
33-
# Modify Rating (189) with misc values mapping to stats
34-
# Modify All Haste% (193)
35-
# Modify Critical Strike% (290)
36-
# Modify Mastery% (318)
37-
# Modify Versatility% (471)
38-
if (int(row['sub_type']) == 29 or
39-
int(row['sub_type']) == 137 or
40-
int(row['sub_type']) == 193 or
41-
int(row['sub_type']) == 290 or
42-
int(row['sub_type']) == 318 or
43-
int(row['sub_type']) == 471 or
44-
int(row['sub_type']) == 189 and (int(row['misc_value_1']) == 1792 or int(row['misc_value_1']) == 917504 or int(row['misc_value_1']) == 33554432 or int(row['misc_value_1']) == 1879048192)):
45-
file.write(' [' + row['id_parent'] + '] = true,\n')
46-
else:
47-
file.write(' [' + row['id_parent'] + '] = false,\n')
34+
for parent_id, rows in sorted(effects_by_parent.items()):
35+
match_found = False
36+
for row in rows:
37+
subtype = int(row['sub_type'])
38+
if (subtype in (29, 137, 193, 290, 318, 471) or
39+
(subtype == 189 and int(row['misc_value_1']) in (1792, 917504, 33554432, 1879048192))):
40+
match_found = True
41+
break
42+
file.write(f' [{parent_id}] = {"true" if match_found else "false"},\n')
4843
file.write('}\n')

0 commit comments

Comments
 (0)