Skip to content

Commit ea3e606

Browse files
committed
Revert "Revert "add clan capital leaderboards""
This reverts commit a12c91b.
1 parent 8532626 commit ea3e606

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

coc/clans.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ class RankedClan(BaseClan):
4848
member_count: :class:`int`
4949
The number of members in the clan.
5050
points: :class:`int`
51-
The clan's trophy-count. If retrieving info for versus leader-boards, this will be ``None``.
51+
The clan's trophy-count. If retrieving info for capital or versus leader-boards, this will be ``None``.
5252
versus_points: :class:`int`
53-
The clan's versus trophy count. If retrieving info for regular leader boards, this will be ``None``.
53+
The clan's versus trophy count. If retrieving info for regular or capital leader boards, this will be ``None``.
54+
capital_points: :class:`int`
55+
The clan's capital trophy count. If retrieving info for regular or versus leader boards, this will be ``None``.
5456
rank: :class:`int`
5557
The clan's rank in the leader board.
5658
previous_rank: :class:`int`
@@ -62,6 +64,7 @@ class RankedClan(BaseClan):
6264
"member_count",
6365
"points",
6466
"versus_points",
67+
"capital_points",
6568
"rank",
6669
"previous_rank",
6770
)
@@ -75,6 +78,7 @@ def _from_data(self, data: dict) -> None:
7578

7679
self.points: int = data_get("clanPoints")
7780
self.versus_points: int = data_get("clanVersusPoints")
81+
self.capital_points: int = data_get("clanCapitalPoints")
7882
self.member_count: int = data_get("members")
7983
self.location = try_enum(Location, data=data_get("location"))
8084
self.rank: int = data_get("rank")

coc/client.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,40 @@ async def get_location_clans(
12711271
data = await self.http.get_location_clans(location_id, limit=limit, before=before, after=after)
12721272
return [RankedClan(data=n, client=self) for n in data["items"]]
12731273

1274+
async def get_location_clans_capital(
1275+
self, location_id: int = "global", *, limit: int = None, before: str = None, after: str = None
1276+
) -> List[RankedClan]:
1277+
"""Get clan capital rankings for a specific location
1278+
1279+
Parameters
1280+
-----------
1281+
location_id : int
1282+
The Location ID to search for. Defaults to all locations (``global``).
1283+
limit : int
1284+
The number of results to fetch.
1285+
before : str, optional
1286+
For use with paging. Not implemented yet.
1287+
after: str, optional
1288+
For use with paging. Not implemented yet.
1289+
1290+
Raises
1291+
------
1292+
Maintenance
1293+
The API is currently in maintenance.
1294+
1295+
GatewayError
1296+
The API hit an unexpected gateway exception.
1297+
1298+
1299+
Returns
1300+
--------
1301+
List[:class:`RankedClan`]
1302+
The top clans for the requested location.
1303+
"""
1304+
1305+
data = await self.http.get_location_clans_capital(location_id, limit=limit, before=before, after=after)
1306+
return [RankedClan(data=n, client=self) for n in data["items"]]
1307+
12741308
async def get_location_players(
12751309
self, location_id: int = "global", *, limit: int = None, before: str = None, after: str = None
12761310
) -> List[RankedPlayer]:

coc/http.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,9 @@ def get_location_players(self, location_id, **kwargs):
403403
def get_location_clans_versus(self, location_id, **kwargs):
404404
return self.request(Route("GET", "/locations/{}/rankings/clans-versus".format(location_id), **kwargs))
405405

406+
def get_location_clans_capital(self, location_id, **kwargs):
407+
return self.request(Route("GET", "/locations/{}/rankings/capitals".format(location_id), **kwargs))
408+
406409
def get_location_players_versus(self, location_id, **kwargs):
407410
return self.request(Route("GET", "/locations/{}/rankings/players-versus".format(location_id), **kwargs))
408411

0 commit comments

Comments
 (0)