diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..fd16ba2 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,10 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files diff --git a/erepublik/citizen.py b/erepublik/citizen.py index 6745517..8910b8a 100644 --- a/erepublik/citizen.py +++ b/erepublik/citizen.py @@ -2,7 +2,7 @@ import re import sys import warnings import weakref -from datetime import datetime, timedelta, time +from datetime import datetime, time, timedelta from decimal import Decimal from itertools import product from threading import Event @@ -11,7 +11,7 @@ from typing import Any, Dict, List, NoReturn, Optional, Set, Tuple, Union from requests import HTTPError, RequestException, Response -from . import access_points, classes, constants, utils, types +from . import access_points, classes, constants, types, utils from .classes import OfferItem @@ -2617,17 +2617,21 @@ class Citizen(CitizenAnniversary, CitizenCompanies, CitizenLeaderBoard, data = self._get_main_weekly_challenge_data().json() self.details.pp = data.get("player", {}).get("prestigePoints", 0) self.details.next_pp.clear() + max_collectable_id = data.get('maxRewardId') + should_collect = False for reward in data.get("rewards", {}).get("normal", {}): status = reward.get("status", "") if status == "rewarded": continue elif status == "completed": - self._post_main_weekly_challenge_reward(reward.get("id", 0)) + should_collect = True elif reward.get("icon", "") == "energy_booster": pps = re.search(r"Reach (\d+) Prestige Points to unlock the following reward: \+1 Energy", reward.get("tooltip", "")) if pps: self.details.next_pp.append(int(pps.group(1))) + if should_collect: + self._post_main_weekly_challenge_collect_all(max_collectable_id) def should_fight(self, silent: bool = True) -> Tuple[int, str, bool]: count, log_msg, force_fight = super().should_fight() diff --git a/erepublik/classes.py b/erepublik/classes.py index f865091..1cd6fe4 100644 --- a/erepublik/classes.py +++ b/erepublik/classes.py @@ -7,7 +7,7 @@ from typing import Any, Dict, Generator, Iterable, List, NamedTuple, NoReturn, T from requests import Response, Session, post -from . import constants, utils, types +from . import constants, types, utils __all__ = ['Battle', 'BattleDivision', 'BattleSide', 'Company', 'Config', 'Details', 'Energy', 'ErepublikException', 'ErepublikNetworkException', 'EnergyToFight', diff --git a/erepublik/types.py b/erepublik/types.py index b27f95f..96253ac 100644 --- a/erepublik/types.py +++ b/erepublik/types.py @@ -1,5 +1,5 @@ from datetime import datetime -from typing import Dict, Union, List +from typing import Dict, List, Union InvFinalItem = Dict[str, Union[str, int, List[Dict[str, Union[int, datetime]]]]] InvBooster = Dict[str, Dict[int, Dict[int, InvFinalItem]]] diff --git a/requirements_dev.txt b/requirements_dev.txt index e358e41..07ea9d0 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -5,14 +5,15 @@ flake8==3.8.4 ipython>=7.19.0 isort==5.7.0 pip==20.3.3 +pre-commit==2.9.3 +pur==5.3.0 PyInstaller==4.1 -pytz>=2020.0 +PySocks==1.7.1 pytest==6.2.1 +pytz>=2020.5 +requests>=2.25.1 responses==0.12.1 setuptools==51.1.1 Sphinx==3.4.2 -requests>=2.24.0,<2.26.0 -PySocks==1.7.1 twine==3.3.0 wheel==0.36.2 -pur==5.3.0 diff --git a/setup.cfg b/setup.cfg index a67355e..8eaf289 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,4 +37,3 @@ warn_unused_configs = True [isort] multi_line_output = 2 line_length = 120 -not_skip = __init__.py