Skip to content

Commit 75ed90c

Browse files
authored
Merge pull request #157 from Kuchenmampfer/capital_leaderboards
add clan capital leaderboards
2 parents 26a02f6 + d8f2649 commit 75ed90c

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
@@ -1240,6 +1240,40 @@ async def get_location_clans(
12401240
data = await self.http.get_location_clans(location_id, limit=limit, before=before, after=after)
12411241
return [RankedClan(data=n, client=self) for n in data["items"]]
12421242

1243+
async def get_location_clans_capital(
1244+
self, location_id: int = "global", *, limit: int = None, before: str = None, after: str = None
1245+
) -> List[RankedClan]:
1246+
"""Get clan capital rankings for a specific location
1247+
1248+
Parameters
1249+
-----------
1250+
location_id : int
1251+
The Location ID to search for. Defaults to all locations (``global``).
1252+
limit : int
1253+
The number of results to fetch.
1254+
before : str, optional
1255+
For use with paging. Not implemented yet.
1256+
after: str, optional
1257+
For use with paging. Not implemented yet.
1258+
1259+
Raises
1260+
------
1261+
Maintenance
1262+
The API is currently in maintenance.
1263+
1264+
GatewayError
1265+
The API hit an unexpected gateway exception.
1266+
1267+
1268+
Returns
1269+
--------
1270+
List[:class:`RankedClan`]
1271+
The top clans for the requested location.
1272+
"""
1273+
1274+
data = await self.http.get_location_clans_capital(location_id, limit=limit, before=before, after=after)
1275+
return [RankedClan(data=n, client=self) for n in data["items"]]
1276+
12431277
async def get_location_players(
12441278
self, location_id: int = "global", *, limit: int = None, before: str = None, after: str = None
12451279
) -> List[RankedPlayer]:

coc/http.py

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

399+
def get_location_clans_capital(self, location_id, **kwargs):
400+
return self.request(Route("GET", "/locations/{}/rankings/capitals".format(location_id), **kwargs))
401+
399402
def get_location_players_versus(self, location_id, **kwargs):
400403
return self.request(Route("GET", "/locations/{}/rankings/players-versus".format(location_id), **kwargs))
401404

0 commit comments

Comments
 (0)