Skip to content

Commit

Permalink
Merge pull request #36 from 201st-Luka/new-features
Browse files Browse the repository at this point in the history
New features
  • Loading branch information
201st-Luka authored Aug 27, 2023
2 parents d1c33cc + da329bb commit d59ed89
Show file tree
Hide file tree
Showing 40 changed files with 840 additions and 90 deletions.
50 changes: 24 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,50 @@ requested data.

---

I am planning to release the package on pypi.org after my exams. This is probably in the first week of september.
I am planning to release the package on pypi.org after my exams. This is
probably in the first week of september.

The package is still in development and will be finished as short as
possible for me. When the package covers the
whole ClashOfClans API, the repository will be transformed into
a python package and will be available for everyone.
possible for me. When the package covers the whole ClashOfClans API, the
repository will be transformed into a python package and will be available for
everyone.

If you have any questions, feel free to join my discord server
to ask you question.
If you have any questions, feel free to join my discord server to ask your
question.

## Installation

It is possible to install the package from GitHib releases. You can use the following command to add PyClasher to your library:
It is possible to install the package from GitHib releases. You can use the
following command to add PyClasher to your library:
```bash
pip install git+https://github.com/201st-Luka/PyClasher.git@v0.0.1-alpha3
pip install git+https://github.com/201st-Luka/PyClasher.git@v1.0.0-alpha1
```

---

## Features
- Asynchronous and parallel requesting
- Possibility to use multiple tokens and to login via email address
and password of the ClashOfClans developer portal
- Control over the number of requests per second and the number of
used tokens
- Possibility to use multiple tokens and to login via email address and
password of the ClashOfClans developer portal
- Control over the number of requests per second and the number of used tokens
- Open source
- Documented and type hinted
- Type hinted
- Sopports Python 3.8 -> 3.11

---

## Contributing

Feel free to contribute to the repository.

You can fork the repository and commit your changes in a pull request. Please consider to check out the
[Discord server][discord_url] if so.
You can fork the repository and commit your changes in a pull request. Please
consider to check out the [Discord server][discord_url] if so.

---

## Future

I'm planning to keep the API wrapper up to date and improve it as
good as I can.
I'm planning to keep the API wrapper up to date and improve it as good as I can.

### Planned features

Expand All @@ -67,23 +68,20 @@ good as I can.

### Planned code implementations (ToDo-list)

- `total_wars` attribute for `ClanWarLogEntry`
- war log filtering for `ClanWarLogRequest` (for example filter the number of attacks per member)
- some "average" attributes for `Clan`-classes, `WarLog`-classes, ...
- 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)
- attributes `king`, `queen`, `warden`, `royal_champion` for the
`Player.heroes` attribute
- events and an `EventClient`

---

If you find a bug, an error or want custom functionality, please tell
me via Discord or open an issue or start a discussion on the
GitHub-repository.
If you find a bug, an error or want custom functionality, please tell me via
Discord or open an issue or start a discussion on the GitHub-repository.

---

##### Disclaimer
This material is unofficial and is not endorsed by Supercell. For more information see Supercell's Fan Content Policy:
This material is unofficial and is not endorsed by Supercell. For more
information see Supercell's Fan Content Policy:
www.supercell.com/fan-content-policy.


Expand Down
83 changes: 70 additions & 13 deletions pyclasher/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
pyclasher ClashOfClans API wrapper client
This wrapper client has been created by 201st-Luka.
This wrapper client has been created and developed by 201st-Luka.
`GitHub <https://github.com/201st-Luka/PyClasher>`_
`Wiki <https://github.com/201st-Luka/PyClasher/wiki>`_
Expand All @@ -11,20 +11,77 @@

__version__ = '1.0.0-alpha1'

# api
from .api import *
from .client import Client
from .exceptions import (
PyClasherException, ApiException, ApiExceptions, UnknownApiException,
MISSING, Missing, RequestNotDone, RequestTimeout, BadRequest, NotFound,
Throttled, Maintenance, AccessDenied, NoClient, InvalidClientId,
ClientIsRunning, ClientIsNotRunning, ClientRunningOverwrite,
ClientAlreadyInitialised, LoginNotDone, InvalidLoginData, InvalidType,
InvalidTimeFormat, InvalidSeasonFormat, NoneToken
)

