Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions coc/clans.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ class RankedClan(BaseClan):
member_count: :class:`int`
The number of members in the clan.
points: :class:`int`
The clan's trophy-count. If retrieving info for versus leader-boards, this will be ``None``.
The clan's trophy-count. If retrieving info for capital or versus leader-boards, this will be ``None``.
versus_points: :class:`int`
The clan's versus trophy count. If retrieving info for regular leader boards, this will be ``None``.
The clan's versus trophy count. If retrieving info for regular or capital leader boards, this will be ``None``.
capital_points: :class:`int`
The clan's capital trophy count. If retrieving info for regular or versus leader boards, this will be ``None``.
rank: :class:`int`
The clan's rank in the leader board.
previous_rank: :class:`int`
Expand All @@ -62,6 +64,7 @@ class RankedClan(BaseClan):
"member_count",
"points",
"versus_points",
"capital_points",
"rank",
"previous_rank",
)
Expand All @@ -75,6 +78,7 @@ def _from_data(self, data: dict) -> None:

self.points: int = data_get("clanPoints")
self.versus_points: int = data_get("clanVersusPoints")
self.capital_points: int = data_get("clanCapitalPoints")
self.member_count: int = data_get("members")
self.location = try_enum(Location, data=data_get("location"))
self.rank: int = data_get("rank")
Expand Down
34 changes: 34 additions & 0 deletions coc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,40 @@ async def get_location_clans(
data = await self.http.get_location_clans(location_id, limit=limit, before=before, after=after)
return [RankedClan(data=n, client=self) for n in data["items"]]

async def get_location_clans_capital(
self, location_id: int = "global", *, limit: int = None, before: str = None, after: str = None
) -> List[RankedClan]:
"""Get clan capital rankings for a specific location

Parameters
-----------
location_id : int
The Location ID to search for. Defaults to all locations (``global``).
limit : int
The number of results to fetch.
before : str, optional
For use with paging. Not implemented yet.
after: str, optional
For use with paging. Not implemented yet.

Raises
------
Maintenance
The API is currently in maintenance.

GatewayError
The API hit an unexpected gateway exception.


Returns
--------
List[:class:`RankedClan`]
The top clans for the requested location.
"""

data = await self.http.get_location_clans_capital(location_id, limit=limit, before=before, after=after)
return [RankedClan(data=n, client=self) for n in data["items"]]

async def get_location_players(
self, location_id: int = "global", *, limit: int = None, before: str = None, after: str = None
) -> List[RankedPlayer]:
Expand Down
3 changes: 3 additions & 0 deletions coc/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,9 @@ def get_location_players(self, location_id, **kwargs):
def get_location_clans_versus(self, location_id, **kwargs):
return self.request(Route("GET", "/locations/{}/rankings/clans-versus".format(location_id), **kwargs))

def get_location_clans_capital(self, location_id, **kwargs):
return self.request(Route("GET", "/locations/{}/rankings/capitals".format(location_id), **kwargs))

def get_location_players_versus(self, location_id, **kwargs):
return self.request(Route("GET", "/locations/{}/rankings/players-versus".format(location_id), **kwargs))

Expand Down
4 changes: 2 additions & 2 deletions docs/client/logging_in.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Logging In
==========
A coc.py client instance can be created directly by :class:`Client`. The instance can then be logged in with the methods

.. autofunction:: coc.client.Client.login
.. autofunction:: coc.Client.login

.. autofunction:: coc.client.Client.login_with_tokens
.. autofunction:: coc.Client.login_with_tokens


Example
Expand Down
9 changes: 8 additions & 1 deletion docs/miscellaneous/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ Changelog
This page keeps a fairly detailed, human readable version
of what has changed, and whats new for each version of the lib.

v2.3.1
------

- Added back :func:`coc.Client.get_location_clans_capital` which was accidentally reverted in 2.3.0

- Fixed some minor typos in the docs

v2.3.0
------
Additions:
Expand Down Expand Up @@ -52,7 +59,7 @@ Bugs Fixed:

- Fixed a bug that tried to use a cache when `max_cache_size` was set to 0

- Corrected order of elixir troups
- Corrected order of elixir troops

- Fixed a bug when clans faced each other multiple times in one raid weekend

Expand Down