Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
d5ed989e80 | |||
6fc24b8adf | |||
cf797f2f60 | |||
ad29045ace | |||
c919e46af5 | |||
644b4d70e1 | |||
6dbbd054ba | |||
0ee952e504 |
6
Makefile
6
Makefile
@ -88,9 +88,3 @@ dist: clean ## builds source and wheel package
|
||||
|
||||
install: clean ## install the package to the active Python's site-packages
|
||||
python setup.py install
|
||||
|
||||
setcommit:
|
||||
bash set_commit_id.sh
|
||||
# commit=`git log -1 --pretty=format:%h`
|
||||
# sed -i.bak -E "s|COMMIT_ID = \".+\"|COMMIT_ID = \"$(commit)\"|g" erepublik/utils.py
|
||||
# mv erepublik/utils.py.bak erepublik/utils.py
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
__author__ = """Eriks Karls"""
|
||||
__email__ = 'eriks@72.lv'
|
||||
__version__ = '0.21.2'
|
||||
__version__ = '0.21.3'
|
||||
|
||||
from erepublik import classes, utils, constants
|
||||
from erepublik.citizen import Citizen
|
||||
|
@ -15,24 +15,26 @@ class SlowRequests(Session):
|
||||
timeout = datetime.timedelta(milliseconds=500)
|
||||
uas = [
|
||||
# Chrome
|
||||
'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/79.0.3945.88 Safari/537.36', # noqa
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36', # noqa
|
||||
'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',
|
||||
'Mozilla/5.0 (X11; Linux x86_64) 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/79.0.3945.88 Safari/537.36',
|
||||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36',
|
||||
|
||||
# FireFox
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0',
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0',
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:74.0) Gecko/20100101 Firefox/74.0',
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0',
|
||||
'Mozilla/5.0 (X11; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0',
|
||||
'Mozilla/5.0 (X11; Linux x86_64; rv:75.0) Gecko/20100101 Firefox/75.0',
|
||||
'Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0',
|
||||
'Mozilla/5.0 (X11; Linux x86_64; rv:73.0) Gecko/20100101 Firefox/73.0',
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:83.0) Gecko/20100101 Firefox/83.0',
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0',
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0',
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0',
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:79.0) Gecko/20100101 Firefox/79.0',
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0',
|
||||
'Mozilla/5.0 (X11; Linux x86_64; rv:83.0) Gecko/20100101 Firefox/83.0',
|
||||
'Mozilla/5.0 (X11; Linux x86_64; rv:82.0) Gecko/20100101 Firefox/82.0',
|
||||
'Mozilla/5.0 (X11; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0',
|
||||
'Mozilla/5.0 (X11; Linux x86_64; rv:80.0) Gecko/20100101 Firefox/80.0',
|
||||
'Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0',
|
||||
'Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0',
|
||||
]
|
||||
debug = False
|
||||
|
||||
@ -433,7 +435,7 @@ class ErepublikMilitaryAPI(CitizenBaseAPI):
|
||||
|
||||
class ErepublikPoliticsAPI(CitizenBaseAPI):
|
||||
def _get_candidate_party(self, party_slug: str) -> Response:
|
||||
return self.post(f"{self.url}/candidate/{party_slug}")
|
||||
return self.get(f"{self.url}/candidate/{party_slug}")
|
||||
|
||||
def _get_main_party_members(self, party_id: int) -> Response:
|
||||
return self.get(f"{self.url}/main/party-members/{party_id}")
|
||||
@ -448,6 +450,13 @@ class ErepublikPoliticsAPI(CitizenBaseAPI):
|
||||
def _get_presidential_elections(self, country_id: int, timestamp: int) -> Response:
|
||||
return self.get(f"{self.url}/main/presidential-elections/{country_id}/{timestamp}")
|
||||
|
||||
def _post_propose_president_candidate(self, party_slug: str, citizen_id: int) -> Response:
|
||||
return self.post(f"{self.url}/propose-president-candidate/{party_slug}",
|
||||
data=dict(_token=self.token, citizen=citizen_id))
|
||||
|
||||
def _get_auto_propose_president_candidate(self, party_slug: str) -> Response:
|
||||
return self.get(f"{self.url}/auto-propose-president-candidate/{party_slug}")
|
||||
|
||||
|
||||
class ErepublikPresidentAPI(CitizenBaseAPI):
|
||||
def _post_wars_attack_region(self, war_id: int, region_id: int, region_name: str) -> Response:
|
||||
|
@ -1540,8 +1540,8 @@ class CitizenMilitary(CitizenTravel):
|
||||
else:
|
||||
ground_divs.append((medal.get('1').get('raw_value'), division))
|
||||
|
||||
air_divs.sort(key=lambda dmg, div: (dmg, div.start))
|
||||
ground_divs.sort(key=lambda dmg, div: (dmg, div.start))
|
||||
air_divs.sort(key=lambda z: (z[0], z[1].battle.start))
|
||||
ground_divs.sort(key=lambda z: (z[0], z[1].battle.start))
|
||||
return {'air': air_divs, 'ground': ground_divs}
|
||||
|
||||
@property
|
||||
@ -1609,7 +1609,8 @@ class CitizenMilitary(CitizenTravel):
|
||||
self.travel_to_residence()
|
||||
break
|
||||
|
||||
def fight(self, battle: classes.Battle, division: classes.BattleDivision, side: classes.BattleSide = None, count: int = None) -> int:
|
||||
def fight(self, battle: classes.Battle, division: classes.BattleDivision, side: classes.BattleSide = None,
|
||||
count: int = None) -> int:
|
||||
"""Fight in a battle.
|
||||
|
||||
Will auto activate booster and travel if allowed to do it.
|
||||
@ -1763,7 +1764,8 @@ class CitizenMilitary(CitizenTravel):
|
||||
if resp.json().get('error'):
|
||||
self.write_log(resp.json().get('message'))
|
||||
return False
|
||||
self._report_action("MILITARY_DIV_SWITCH", f"Switched to d{division.div} in battle {battle.id}", kwargs=resp.json())
|
||||
self._report_action("MILITARY_DIV_SWITCH", f"Switched to d{division.div} in battle {battle.id}",
|
||||
kwargs=resp.json())
|
||||
return True
|
||||
|
||||
def get_ground_hit_dmg_value(self, rang: int = None, strength: float = None, elite: bool = None, ne: bool = False,
|
||||
@ -1963,6 +1965,13 @@ class CitizenMilitary(CitizenTravel):
|
||||
return member.get('panelContents', {}).get('members', [{}])[0].get('dailyOrdersCompleted')
|
||||
return 0
|
||||
|
||||
def get_possibly_empty_medals(self):
|
||||
self.update_war_info()
|
||||
for battle in self.all_battles.values():
|
||||
for division in battle.div.values():
|
||||
if division.wall['dom'] == 50 or division.wall['dom'] > 98:
|
||||
yield division, division.wall['for'] == battle.invader.country.id
|
||||
|
||||
|
||||
class CitizenPolitics(BaseCitizen):
|
||||
def get_country_parties(self, country: constants.Country = None) -> dict:
|
||||
|
@ -569,8 +569,8 @@ class Reporter:
|
||||
def __bot_update(self, data: dict) -> Response:
|
||||
if self.__to_update:
|
||||
for unreported_data in self.__to_update:
|
||||
unreported_data.update(player_id=self.citizen.id, key=self.key)
|
||||
unreported_data = utils.json.load(utils.json.dumps(unreported_data, cls=MyJSONEncoder))
|
||||
unreported_data.update(player_id=self.citizen_id, key=self.key)
|
||||
unreported_data = utils.json.loads(utils.json.dumps(unreported_data, cls=MyJSONEncoder))
|
||||
self._req.post("{}/bot/update".format(self.url), json=unreported_data)
|
||||
self.__to_update.clear()
|
||||
data = utils.json.loads(utils.json.dumps(data, cls=MyJSONEncoder))
|
||||
|
@ -1,17 +1,18 @@
|
||||
bump2version==1.0.0
|
||||
coverage==5.2
|
||||
coverage==5.2.1
|
||||
edx-sphinx-theme==1.5.0
|
||||
flake8==3.8.3
|
||||
ipython==7.16.1
|
||||
isort==5.0.9
|
||||
pip==20.1.1
|
||||
PyInstaller==3.6
|
||||
ipython==7.17.0
|
||||
isort==5.4.2
|
||||
pip==20.2.2
|
||||
PyInstaller==4.0
|
||||
pytz==2020.1
|
||||
pytest==5.4.3
|
||||
responses==0.10.15
|
||||
setuptools==49.2.0
|
||||
Sphinx==3.1.2
|
||||
tox==3.16.1
|
||||
pytest==6.0.1
|
||||
responses==0.10.16
|
||||
setuptools==49.6.0
|
||||
Sphinx==3.2.1
|
||||
requests==2.24.0
|
||||
tox==3.19.0
|
||||
twine==3.2.0
|
||||
watchdog==0.10.3
|
||||
wheel==0.34.2
|
||||
wheel==0.35.1
|
||||
|
@ -1,5 +1,5 @@
|
||||
[bumpversion]
|
||||
current_version = 0.21.2
|
||||
current_version = 0.21.3
|
||||
commit = True
|
||||
tag = True
|
||||
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)\.?(?P<dev>\d+)?
|
||||
|
Reference in New Issue
Block a user