-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatCalculator.py
128 lines (98 loc) · 2.86 KB
/
statCalculator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
"""
Stat calculator script for the H2O leaderboard bot
"""
import math
import os
import json
def simplifyStat(n):
"""
Simplify numbers in an easier to read format
- note this does round to 5 significant figures to hinders the accuracy of the numbers.
"""
try:
if n < 1000:
n = n
elif n < 1000000:
n = float(n)/1000
n = f"{n:.5g}K"
elif n < 1000000000:
n = float(n)/1000000
n = f"{n:.5g}M"
elif n < 1000000000000:
n = float(n)/1000000000
n = f"{n:.5g}B"
elif n < 1000000000000000:
n = float(n)/1000000000000
n = f"{n:.5g}T"
elif n < 1000000000000000000:
n = float(n)/1000000000000000
n = f"{n:.5g}Qa"
elif n < 1000000000000000000000:
n = float(n)/1000000000000000000
n = f"{n:.5g}Qi"
return n
except:
return
def getData(id):
with open("userData.json", "r") as f:
userData = dict(json.load(f))
f.close()
idInfo = {}
for i in userData:
idUser = userData[i]
idInfo[i] = idUser[id]
idInfo = sorted(idInfo.items(), key=lambda x: x[1], reverse=True)
return idInfo
def statHidden(i):
with open("userData.json", "r") as f:
userData = dict(json.load(f))
f.close()
if userData[i]["hidden"] == True:
return True
else:
return False
def psychicLeaderboard():
"""
Grab each users psychic power data from the database
"""
statPS = getData("statPS")
return statPS
def bodyLeaderboard():
"""
Grab each users body toughness data from the database
"""
statBT = getData("statBT")
return statBT
def fistLeaderboard():
"""
Grab each users fist strength data from the database
"""
statFS = getData("statFS")
return statFS
def movementLeaderboard():
statMS = getData("statMS")
return statMS
def jumpForceLeaderboard():
statJF = getData("statJF")
return statJF
def totalLeaderboard():
"""
Calculate each users total power using the database
"""
with open("userData.json", "r") as f:
userData = json.load(f)
f.close()
statFS = {}
statBT = {}
statPS = {}
statTP = {}
for i in userData:
userFS = userData[i]["statFS"]
userBT = userData[i]["statBT"]
userPS = userData[i]["statPS"]
statFS[i] = userFS
statBT[i] = userBT
statPS[i] = userPS
statTP[i] = statFS[i] + statBT[i] + statPS[i]
statTP = sorted(statTP.items(), key=lambda x: x[1], reverse=True)
return statTP