-
Notifications
You must be signed in to change notification settings - Fork 0
/
achievements.py
149 lines (148 loc) · 4.9 KB
/
achievements.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
def get_eligible_achievements(info):
return [definition for definition in definitions if definition["eligible"](info)]
definitions = [
# place 0 in global chart
{
"name": 'global_chart_gold',
"eligible": lambda info: len(info["global_chart"]) >= 1 and info["global_chart"][0][0] == info["name"],
'image': 'trophy',
'name': 'Global #1',
'text': 'Number one on the global chart'
},
# place 1 in global chart
{
"name": 'global_chart_silver',
"eligible": lambda info: len(info["global_chart"]) >= 2 and info["global_chart"][1][0] == info["name"],
'image': 'medal',
'name': 'Global #2',
'text': 'Number two on the global chart'
},
# place 2 in global chart
{
"name": 'global_chart_bronze',
"eligible": lambda info: len(info["global_chart"]) >= 3 and info["global_chart"][2][0] == info["name"],
'image': 'award',
'name': 'Global #3',
'text': 'Number three on the global chart'
},
# played at least 5 games, all ratings above 1100
{
"name": 'star',
"eligible": lambda info: len(info["ratings"]) >= 5 and info["ratings"][-1][2] > 1100,
'image': 'star',
'name': 'Star',
'text': 'Played at least five games and all ratings above 1100'
},
# leader in at least one game
{
"name": 'number_one',
"eligible": lambda info: len([placement for (game, game_name, rating, placement) in info["ratings"] if placement == 0]) > 0,
'image': 'crown',
'name': 'Number One',
'text': 'Leader of at least one game'
},
# at least three ratings > 1100
{
"name": 'diverse',
"eligible": lambda info: len(info["ratings"]) >= 3 and info["ratings"][2][2] > 1100,
'image': 'hand-peace',
'name': 'Diverse',
'text': 'Rating above 1100 in at least three games'
},
# highest rating > 2500
{
"name": 'grand_master',
"eligible": lambda info: info["ratings"][0][2] > 2500,
'image': 'hat-wizard',
'name': 'Grand Master',
'text': 'At least one rating above 2500'
},
# highest rating > 2000
{
"name": 'master',
"eligible": lambda info: info["ratings"][0][2] > 2000,
'image': 'gem',
'name': 'Master',
'text': 'At least one rating above 2000'
},
# highest rating > 1500
{
"name": 'journeyman',
"eligible": lambda info: info["ratings"][0][2] > 1500,
'image': 'hammer',
'name': 'Journeyman',
'text': 'At least one rating above 1500'
},
# highest rating > 1300
{
"name": 'apprentice',
"eligible": lambda info: info["ratings"][0][2] > 1300,
'image': 'broom',
'name': 'Apprentice',
'text': 'At least one rating above 1300'
},
# highest rating > 1100
{
"name": 'challenger',
"eligible": lambda info: info["ratings"][0][2] > 1100,
'image': 'rocket',
'name': 'Challenger',
'text': 'At least one rating above 1100'
},
# highest rating > 1000
{
"name": 'not_bad',
"eligible": lambda info: info["ratings"][0][2] > 1000,
'image': 'thumbs-up',
'name': "Not bad!",
'text': 'At least one rating above 1000.'
},
# Low highest rating :)
{
"name": 'potential',
"eligible": lambda info: info["ratings"][0][2] <= 1000,
'image': 'level-up-alt',
'name': 'Potential',
'text': 'Has real potential to improve rating!'
},
# on global chart
{
"name": 'charter',
"eligible": lambda info: len([player for (player, percent) in info["global_chart"] if player == info["name"]]) > 0,
'image': 'list-ol',
'name': 'Charter',
'text': 'Member of the global chart'
},
# played all games
{
"name": 'versatile',
"eligible": lambda info: len(info["ratings"]) == len(info["games"]),
'image': 'asterisk',
'name': 'Versatile',
'text': 'Played all games'
},
# only played one type of game
{
"name": 'snowflake',
"eligible": lambda info: len(info["ratings"]) == 1,
'image': 'snowflake',
'name': 'Snowflake',
'text': 'Only played one kind of game'
},
# highest rating > 1100 and lowest rating < 900
{
"name": 'fluctuating',
"eligible": lambda info: info["ratings"][0][2] > 1100 and info["ratings"][-1][2] < 900,
'image': 'arrows-alt-v',
'name': 'Fluctuating',
'text': 'At least one rating above 1100 and at least one rating below 900'
},
# Played at least 5 different types of games
{
"name": 'multi_player',
"eligible": lambda info: len(info["ratings"]) >= 5,
'image': 'headset',
'name': 'Multi Player',
'text': 'Played at least five different types of games'
},
]