import json

FIELDS = ["name", "competence", "description", "duree", "portee", "concentration", "critique", "ingredients", "resistance"]

def capitalize_first_letter(s):
    if isinstance(s, str) and s:
        return s[0].upper() + s[1:]
    return s

with open("../srcdata/sort_magieduclan.json", "r", encoding="utf-8") as f:
    data = json.load(f)

for spell in data:
    for field in FIELDS:
        if field in spell:
            spell[field] = capitalize_first_letter(spell[field])

with open("../srcdata/sort_magieduclan.json", "w", encoding="utf-8") as f:
    json.dump(data, f, ensure_ascii=False, indent=2)