From 98d3deb401a8f6a60af236125fdd545a9de0ca6e Mon Sep 17 00:00:00 2001 From: khuxkm fbexl Date: Sun, 23 Feb 2020 10:57:47 -0500 Subject: [PATCH] Add black magic to get randgen badge rates --- get_chances.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 get_chances.py diff --git a/get_chances.py b/get_chances.py new file mode 100644 index 0000000..a486a58 --- /dev/null +++ b/get_chances.py @@ -0,0 +1,20 @@ +import ast, csv, sys + +with open("plugins/badge_plugin.py") as f: + tree = ast.parse(f.read()) + +ret = [["Badge name","Chance to pull"]] + +for statement in tree.body: + if type(statement)==ast.Assign and statement.targets[0].id=="badge_weights": + # Bingo! + d = statement.value + assert len(d.keys)==len(d.values) + for i in range(len(d.keys)): + key = d.keys[i].s + value = d.values[i].n + ret.append([key,f"{value:0.2%}"]) + +ret[1:]=sorted(ret[1:],key=lambda x: -float(x[1][:-1])) +w = csv.writer(sys.stdout) +w.writerows(ret)