"""
This file will generate a list of achievements that can be used by the Unlock.Achievements function of the cheat.

files :
script.json -> all the functions/strings/data in the game, generated by https://github.com/Perfare/Il2CppDumper
out.cs -> final list of achievements in the form : string[] achievements = { "XXX" ...};
"""
import json
  
# Opening JSON file
f = open('script.json')
data = json.load(f)

o = open('out.cs', 'w')
o.write("string[] achievements = {")
tot_ach = 0
for i in data['ScriptString']:
    v = i["Value"]
    if "ACH_" in v :
        o.write('"'+v+'", ')
        tot_ach+=1
o.write("};\n")

tot_stat = 0
o.write("string[] stats = {")
for j in data['ScriptString']:
    v = j["Value"]
    if "STAT_" in v :
        o.write('"'+v+'", ')
        tot_stat+=1
o.write("};\n")

print(f"{tot_ach} achievements, {tot_stat} stats")

# Closing files
o.close()
f.close()