import json
from pathlib import Path

root = Path(__file__).resolve().parents[4]
for relative in ['data/game_data_master.json', 'tools/game-data-manager/data/draft.json']:
    after = json.loads((root / relative).read_text(encoding='utf-8'))
    before = json.loads((Path(__file__).parent / (Path(relative).name + '.before.json')).read_text(encoding='utf-8'))
    changes = []
    def compare(a, b, path=''):
        if isinstance(a, dict) and isinstance(b, dict):
            for key in a.keys() | b.keys():
                if key not in a or key not in b:
                    changes.append(path + '/' + key)
                else:
                    compare(a[key], b[key], path + '/' + key)
        elif a != b:
            changes.append(path)
    compare(before, after)
    print(relative, changes[:30], 'total', len(changes))
