Compare commits
8 Commits
v0.23.2.11
...
v0.23.3.2
Author | SHA1 | Date | |
---|---|---|---|
c458eb4b1c | |||
4af4d284c9 | |||
104c1a0b16 | |||
86f820771b | |||
2a7af0cb7d | |||
94de509026 | |||
82d913bc47 | |||
c462eac369 |
@ -4,7 +4,7 @@
|
||||
|
||||
__author__ = """Eriks Karls"""
|
||||
__email__ = 'eriks@72.lv'
|
||||
__version__ = '0.23.2.11'
|
||||
__version__ = '0.23.3.2'
|
||||
|
||||
from erepublik import classes, utils, constants
|
||||
from erepublik.citizen import Citizen
|
||||
|
@ -15,10 +15,10 @@ class SlowRequests(Session):
|
||||
timeout: datetime.timedelta = datetime.timedelta(milliseconds=500)
|
||||
uas: List[str] = [
|
||||
# Chrome
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36', # noqa
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36', # noqa
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36', # noqa
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36', # noqa
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36',
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36',
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36',
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36',
|
||||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36',
|
||||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36',
|
||||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36',
|
||||
@ -285,7 +285,6 @@ class ErepublikCountryAPI(CitizenBaseAPI):
|
||||
|
||||
def _post_main_country_donate(self, country_id: int, action: str, value: Union[int, float],
|
||||
quality: int = None) -> Response:
|
||||
|
||||
data = dict(countryId=country_id, action=action, _token=self.token, value=value, quality=quality)
|
||||
return self.post(f"{self.url}/main/country-donate", data=data,
|
||||
headers={"Referer": f"{self.url}/country/economy/Latvia"})
|
||||
@ -360,16 +359,20 @@ class ErepublikEconomyAPI(CitizenBaseAPI):
|
||||
|
||||
|
||||
class ErepublikLeaderBoardAPI(CitizenBaseAPI):
|
||||
def _get_main_leaderboards_damage_aircraft_rankings(self, country_id: int, weeks: int = 0, mu_id: int = 0) -> Response: # noqa
|
||||
def _get_main_leaderboards_damage_aircraft_rankings(self, country_id: int, weeks: int = 0,
|
||||
mu_id: int = 0) -> Response: # noqa
|
||||
return self.get(f"{self.url}/main/leaderboards-damage-aircraft-rankings/{country_id}/{weeks}/{mu_id}/0")
|
||||
|
||||
def _get_main_leaderboards_damage_rankings(self, country_id: int, weeks: int = 0, mu_id: int = 0, div: int = 0) -> Response: # noqa
|
||||
def _get_main_leaderboards_damage_rankings(self, country_id: int, weeks: int = 0, mu_id: int = 0,
|
||||
div: int = 0) -> Response: # noqa
|
||||
return self.get(f"{self.url}/main/leaderboards-damage-rankings/{country_id}/{weeks}/{mu_id}/{div}")
|
||||
|
||||
def _get_main_leaderboards_kills_aircraft_rankings(self, country_id: int, weeks: int = 0, mu_id: int = 0) -> Response: # noqa
|
||||
def _get_main_leaderboards_kills_aircraft_rankings(self, country_id: int, weeks: int = 0,
|
||||
mu_id: int = 0) -> Response: # noqa
|
||||
return self.get(f"{self.url}/main/leaderboards-kills-aircraft-rankings/{country_id}/{weeks}/{mu_id}/0")
|
||||
|
||||
def _get_main_leaderboards_kills_rankings(self, country_id: int, weeks: int = 0, mu_id: int = 0, div: int = 0) -> Response: # noqa
|
||||
def _get_main_leaderboards_kills_rankings(self, country_id: int, weeks: int = 0, mu_id: int = 0,
|
||||
div: int = 0) -> Response: # noqa
|
||||
return self.get(f"{self.url}/main/leaderboards-kills-rankings/{country_id}/{weeks}/{mu_id}/{div}")
|
||||
|
||||
|
||||
@ -435,8 +438,9 @@ class ErepublikMilitaryAPI(CitizenBaseAPI):
|
||||
data.update(page=page)
|
||||
return self.post(f"{self.url}/military/battle-console", data=data)
|
||||
|
||||
def _post_military_deploy_bomb(self, battle_id: int, bomb_id: int) -> Response:
|
||||
data = dict(battleId=battle_id, bombId=bomb_id, _token=self.token)
|
||||
def _post_military_deploy_bomb(self, battle_id: int, division_id: int, side_id: int, bomb_id: int) -> Response:
|
||||
data = dict(battleId=battle_id, battleZoneId=division_id, sideId=side_id, sideCountryId=side_id,
|
||||
bombId=bomb_id, _token=self.token)
|
||||
return self.post(f"{self.url}/military/deploy-bomb", data=data)
|
||||
|
||||
def _post_military_fight_air(self, battle_id: int, side_id: int, zone_id: int) -> Response:
|
||||
|
@ -1863,7 +1863,18 @@ class CitizenMilitary(CitizenTravel):
|
||||
self.travel_to_battle(battle, countries)
|
||||
err = True
|
||||
elif r_json.get("message") == "ENEMY_KILLED":
|
||||
hits = (self.energy.recovered - r_json["details"]["wellness"]) // 10
|
||||
# Non-InfantryKit players
|
||||
if r_json['user']['earnedXp']:
|
||||
hits = r_json['user']['earnedXp']
|
||||
# InfantryKit player
|
||||
# The almost always safe way (breaks on levelup hit)
|
||||
elif self.energy.recovered >= r_json["details"]["wellness"]: # Haven't reached levelup
|
||||
hits = (self.energy.recovered - r_json["details"]["wellness"]) // 10
|
||||
else:
|
||||
hits = r_json['hits']
|
||||
if r_json['user']['epicBattle']:
|
||||
hits /= 1+r_json['user']['epicBattle']
|
||||
|
||||
self.energy.recovered = r_json["details"]["wellness"]
|
||||
self.details.xp = int(r_json["details"]["points"])
|
||||
damage = r_json["user"]["givenDamage"] * (1.1 if r_json["oldEnemy"]["isNatural"] else 1)
|
||||
@ -1873,14 +1884,19 @@ class CitizenMilitary(CitizenTravel):
|
||||
return hits, err, damage
|
||||
|
||||
@utils.wait_for_lock
|
||||
def deploy_bomb(self, battle: classes.Battle, bomb_id: int, inv_side: bool = None, count: int = 1) -> Optional[int]:
|
||||
def deploy_bomb(self, battle: classes.Battle, division: classes.BattleDivision, bomb_id: int, inv_side: bool, count: int = 1) -> Optional[int]:
|
||||
"""Deploy bombs in a battle for given side.
|
||||
|
||||
:param battle: Battle
|
||||
:type battle: Battle
|
||||
:type battle: classes.Battle
|
||||
:param division: BattleDivision
|
||||
:type division: classes.BattleDivision
|
||||
:param bomb_id: int bomb id
|
||||
:param inv_side: should deploy on invader side, if None then will deploy in currently available side
|
||||
:param count: int how many bombs to deploy
|
||||
:type bomb_id: int
|
||||
:param inv_side: should deploy on invader side
|
||||
:type inv_side: bool
|
||||
:param count: how many bombs to deploy
|
||||
:type count: int
|
||||
:return: Deployed count
|
||||
:rtype: int
|
||||
"""
|
||||
@ -1895,18 +1911,15 @@ class CitizenMilitary(CitizenTravel):
|
||||
good_countries = [battle.invader.country] + battle.invader.deployed
|
||||
if self.details.current_country not in good_countries:
|
||||
has_traveled = self.travel_to_battle(battle, good_countries)
|
||||
elif inv_side is not None:
|
||||
good_countries = [battle.defender.country] + battle.defender.deployed
|
||||
if self.details.current_country not in good_countries:
|
||||
has_traveled = self.travel_to_battle(battle, good_countries)
|
||||
else:
|
||||
involved = [battle.invader.country,
|
||||
battle.defender.country] + battle.invader.deployed + battle.defender.deployed
|
||||
if self.details.current_country not in involved:
|
||||
count = 0
|
||||
side = battle.invader if inv_side else battle.defender
|
||||
errors = deployed_count = 0
|
||||
while (not deployed_count == count) and errors < 10:
|
||||
r = self._post_military_deploy_bomb(battle.id, bomb_id).json()
|
||||
r = self._post_military_deploy_bomb(battle.id, division.id, side.id, bomb_id).json()
|
||||
if not r.get('error'):
|
||||
deployed_count += 1
|
||||
elif r.get('message') == 'LOCKED':
|
||||
|
@ -10,6 +10,7 @@ from requests import Response, Session, post
|
||||
from . import utils, constants
|
||||
|
||||
__all__ = ['Battle', 'BattleDivision', 'BattleSide', 'Company', 'Config', 'Details', 'Energy', 'ErepublikException',
|
||||
'ErepublikNetworkException', 'EnergyToFight',
|
||||
'Holding', 'MyCompanies', 'MyJSONEncoder', 'OfferItem', 'Politics', 'Reporter', 'TelegramReporter']
|
||||
|
||||
|
||||
|
@ -21,10 +21,10 @@ try:
|
||||
except ImportError:
|
||||
import json
|
||||
|
||||
__all__ = ['VERSION', 'calculate_hit', 'caught_error', 'date_from_eday', 'eday_from_date',
|
||||
__all__ = ['VERSION', 'calculate_hit', 'caught_error', 'date_from_eday', 'eday_from_date', 'deprecation',
|
||||
'get_air_hit_dmg_value', 'get_file', 'get_ground_hit_dmg_value', 'get_sleep_seconds', 'good_timedelta',
|
||||
'interactive_sleep', 'json', 'localize_dt', 'localize_timestamp', 'normalize_html_json', 'now',
|
||||
'process_error', 'process_warning', 'send_email', 'silent_sleep', 'slugify', 'write_file',
|
||||
'process_error', 'process_warning', 'send_email', 'silent_sleep', 'slugify', 'write_file', 'write_request',
|
||||
'write_interactive_log', 'write_silent_log', 'get_final_hit_dmg', 'wait_for_lock']
|
||||
|
||||
if not sys.version_info >= (3, 6):
|
||||
|
@ -4,16 +4,16 @@ edx-sphinx-theme==1.5.0
|
||||
flake8==3.8.4
|
||||
ipython>=7.19.0
|
||||
isort==5.6.4
|
||||
pip==20.3
|
||||
pip==20.3.1
|
||||
PyInstaller==4.1
|
||||
pytz==2020.4
|
||||
pytest==6.1.2
|
||||
responses==0.12.1
|
||||
setuptools==50.3.2
|
||||
setuptools==51.0.0
|
||||
Sphinx==3.3.1
|
||||
requests==2.25.0
|
||||
PySocks==1.7.1
|
||||
tox==3.20.1
|
||||
twine==3.2.0
|
||||
watchdog==0.10.4
|
||||
wheel==0.35.1
|
||||
watchdog==1.0.0
|
||||
wheel==0.36.1
|
||||
|
@ -1,5 +1,5 @@
|
||||
[bumpversion]
|
||||
current_version = 0.23.2.11
|
||||
current_version = 0.23.3.2
|
||||
commit = True
|
||||
tag = True
|
||||
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)\.?(?P<dev>\d+)?
|
||||
|
4
setup.py
4
setup.py
@ -45,11 +45,11 @@ setup(
|
||||
keywords='erepublik',
|
||||
name='eRepublik',
|
||||
packages=find_packages(include=['erepublik']),
|
||||
python_requires='>=3.6, <4',
|
||||
python_requires='>=3.7, <4',
|
||||
setup_requires=setup_requirements,
|
||||
test_suite='tests',
|
||||
tests_require=test_requirements,
|
||||
url='https://github.com/eeriks/erepublik/',
|
||||
version='0.23.2.11',
|
||||
version='0.23.3.2',
|
||||
zip_safe=False,
|
||||
)
|
||||
|
Reference in New Issue
Block a user