135 lines
4.3 KiB
Python
135 lines
4.3 KiB
Python
#\!/usr/bin/env python3
|
|
"""Extract dictionaries from Mag-Plugins Dictionaries.cs file."""
|
|
|
|
import re
|
|
import json
|
|
|
|
def extract_attribute_set_info():
|
|
"""Extract AttributeSetInfo dictionary from Dictionaries.cs."""
|
|
with open('/home/erik/MosswartOverlord/unused/Mag-Plugins/Shared/Constants/Dictionaries.cs', 'r') as f:
|
|
content = f.read()
|
|
|
|
# Find the AttributeSetInfo dictionary
|
|
pattern = r'AttributeSetInfo\s*=\s*new\s+Dictionary<int,\s*string>\s*\{([^}]+)\}'
|
|
match = re.search(pattern, content, re.DOTALL)
|
|
|
|
if not match:
|
|
print("AttributeSetInfo not found\!")
|
|
return {}
|
|
|
|
dict_content = match.group(1)
|
|
|
|
# Extract entries
|
|
entry_pattern = r'\{\s*(\d+),\s*"([^"]+)"\s*\}'
|
|
entries = re.findall(entry_pattern, dict_content)
|
|
|
|
attribute_sets = {}
|
|
for set_id, set_name in entries:
|
|
attribute_sets[set_id] = set_name
|
|
|
|
return attribute_sets
|
|
|
|
def extract_material_info():
|
|
"""Extract MaterialInfo dictionary from Dictionaries.cs."""
|
|
with open('/home/erik/MosswartOverlord/unused/Mag-Plugins/Shared/Constants/Dictionaries.cs', 'r') as f:
|
|
content = f.read()
|
|
|
|
# Find the MaterialInfo dictionary
|
|
pattern = r'MaterialInfo\s*=\s*new\s+Dictionary<int,\s*string>\s*\{([^}]+)\}'
|
|
match = re.search(pattern, content, re.DOTALL)
|
|
|
|
if not match:
|
|
print("MaterialInfo not found\!")
|
|
return {}
|
|
|
|
dict_content = match.group(1)
|
|
|
|
# Extract entries
|
|
entry_pattern = r'\{\s*(\d+),\s*"([^"]+)"\s*\}'
|
|
entries = re.findall(entry_pattern, dict_content)
|
|
|
|
materials = {}
|
|
for mat_id, mat_name in entries:
|
|
materials[mat_id] = mat_name
|
|
|
|
return materials
|
|
|
|
def extract_skill_info():
|
|
"""Extract SkillInfo dictionary from Dictionaries.cs."""
|
|
with open('/home/erik/MosswartOverlord/unused/Mag-Plugins/Shared/Constants/Dictionaries.cs', 'r') as f:
|
|
content = f.read()
|
|
|
|
# Find the SkillInfo dictionary
|
|
pattern = r'SkillInfo\s*=\s*new\s+Dictionary<int,\s*string>\s*\{([^}]+)\}'
|
|
match = re.search(pattern, content, re.DOTALL)
|
|
|
|
if not match:
|
|
print("SkillInfo not found\!")
|
|
return {}
|
|
|
|
dict_content = match.group(1)
|
|
|
|
# Extract entries - handle hex values
|
|
entry_pattern = r'\{\s*(0x[0-9A-Fa-f]+ < /dev/null | \d+),\s*"([^"]+)"\s*\}'
|
|
entries = re.findall(entry_pattern, dict_content)
|
|
|
|
skills = {}
|
|
for skill_id, skill_name in entries:
|
|
# Convert hex to decimal if needed
|
|
if skill_id.startswith('0x'):
|
|
skill_id = str(int(skill_id, 16))
|
|
skills[skill_id] = skill_name
|
|
|
|
return skills
|
|
|
|
def extract_mastery_info():
|
|
"""Extract MasteryInfo dictionary from Dictionaries.cs."""
|
|
with open('/home/erik/MosswartOverlord/unused/Mag-Plugins/Shared/Constants/Dictionaries.cs', 'r') as f:
|
|
content = f.read()
|
|
|
|
# Find the MasteryInfo dictionary
|
|
pattern = r'MasteryInfo\s*=\s*new\s+Dictionary<int,\s*string>\s*\{([^}]+)\}'
|
|
match = re.search(pattern, content, re.DOTALL)
|
|
|
|
if not match:
|
|
print("MasteryInfo not found\!")
|
|
return {}
|
|
|
|
dict_content = match.group(1)
|
|
|
|
# Extract entries
|
|
entry_pattern = r'\{\s*(\d+),\s*"([^"]+)"\s*\}'
|
|
entries = re.findall(entry_pattern, dict_content)
|
|
|
|
masteries = {}
|
|
for mastery_id, mastery_name in entries:
|
|
masteries[mastery_id] = mastery_name
|
|
|
|
return masteries
|
|
|
|
def main():
|
|
"""Extract all dictionaries and save to JSON."""
|
|
dictionaries = {
|
|
'AttributeSetInfo': extract_attribute_set_info(),
|
|
'MaterialInfo': extract_material_info(),
|
|
'SkillInfo': extract_skill_info(),
|
|
'MasteryInfo': extract_mastery_info()
|
|
}
|
|
|
|
# Print summary
|
|
for dict_name, dict_data in dictionaries.items():
|
|
print(f"{dict_name}: {len(dict_data)} entries")
|
|
if dict_data and dict_name == 'AttributeSetInfo':
|
|
# Show some equipment set examples
|
|
for set_id in ['13', '14', '16', '21']:
|
|
if set_id in dict_data:
|
|
print(f" {set_id} -> {dict_data[set_id]}")
|
|
|
|
# Save to file
|
|
with open('extracted_dictionaries.json', 'w') as f:
|
|
json.dump(dictionaries, f, indent=2)
|
|
|
|
print("\nDictionaries saved to extracted_dictionaries.json")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|