forked from BeanGirlThing/6NimmtEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleDataParser.py
More file actions
33 lines (22 loc) · 791 Bytes
/
SimpleDataParser.py
File metadata and controls
33 lines (22 loc) · 791 Bytes
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
import json
from math import floor
class SimpleDataParser:
PLAYER_NAMES = []
win_count = {}
def __init__(self):
with open("datafile.json", "r") as f:
data = json.load(f)
self.PLAYER_NAMES = data["player_names"]
for player in self.PLAYER_NAMES:
self.win_count[player] = 0
game_total = 0
for game in data["games"]:
self.win_count[game["winner"]] += 1
game_total += 1
print(f"{game_total} Games were played\n")
for player in self.PLAYER_NAMES:
print(f"{player}:")
print(f"Won: {self.win_count[player]}")
print(f"Winrate: {round((self.win_count[player] / game_total) * 100, 2)}%\n")
if __name__ == '__main__':
SimpleDataParser()