Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
08937d06e4 | |||
cec4510831 | |||
cfb9501647 | |||
d419211955 | |||
0ea144db17 | |||
1418f580cd | |||
49575bddf5 |
10
HISTORY.rst
10
HISTORY.rst
@ -2,6 +2,16 @@
|
|||||||
History
|
History
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
0.23.0 (2020-11-26)
|
||||||
|
-------------------
|
||||||
|
* Added `Config.maverick` switch, to allow/deny automated fighting in non native divisions if the player has MaverickPack
|
||||||
|
* Added `CitizenMedia.get_article(article_id:int)` method to get article data
|
||||||
|
* Added `CitizenMedia.delete_article(article_id:int)` method to delete article
|
||||||
|
* Fixed `CitizenTravel.travel_to_region(region_id:int)` method
|
||||||
|
* Added `CitizenAnniversary.collect_map_quest_node(node_id:int, extra:bool=False)` to collect also extra rewards
|
||||||
|
* Fixed `CitizenTasks.work()` when employer out of money - resign and find a new job
|
||||||
|
* Fixed `CitizenEconomy.post_market_offer()`
|
||||||
|
|
||||||
0.22.3 (2020-11-16)
|
0.22.3 (2020-11-16)
|
||||||
-------------------
|
-------------------
|
||||||
* Fixed round to even bug when doing wam and not enough raw.
|
* Fixed round to even bug when doing wam and not enough raw.
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
__author__ = """Eriks Karls"""
|
__author__ = """Eriks Karls"""
|
||||||
__email__ = 'eriks@72.lv'
|
__email__ = 'eriks@72.lv'
|
||||||
__version__ = '0.23.0'
|
__version__ = '0.23.1'
|
||||||
|
|
||||||
from erepublik import classes, utils, constants
|
from erepublik import classes, utils, constants
|
||||||
from erepublik.citizen import Citizen
|
from erepublik.citizen import Citizen
|
||||||
|
@ -388,6 +388,9 @@ class ErepublikLocationAPI(CitizenBaseAPI):
|
|||||||
|
|
||||||
|
|
||||||
class ErepublikMilitaryAPI(CitizenBaseAPI):
|
class ErepublikMilitaryAPI(CitizenBaseAPI):
|
||||||
|
def _get_military_battle_stats(self, battle_id: int, division: int, division_id: int):
|
||||||
|
return self.get(f"{self.url}/military/battle-stats/{battle_id}/{division}/{division_id}")
|
||||||
|
|
||||||
def _get_military_battlefield_choose_side(self, battle_id: int, side_id: int) -> Response:
|
def _get_military_battlefield_choose_side(self, battle_id: int, side_id: int) -> Response:
|
||||||
return self.get(f"{self.url}/military/battlefield-choose-side/{battle_id}/{side_id}")
|
return self.get(f"{self.url}/military/battlefield-choose-side/{battle_id}/{side_id}")
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ class BaseCitizen(access_points.CitizenAPI):
|
|||||||
maverick: bool = False
|
maverick: bool = False
|
||||||
|
|
||||||
eday: int = 0
|
eday: int = 0
|
||||||
|
wheel_of_fortune: bool
|
||||||
|
|
||||||
config: classes.Config = None
|
config: classes.Config = None
|
||||||
energy: classes.Energy = None
|
energy: classes.Energy = None
|
||||||
@ -62,6 +63,7 @@ class BaseCitizen(access_points.CitizenAPI):
|
|||||||
self.config.password = password
|
self.config.password = password
|
||||||
self.inventory = {}
|
self.inventory = {}
|
||||||
self.inventory_status = dict(used=0, total=0)
|
self.inventory_status = dict(used=0, total=0)
|
||||||
|
self.wheel_of_fortune = False
|
||||||
|
|
||||||
def get_csrf_token(self):
|
def get_csrf_token(self):
|
||||||
"""
|
"""
|
||||||
@ -230,6 +232,9 @@ class BaseCitizen(access_points.CitizenAPI):
|
|||||||
self.politics.is_party_president = bool(party.get('is_party_president'))
|
self.politics.is_party_president = bool(party.get('is_party_president'))
|
||||||
self.politics.party_slug = f"{party.get('stripped_title')}-{party.get('party_id')}"
|
self.politics.party_slug = f"{party.get('stripped_title')}-{party.get('party_id')}"
|
||||||
|
|
||||||
|
self.wheel_of_fortune = bool(
|
||||||
|
re.search(r'<a id="launch_wof" class="powerspin_sidebar( show_free)?" href="javascript:">', html))
|
||||||
|
|
||||||
def update_inventory(self):
|
def update_inventory(self):
|
||||||
"""
|
"""
|
||||||
Updates class properties and returns structured inventory.
|
Updates class properties and returns structured inventory.
|
||||||
@ -739,23 +744,33 @@ class CitizenAnniversary(BaseCitizen):
|
|||||||
return self._post_map_rewards_speedup(node_id, node.get("skipCost", 0))
|
return self._post_map_rewards_speedup(node_id, node.get("skipCost", 0))
|
||||||
|
|
||||||
def spin_wheel_of_fortune(self, max_cost=0, spin_count=0):
|
def spin_wheel_of_fortune(self, max_cost=0, spin_count=0):
|
||||||
def _write_spin_data(cost, cc, prize):
|
if not self.config.spin_wheel_of_fortune:
|
||||||
self._report_action("WHEEL_SPIN", f"Cost: {cost:4d} | Currency left: {cc:,} | Prize: {prize}")
|
self.write_log("Unable to spin wheel of fortune because 'config.spin_wheel_of_fortune' is False")
|
||||||
|
return
|
||||||
|
|
||||||
|
def _write_spin_data(cost: int, prize: str):
|
||||||
|
self._report_action("WHEEL_SPIN", f"Cost: {cost:4d} | Currency left: {self.details.cc:,} | Prize: {prize}")
|
||||||
|
|
||||||
|
if not self.wheel_of_fortune:
|
||||||
|
self.update_citizen_info()
|
||||||
base = self._post_main_wheel_of_fortune_build().json()
|
base = self._post_main_wheel_of_fortune_build().json()
|
||||||
current_cost = 0 if base.get('progress').get('free_spin') else base.get('cost')
|
current_cost = 0 if base.get('progress').get('free_spin') else base.get('cost')
|
||||||
current_count = base.get('progress').get('spins')
|
current_count = base.get('progress').get('spins')
|
||||||
|
prizes = base.get('prizes')
|
||||||
if not max_cost and not spin_count:
|
if not max_cost and not spin_count:
|
||||||
r = self._post_main_wheel_of_fortune_spin(current_cost).json()
|
r = self._post_main_wheel_of_fortune_spin(current_cost).json()
|
||||||
_write_spin_data(current_cost, r.get('account'),
|
_write_spin_data(current_cost, prizes.get('prizes').get(str(r.get('result'))).get('tooltip'))
|
||||||
base.get('prizes').get('prizes').get(str(r.get('result'))).get('tooltip'))
|
|
||||||
else:
|
else:
|
||||||
while max_cost >= current_cost if max_cost else spin_count >= current_count if spin_count else False:
|
while max_cost >= current_cost if max_cost else spin_count >= current_count if spin_count else False:
|
||||||
r = self._spin_wheel_of_loosing(current_cost)
|
r = self._spin_wheel_of_loosing(current_cost)
|
||||||
current_count += 1
|
current_count += 1
|
||||||
|
prize_name = prizes.get('prizes').get(str(r.get('result'))).get('tooltip')
|
||||||
|
if r.get('result') == 7:
|
||||||
|
prize_name += f" - {prizes.get('jackpot').get(str(r.get('jackpot'))).get('tooltip')}"
|
||||||
|
_write_spin_data(current_cost, prize_name)
|
||||||
current_cost = r.get('cost')
|
current_cost = r.get('cost')
|
||||||
_write_spin_data(current_cost, r.get('account'),
|
if r.get('jackpot', 0) == 3:
|
||||||
base.get('prizes').get('prizes').get(str(r.get('result'))).get('tooltip'))
|
return
|
||||||
|
|
||||||
def _spin_wheel_of_loosing(self, current_cost: int) -> Dict[str, Any]:
|
def _spin_wheel_of_loosing(self, current_cost: int) -> Dict[str, Any]:
|
||||||
r = self._post_main_wheel_of_fortune_spin(current_cost).json()
|
r = self._post_main_wheel_of_fortune_spin(current_cost).json()
|
||||||
@ -2018,6 +2033,21 @@ class CitizenMilitary(CitizenTravel):
|
|||||||
return (r_json.get(str(battle.invader.id)).get("fighterData"),
|
return (r_json.get(str(battle.invader.id)).get("fighterData"),
|
||||||
r_json.get(str(battle.defender.id)).get("fighterData"))
|
r_json.get(str(battle.defender.id)).get("fighterData"))
|
||||||
|
|
||||||
|
def get_battle_division_stats(self, division: classes.BattleDivision) -> Dict[str, Any]:
|
||||||
|
battle = division.battle
|
||||||
|
r = self._get_military_battle_stats(battle.id, division.div, division.id)
|
||||||
|
return r.json()
|
||||||
|
|
||||||
|
def get_division_max_hit(self, division: classes.BattleDivision) -> int:
|
||||||
|
""" Returns max hit in division for current side (if not on either side returns 0)
|
||||||
|
|
||||||
|
:param division: BattleDivision for which to get max hit value
|
||||||
|
:type division: classes.BattleDivision
|
||||||
|
:return: max hit value
|
||||||
|
:rtype: int
|
||||||
|
"""
|
||||||
|
return self.get_battle_division_stats(division).get('maxHit', -1)
|
||||||
|
|
||||||
def schedule_attack(self, war_id: int, region_id: int, region_name: str, at_time: datetime):
|
def schedule_attack(self, war_id: int, region_id: int, region_name: str, at_time: datetime):
|
||||||
if at_time:
|
if at_time:
|
||||||
self.sleep(utils.get_sleep_seconds(at_time))
|
self.sleep(utils.get_sleep_seconds(at_time))
|
||||||
@ -2626,7 +2656,8 @@ class Citizen(CitizenAnniversary, CitizenCompanies, CitizenEconomy, CitizenLeade
|
|||||||
|
|
||||||
if not best_offer.country == self.details.current_country:
|
if not best_offer.country == self.details.current_country:
|
||||||
self.travel_to_country(best_offer.country)
|
self.travel_to_country(best_offer.country)
|
||||||
self._report_action("ECONOMY_BUY", f"Attempting to buy {amount} {raw_kind} for {best_offer.price*amount}cc")
|
self._report_action("ECONOMY_BUY",
|
||||||
|
f"Attempting to buy {amount} {raw_kind} for {best_offer.price * amount}cc")
|
||||||
rj = self.buy_from_market(amount=amount, offer=best_offer.offer_id)
|
rj = self.buy_from_market(amount=amount, offer=best_offer.offer_id)
|
||||||
if not rj.get('error'):
|
if not rj.get('error'):
|
||||||
amount_needed -= amount
|
amount_needed -= amount
|
||||||
|
@ -358,6 +358,7 @@ class Config:
|
|||||||
telegram_chat_id = 0
|
telegram_chat_id = 0
|
||||||
telegram_token = ""
|
telegram_token = ""
|
||||||
maverick = False
|
maverick = False
|
||||||
|
spin_wheel_of_fortune = False
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.auto_sell = []
|
self.auto_sell = []
|
||||||
@ -391,6 +392,7 @@ class Config:
|
|||||||
self.telegram_chat_id = 0
|
self.telegram_chat_id = 0
|
||||||
self.telegram_token = ""
|
self.telegram_token = ""
|
||||||
self.maverick = False
|
self.maverick = False
|
||||||
|
self.spin_wheel_of_fortune = False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def as_dict(self):
|
def as_dict(self):
|
||||||
@ -402,7 +404,8 @@ class Config:
|
|||||||
rw_def_side=self.rw_def_side, interactive=self.interactive, maverick=self.maverick,
|
rw_def_side=self.rw_def_side, interactive=self.interactive, maverick=self.maverick,
|
||||||
continuous_fighting=self.continuous_fighting, auto_buy_raw=self.auto_buy_raw,
|
continuous_fighting=self.continuous_fighting, auto_buy_raw=self.auto_buy_raw,
|
||||||
force_wam=self.force_wam, sort_battles_time=self.sort_battles_time, force_travel=self.force_travel,
|
force_wam=self.force_wam, sort_battles_time=self.sort_battles_time, force_travel=self.force_travel,
|
||||||
telegram=self.telegram, telegram_chat_id=self.telegram_chat_id, telegram_token=self.telegram_token)
|
telegram=self.telegram, telegram_chat_id=self.telegram_chat_id, telegram_token=self.telegram_token,
|
||||||
|
spin_wheel_of_fortune=self.spin_wheel_of_fortune)
|
||||||
|
|
||||||
|
|
||||||
class Energy:
|
class Energy:
|
||||||
|
@ -4,16 +4,16 @@ edx-sphinx-theme==1.5.0
|
|||||||
flake8==3.8.4
|
flake8==3.8.4
|
||||||
ipython>=7.19.0
|
ipython>=7.19.0
|
||||||
isort==5.6.4
|
isort==5.6.4
|
||||||
pip==20.2.4
|
pip==20.3
|
||||||
PyInstaller==4.0
|
PyInstaller==4.1
|
||||||
pytz==2020.4
|
pytz==2020.4
|
||||||
pytest==6.1.2
|
pytest==6.1.2
|
||||||
responses==0.12.0
|
responses==0.12.1
|
||||||
setuptools==50.3.2
|
setuptools==50.3.2
|
||||||
Sphinx==3.3.0
|
Sphinx==3.3.1
|
||||||
requests==2.24.0
|
requests==2.25.0
|
||||||
PySocks==1.7.1
|
PySocks==1.7.1
|
||||||
tox==3.20.1
|
tox==3.20.1
|
||||||
twine==3.2.0
|
twine==3.2.0
|
||||||
watchdog==0.10.3
|
watchdog==0.10.4
|
||||||
wheel==0.35.1
|
wheel==0.35.1
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 0.23.0
|
current_version = 0.23.1
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)\.?(?P<dev>\d+)?
|
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)\.?(?P<dev>\d+)?
|
||||||
|
6
setup.py
6
setup.py
@ -13,7 +13,7 @@ with open('HISTORY.rst') as history_file:
|
|||||||
|
|
||||||
requirements = [
|
requirements = [
|
||||||
'pytz==2020.4',
|
'pytz==2020.4',
|
||||||
'requests==2.24.0',
|
'requests==2.25.0',
|
||||||
'PySocks==1.7.1'
|
'PySocks==1.7.1'
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ setup_requirements = []
|
|||||||
|
|
||||||
test_requirements = [
|
test_requirements = [
|
||||||
"pytest==6.1.2",
|
"pytest==6.1.2",
|
||||||
"responses==0.12.0"
|
"responses==0.12.1"
|
||||||
]
|
]
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
@ -50,6 +50,6 @@ setup(
|
|||||||
test_suite='tests',
|
test_suite='tests',
|
||||||
tests_require=test_requirements,
|
tests_require=test_requirements,
|
||||||
url='https://github.com/eeriks/erepublik/',
|
url='https://github.com/eeriks/erepublik/',
|
||||||
version='0.23.0',
|
version='0.23.1',
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user