diff options
author | jacopo grandi <jak.sk8@hotmail.it> | 2021-02-19 18:30:53 +0100 |
---|---|---|
committer | jacopo grandi <jak.sk8@hotmail.it> | 2021-02-19 18:30:53 +0100 |
commit | 5126638d46398579c26d3c7bd908fe17b8508b13 (patch) | |
tree | fbb9e981187f32bf78dc521ff538ea31de9c0019 /build/content/autolevel.py | |
parent | 5f0fce4191309e9526b7109a0d87c092ce6a4193 (diff) |
battery calc and unstable levels
Diffstat (limited to 'build/content/autolevel.py')
-rw-r--r-- | build/content/autolevel.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/build/content/autolevel.py b/build/content/autolevel.py new file mode 100644 index 0000000..eac6e09 --- /dev/null +++ b/build/content/autolevel.py @@ -0,0 +1,28 @@ +import json + +def vectorize (obj, forbidlist): + for c in obj: + for key in c: + if not(key in forbidlist): + val = c[key] + try: val = int(val); + except: pass + try: val = float(val); + except: pass + c[key] = [val for i in range(3)] + return obj + + +def comp(filename, forbidlist): + with open(filename+".txt", "r") as f: obj = json.loads(f.read()) + obj = vectorize(obj, forbidlist) + with open(filename+".txt", "w") as f: + f.write(json.dumps(obj, indent=4)) + +if __name__ == "__main__": + #comp("weapons", ["name", "damage_type"]) + #comp("augments", ["name"]) + #comp("batteries", ["name"]) + #comp("armor", ["name"]) + #comp("chassis", ["name"]) + comp("brains", ["name"]) |