-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtop10.py
114 lines (102 loc) · 3.49 KB
/
top10.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: set noet:ts=4:
import json
import os
import random
base_dir = os.path.dirname(__file__)
def get_top_list(players, stat_key):
occurances = {}
for uuid, player in players.items():
if uuid == 'whitelist' or uuid not in players['whitelist']:
continue
name = players['whitelist'][uuid]['name']
for k, v in player.items():
if k.find(stat_key) == 0:
if not name in occurances:
occurances[name] = 0
occurances[name] += players[uuid][k]
occurances_sorted = sorted(occurances, key=occurances.__getitem__, reverse=True)
return [{"player": key, "value": occurances[key]} for key in occurances_sorted]
players = json.loads(open(os.path.join(base_dir, "../www/json/stats/allplayers.json")).read())
cam_accounts = ['Notch', 'ShreeyamGFX', 'Coestar', 'Dinnerbone', 'UelandCam', 'AtillaTari', 'einarcam', 'hildenae', 'sakecam', 'afarberg', 'Hanyu_Furude','Kagee_Kamera', 'Tonje', 'linselus'];
uuid_indexed_players = {}
for p in players['whitelist']:
if p['name'] not in cam_accounts:
uuid_indexed_players[p['uuid']] = p
players['whitelist'] = uuid_indexed_players
top_list = {
"deaths": {
"title": "Dødd",
"entries": get_top_list(players, "stat.deaths")
},
"jumps": {
"title": "Hoppet",
"entries": get_top_list(players, "stat.jump")
},
"player_kills": {
"title": "Drept andre",
"entries": get_top_list(players, "stat.playerKills")
},
"enderman_kills": {
"title": "Drepte Endermenn",
"entries": get_top_list(players, "stat.killEntity.Enderman")
},
"played_minutes": {
"title": "Spilletid (min)",
"entries": get_top_list(players, "stat.playOneMinute")
},
"damage_taken": {
"title": "Skade motatt",
"entries": get_top_list(players, "stat.damageTaken")
},
"mined_diamond_ore": {
"title": "Diamanter utgravd",
"entries": get_top_list(players, "stat.mineBlock.minecraft.diamond_ore")
},
"mined_obsidian": {
"title": "Obsidian utgravd",
"entries": get_top_list(players, "stat.mineBlock.minecraft.obsidian")
},
"damage_dealt": {
"title": "Skade gjort",
"entries": get_top_list(players, "stat.damageDealt")
},
"treasure_fished": {
"title": "Fiskede skatter",
"entries": get_top_list(players, "stat.treasureFished")
},
"bats_killed": {
"title": "Flaggermus drept",
"entries": get_top_list(players, "stat.killEntity.Bat")
},
"mined_lapis_ore": {
"title": "Lapis utgravd",
"entries": get_top_list(players, "stat.mineBlock.minecraft.lapis_ore")
},
"blocks_mined": {
"title": "Blokker utgravd",
"entries": get_top_list(players, "stat.mineBlock.")
},
"items_crafted": {
"title": "Ting bygget",
"entries": get_top_list(players, "stat.craftItem.")
},
"fallen_cm": {
"title": "Falt (cm)",
"entries": get_top_list(players, "stat.fallOneCm")
},
"dive_cm": {
"title": "Dykket (cm)",
"entries": get_top_list(players, "stat.diveOneCm")
},
"villager_trades": {
"title": "Handlet med landsbyborgere",
"entries": get_top_list(players, "stat.tradedWithVillager")
},
"time_since_death": {
"title": "Tid siden død (eller start)",
"entries": get_top_list(players, "stat.timeSinceDeath")
}
}
open(os.path.join(base_dir, "../www/json/stats/top_lists.json"), "w+").write(json.dumps(top_list))