-
Notifications
You must be signed in to change notification settings - Fork 1
/
season_stitcher.py
38 lines (30 loc) · 1.03 KB
/
season_stitcher.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
import curves
import json
import argparse
import os
from tarot_commands import leaderboard
def fuse_history_and_players(folder_list):
history, players = [], {}
for folder in folder_list:
# concatenante histories, assuming they are given chronologically
with open(os.path.join(folder, 'history.json'), 'r') as f:
history.extend(json.load(f))
# final score of each player is the sum of their season scores
with open(os.path.join(folder, 'players.json'), 'r') as f:
players_dict = json.load(f)
for (player, score) in players_dict.items():
if player in players:
players[player] += score
else:
players[player] = score
with open('players.json', 'w') as f:
json.dump(players, f, indent=4)
with open('history.json', 'w') as f:
json.dump(history, f, indent=4)
all_folders = os.listdir()
season_folders = sorted([s for s in all_folders if 'saison' in s])
fuse_history_and_players(season_folders)
curves.render_curves()
print(leaderboard.leaderboard_text())
print('\n\n\n\n')
print(leaderboard.leaderboard2_text())