-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmerge_stats.py
65 lines (53 loc) · 2.29 KB
/
merge_stats.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
import json
import os
import sys
from collections import defaultdict
from copy import deepcopy
def merge(stats, tmp_stats):
for key in tmp_stats:
if isinstance(tmp_stats[key], dict):
for key2 in tmp_stats[key]:
stats[key][key2] += tmp_stats[key][key2]
elif isinstance(tmp_stats[key], int):
stats[key] += tmp_stats[key]
path = sys.argv[1]
ignore = -1
players = ["Armata", "CierneZeny", "Elerpe", "My", "RuzovyTank", "TankiOffline", "atsooi", "budapest", "dvaja_strateny",
"gersiagi", "janci", "kockumamdoma", "kocurika", "kokorokjo", "krtko", "misqo", "okno",
"pecenezemiaky", "poharvdzbane", "robotrt", "severnakambodza", "zrovnamebudapest", "stefan.exe", "tanky.io",
"tiger"]
scores = defaultdict(lambda: 0)
scores_progress = defaultdict(lambda: [])
scores_progress_d = defaultdict(lambda: [])
colors = ['b', 'g', 'r', 'c', 'm', 'y', 'k', '#000000', '#f7db8d', '#f78de7', '#4a013f', '#a0ff8f', '#71b9f0',
'#f07171', '#ff8945', '#bdbdbd', '#ff0000', '#f6ff00', '#2e1100', '#00002e', '#578f77', '#1f4233']
stats = {
"time_by_tank": {"0": 0, "1": 0, "2": 0, "3": 0, "4": 0, "5": 0, "6": 0, "7": 0, "8": 0, "9": 0, "10": 0, "11": 0, "12": 0},
"score_by_reason": {"0": 0, "1": 0, "2": 0, "3": 0, "4": 0, "5": 0},
"time_in_cooldown": 0, "time_not_in_cooldown": 0, "time_of_responses": 0,
"stats": {
"range": 0,
"speed": 0,
"bullet_speed": 0,
"bullet_ttl": 0,
"bullet_damage": 0,
"health_max": 0,
"health_regeneration": 0,
"body_damage": 0,
"reload_speed": 0
}
}
player_stats = {}
for player in players:
player_stats[player] = deepcopy(stats)
for (dirpath, dirnames, filenames) in os.walk(path):
for dirname in dirnames:
if dirname.startswith('game-'):
if int(dirname[len('game-'):]) > ignore:
try:
tmp_stats = json.load(open(path + os.sep + dirname + os.sep + "stats.json", 'r', encoding='utf-8'))
for player in tmp_stats:
merge(player_stats[player], tmp_stats[player])
except Exception as e:
print(f"exception {e} in directory {dirname}")
json.dump(player_stats, open("statistics.json", "w"), indent=2)