Skip to content

Commit 81e6d59

Browse files
committed
Update mcc_api.island schema to support statistic leaderboards and rotations
1 parent 0b301b3 commit 81e6d59

File tree

6 files changed

+129
-6
lines changed

6 files changed

+129
-6
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![🐍 PyPI](https://img.shields.io/pypi/v/mcc-api?label=🐍%20PyPI)](https://pypi.org/project/mcc-api/)
44
[![👑 Targeting Event API v1.3.2](https://img.shields.io/badge/👑_Targeting_Event_API-v1.3.2-red)](https://github.com/Noxcrew/mcchampionship-api/releases/tag/v1.3.2)
5-
[![🏝️ Targeting Island API v24.05.02](https://img.shields.io/badge/🏝️_Targeting_Island_API-v24.05.02-aqua)](https://github.com/Noxcrew/mccisland-api/releases/tag/v24.05.02)
5+
[![🏝️ Targeting Island API v24.05.06](https://img.shields.io/badge/🏝️_Targeting_Island_API-v24.05.06-aqua)](https://github.com/Noxcrew/mccisland-api/releases/tag/v24.05.06)
66

77
A helper library for the [MC Championship](https://mcchampionship.com) APIs
88
([Event](https://github.com/Noxcrew/mcchampionship-api), inspired by [derNiklaas's](https://github.com/derNiklaas)

docs/index.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ python_mcc_api
77
.. image:: https://img.shields.io/badge/👑_Targeting_Event_API-v1.3.2-red
88
:alt: 👑 Targeting Event API v1.3.2
99
:target: https://github.com/Noxcrew/mcchampionship-api/releases/tag/v1.3.2
10-
.. image:: https://img.shields.io/badge/🏝️_Targeting_Island_API-v24.05.02-aqua
11-
:alt: 🏝️ Targeting Island API v24.05.02
12-
:target: https://github.com/Noxcrew/mccisland-api/releases/tag/v24.05.02
10+
.. image:: https://img.shields.io/badge/🏝️_Targeting_Island_API-v24.05.06-aqua
11+
:alt: 🏝️ Targeting Island API v24.05.06
12+
:target: https://github.com/Noxcrew/mccisland-api/releases/tag/v24.05.06
1313

1414
A helper library for the `MC Championship <https://mcchampionship.com>`_ APIs
1515
(`Event <https://github.com/Noxcrew/mcchampionship-api>`_, inspired by `derNiklaas's <https://github.com/derNiklaas>`_

mcc_api/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
"__version__"
55
]
66

7-
__version__ = "1.1.1"
7+
__version__ = "1.1.2"
88
__user_agent: t.Final[str] = f"python_mcc_api/{__version__} (https://github.com/JamesMCo/python_mcc_api)"

mcc_api/island/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
collections_type,
2121
crown_level_type,
2222
currency_type,
23+
leaderboard_entry_type,
2324
party_type,
2425
player_type,
2526
progression_data_type,
@@ -35,6 +36,7 @@
3536

3637
game_enum,
3738
rank_enum,
39+
rotation_enum,
3840
server_category_enum,
3941
trophy_category_enum,
4042
]

mcc_api/island/enums.py

+29-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
__all__ = [
5-
"game_enum", "rank_enum", "server_category_enum", "trophy_category_enum"
5+
"game_enum", "rank_enum", "rotation_enum", "server_category_enum", "trophy_category_enum"
66
]
77

88
game_enum = GraphQLEnumType(
@@ -75,6 +75,34 @@
7575
}
7676
)
7777

78+
rotation_enum = GraphQLEnumType(
79+
name="Rotation",
80+
description="A rotation period.\n\n"
81+
"Each period resets at 10AM UTC.",
82+
values={
83+
"DAILY": GraphQLEnumValue(
84+
value="DAILY",
85+
description="A daily rotation that resets."
86+
),
87+
"WEEKLY": GraphQLEnumValue(
88+
value="WEEKLY",
89+
description="A weekly rotation that resets on Tuesdays."
90+
),
91+
"MONTHLY": GraphQLEnumValue(
92+
value="MONTHLY",
93+
description="A monthly rotation that resets on the first day of every month."
94+
),
95+
"YEARLY": GraphQLEnumValue(
96+
value="YEARLY",
97+
description="A yearly rotation that resets on the first day of every year."
98+
),
99+
"LIFETIME": GraphQLEnumValue(
100+
value="LIFETIME",
101+
description="A lifetime rotation; a rotation period used to indicate something never rotates."
102+
)
103+
}
104+
)
105+
78106
server_category_enum = GraphQLEnumType(
79107
name="ServerCategory",
80108
description="The category of a server.",

mcc_api/island/types.py

+93
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"collections_type",
1111
"crown_level_type",
1212
"currency_type",
13+
"leaderboard_entry_type",
1314
"party_type",
1415
"player_type",
1516
"progression_data_type",
@@ -92,6 +93,27 @@
9293
}
9394
)
9495

96+
leaderboard_entry_type = GraphQLObjectType(
97+
name="LeaderboardEntry",
98+
description="An entry in a leaderboard.",
99+
fields=lambda: {
100+
"player": GraphQLField(
101+
player_type,
102+
description="The player who has this entry.\n\n"
103+
"This will be `null` if the player does not have the statistics enabled for the API.\n"
104+
"However, for Crown Level or Trophy count leaderboards, the player will not be `null`."
105+
),
106+
"rank": GraphQLField(
107+
GraphQLNonNull(GraphQLInt),
108+
description="The rank for this entry."
109+
),
110+
"value": GraphQLField(
111+
GraphQLNonNull(GraphQLInt),
112+
description="The value for this entry."
113+
)
114+
}
115+
)
116+
95117
party_type = GraphQLObjectType(
96118
name="Party",
97119
description="A player's status within a party.",
@@ -202,6 +224,37 @@
202224
"statistics": GraphQLField(
203225
GraphQLNonNull(GraphQLList(GraphQLNonNull(statistic_type))),
204226
description="Returns a list of all known statistics."
227+
),
228+
"statistic": GraphQLField(
229+
statistic_type,
230+
description="Returns a statistic by it's name.",
231+
args={
232+
"key": GraphQLArgument(
233+
GraphQLNonNull(GraphQLString)
234+
)
235+
}
236+
),
237+
"nextRotation": GraphQLField(
238+
GraphQLNonNull(datetime_scalar),
239+
description="Returns when this rotation will next rotate.\n\n"
240+
"If the rotation is due the exact time this method is called, "
241+
"this method will return the next time that it will rotate.",
242+
args={
243+
"rotation": GraphQLArgument(
244+
GraphQLNonNull(rotation_enum)
245+
)
246+
}
247+
),
248+
"previousRotation": GraphQLField(
249+
GraphQLNonNull(datetime_scalar),
250+
description="Returns when this rotation last rotated.\n\n"
251+
"If the rotation is due the exact time this method is called, "
252+
"this method will return the current time.",
253+
args={
254+
"rotation": GraphQLArgument(
255+
GraphQLNonNull(rotation_enum)
256+
)
257+
}
205258
)
206259
}
207260
)
@@ -251,6 +304,29 @@
251304
"key": GraphQLField(
252305
GraphQLNonNull(GraphQLString),
253306
description="The key of the statistic."
307+
),
308+
"leaderboard": GraphQLField(
309+
GraphQLList(GraphQLNonNull(leaderboard_entry_type)),
310+
description="Returns the leaderboard for this statistic in a given rotation.\n\n"
311+
"If this statistic does not generate leaderboards, "
312+
"or the statistic is not tracked for the provided rotation, this will return `null`.",
313+
args={
314+
"amount": GraphQLArgument(
315+
GraphQLNonNull(GraphQLInt),
316+
default_value=10
317+
),
318+
"rotation": GraphQLArgument(
319+
GraphQLNonNull(rotation_enum),
320+
default_value=rotation_enum.values["LIFETIME"].value
321+
)
322+
}
323+
),
324+
"rotations": GraphQLField(
325+
GraphQLNonNull(GraphQLList(GraphQLNonNull(rotation_enum))),
326+
description="The rotations for which this statistic is tracked.\n\n"
327+
"These are the rotations that can be used to generate leaderboards or fetch rotation values.\n"
328+
"Note that the `YEARLY` rotation never generates leaderboards, "
329+
"even if it is returned in this list."
254330
)
255331
}
256332
)
@@ -281,6 +357,23 @@
281357
"statisticKey": GraphQLArgument(
282358
GraphQLNonNull(GraphQLString)
283359
)
360+
},
361+
deprecation_reason="This value is not backed by a rotation and will be removed. "
362+
"Use `rotationValue` instead."
363+
),
364+
"rotationValue": GraphQLField(
365+
GraphQLInt,
366+
description="Returns the value stored for the given statistic in a rotation.\n\n"
367+
"The returned number will be `null` if the statistic does not track in the provided rotation, "
368+
"or if the statistic doesn't exist.",
369+
args={
370+
"rotation": GraphQLArgument(
371+
GraphQLNonNull(rotation_enum),
372+
default_value=rotation_enum.values["LIFETIME"].value
373+
),
374+
"statisticKey": GraphQLArgument(
375+
GraphQLNonNull(GraphQLString)
376+
)
284377
}
285378
)
286379
}

0 commit comments

Comments
 (0)