Skip to content

Commit

Permalink
feat: player sorting in ClanCurrentWarRequest
Browse files Browse the repository at this point in the history
implemented automatic player sorting (by map position) for the clan and opponent members of the `ClanCurrentWarRequest`
  • Loading branch information
201st-Luka committed Aug 26, 2023
1 parent 1d92cab commit 7b867d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ I'm planning to keep the API wrapper up to date and improve it as good as I can.

- attributes `king`, `queen`, `warden`, `royal_champion` for the
`Player.heroes` attribute
- autosort for the `ClanCurrentWarRequest` members of the `member_list`
attribute (sorted by the map position)
- events and an `EventClient`

---
Expand Down
11 changes: 11 additions & 0 deletions pyclasher/api/requests/clan_current_war.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,14 @@ async def from_base_clan(cls, base_clan):
self = await cls(base_clan.tag).request()
return self

async def request(self, client_id=None):
await super().request(client_id)

self._data['clan']['members'] = sorted(
self._data['clan']['members'],
key=lambda member: member['mapPosition']
)
self._data['opponent']['members'] = sorted(
self._data['opponent']['members'],
key=lambda member: member['mapPosition']
)

0 comments on commit 7b867d1

Please sign in to comment.