# utils
from .utils import *
__all__ = (
"PlayerBulkRequest",

# client.py
from .client import Client
"BuilderBaseLeagueRequest",
"BuilderBaseLeaguesRequest",
"CapitalLeagueRequest",
"CapitalLeaguesRequest",
"CapitalRankingsRequest",
"ClanRequest",
"ClanBuilderBaseRankingsRequest",
"ClanCapitalRaidSeasonsRequest",
"ClanCurrentWarRequest",
"ClanCurrentwarLeaguegroupRequest",
"ClanLabelsRequest",
"ClanMembersRequest",
"ClanRankingsRequest",
"ClanSearchRequest",
"ClanWarLogRequest",
"ClanWarleaguesWarsRequest",
"GoldPassRequest",
"LeagueRequest",
"LeagueSeasonRequest",
"LeagueSeasonsRequest",
"LeaguesRequest",
"LocationRequest",
"LocationsRequest",
"PlayerRequest",
"PlayerBuilderBaseRankingsRequest",
"PlayerLabelsRequest",
"PlayerRankingsRequest",
"WarLeagueRequest",
"WarLeaguesRequest",

# exceptions.py
from .exceptions import (
Missing, MISSING, PyClasherException, RequestNotDone, NoneToken,
InvalidLoginData, InvalidType, LoginNotDone, ClientIsRunning,
ClientIsNotRunning, ClientAlreadyInitialised, NoClient,
InvalidTimeFormat, ClientRunningOverwrite, InvalidSeasonFormat,
RequestTimeout
"__version__",

"Client",

"PyClasherException",
"ApiException",
"ApiExceptions",
"UnknownApiException",
"MISSING",
"Missing",
"RequestNotDone",
"RequestTimeout",
"BadRequest",
"NotFound",
"Throttled",
"Maintenance",
"AccessDenied",
"NoClient",
"InvalidClientId",
"ClientIsRunning",
"ClientIsNotRunning",
"ClientRunningOverwrite",
"ClientAlreadyInitialised",
"LoginNotDone",
"InvalidLoginData",
"InvalidType",
"InvalidTimeFormat",
"InvalidSeasonFormat",
"NoneToken"
)
34 changes: 34 additions & 0 deletions pyclasher/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
from .bulk_requests import *
from .models import *
from .requests import *

__all__ = (
"PlayerBulkRequest",

"BuilderBaseLeagueRequest",
"BuilderBaseLeaguesRequest",
"CapitalLeagueRequest",
"CapitalLeaguesRequest",
"CapitalRankingsRequest",
"ClanRequest",
"ClanBuilderBaseRankingsRequest",
"ClanCapitalRaidSeasonsRequest",
"ClanCurrentWarRequest",
"ClanCurrentwarLeaguegroupRequest",
"ClanLabelsRequest",
"ClanMembersRequest",
"ClanRankingsRequest",
"ClanSearchRequest",
"ClanWarLogRequest",
"ClanWarleaguesWarsRequest",
"GoldPassRequest",
"LeagueRequest",
"LeagueSeasonRequest",
"LeagueSeasonsRequest",
"LeaguesRequest",
"LocationRequest",
"LocationsRequest",
"PlayerRequest",
"PlayerBuilderBaseRankingsRequest",
"PlayerLabelsRequest",
"PlayerRankingsRequest",
"WarLeagueRequest",
"WarLeaguesRequest"
)
5 changes: 5 additions & 0 deletions pyclasher/api/bulk_requests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
from .b_player import PlayerBulkRequest
from .b_request_model import BulkRequestModel

__all__ = (
"PlayerBulkRequest",
)
52 changes: 52 additions & 0 deletions pyclasher/api/bulk_requests/b_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,55 @@ def from_clan(cls, clan):
@classmethod
def from_member_list(cls, member_list):
return cls((member.tag for member in member_list))

@property
def average_attack_wins(self):
return sum((p.attack_wins for p in self)) / len(self)

@property
def average_defense_wins(self):
return sum((p.defense_wins for p in self)) / len(self)

@property
def average_town_hall_level(self):
return sum((p.town_hall_level for p in self)) / len(self)

@property
def average_versus_battle_wins(self):
return sum((p.versus_battle_wins for p in self)) / len(self)

@property
def average_exp_level(self):
return sum((p.exp_level for p in self)) / len(self)

@property
def average_trophies(self):
return sum((p.trophies for p in self)) / len(self)

@property
def average_donations(self):
return sum((p.donations for p in self)) / len(self)

@property
def average_donations_received(self):
return sum((p.donations_received for p in self)) / len(self)

@property
def average_builder_hall_level(self):
return sum((p.builder_hall_level for p in self)) / len(self)

@property
def average_builder_base_trophies(self):
return sum((p.builder_base_trophies for p in self)) / len(self)

@property
def average_best_builder_base_trophies(self):
return sum((p.best_builder_base_trophies for p in self)) / len(self)

@property
def average_war_stars(self):
return sum((p.war_stars for p in self)) / len(self)

@property
def average_clan_capital_contributions(self):
return sum((p.clan_capital_contributions for p in self)) / len(self)
55 changes: 54 additions & 1 deletion pyclasher/api/bulk_requests/b_player.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from typing import Iterable, Coroutine, Any, Iterator

from .b_request_model import BulkRequestModel
from ..models import BaseClan, ClanMemberList, ClanWarMemberList, ClanWarLeagueClanMemberList, \
from ..models import BaseClan, ClanMemberList, ClanWarMemberList, \
ClanWarLeagueClanMemberList, \
ClanCapitalRaidSeasonMemberList
from ..requests import PlayerRequest, ClanMembersRequest

Expand Down Expand Up @@ -67,6 +68,58 @@ class PlayerBulkRequest(BulkRequestModel):
"""
...

@property
def average_attack_wins(self) -> float:
...

@property
def average_defense_wins(self) -> float:
...

@property
def average_town_hall_level(self) -> float:
...

@property
def average_versus_battle_wins(self) -> float:
...

@property
def average_exp_level(self) -> float:
...

@property
def average_trophies(self) -> float:
...

@property
def average_donations(self) -> float:
...

@property
def average_donations_received(self) -> float:
...

@property
def average_builder_hall_level(self) -> float:
...

@property
def average_builder_base_trophies(self) -> float:
...

@property
def average_best_builder_base_trophies(self) -> float:
...

@property
def average_war_stars(self) -> float:
...

@property
def average_clan_capital_contributions(self) -> float:
...

def __getitem__(self, item: int) -> PlayerRequest:
"""
getter for a player of the bulk request
Expand Down
Loading

0 comments on commit d59ed89

Please sign in to comment.