Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
a031da0ee7 | |||
bdb13fa4ae | |||
e1e3b33d46 | |||
e09ca143b1 | |||
61d0599295 | |||
1ef600492a | |||
377eda6445 |
@ -2,6 +2,13 @@
|
|||||||
History
|
History
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
0.22.1 (2020-11-4)
|
||||||
|
-------------------
|
||||||
|
* Requirement update
|
||||||
|
* Unified product naming in inventory and other places based on `erepublik.constants.INDUSTRIES` values
|
||||||
|
* `erepublik.Citizen` parameter `auto_login` now defaults to `False`
|
||||||
|
* Continued work on more verbose action and result logging
|
||||||
|
|
||||||
0.22.0 (2020-10-22)
|
0.22.0 (2020-10-22)
|
||||||
-------------------
|
-------------------
|
||||||
* Ability to dump session and restore from file
|
* Ability to dump session and restore from file
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
__author__ = """Eriks Karls"""
|
__author__ = """Eriks Karls"""
|
||||||
__email__ = 'eriks@72.lv'
|
__email__ = 'eriks@72.lv'
|
||||||
__version__ = '0.22.1.3'
|
__version__ = '0.22.1.5'
|
||||||
|
|
||||||
from erepublik import classes, utils, constants
|
from erepublik import classes, utils, constants
|
||||||
from erepublik.citizen import Citizen
|
from erepublik.citizen import Citizen
|
||||||
|
@ -348,7 +348,7 @@ class BaseCitizen(access_points.CitizenAPI):
|
|||||||
_item_data = dict(kind=kind, quality=item_data.get('quality', 0), amount=item_data.get('amount', 0),
|
_item_data = dict(kind=kind, quality=item_data.get('quality', 0), amount=item_data.get('amount', 0),
|
||||||
durability=item_data.get('duration', 0), icon=icon, name=name)
|
durability=item_data.get('duration', 0), icon=icon, name=name)
|
||||||
if item_data.get('type') in ('damageBoosters', "aircraftDamageBoosters"):
|
if item_data.get('type') in ('damageBoosters', "aircraftDamageBoosters"):
|
||||||
_item_data = {_item_data['durability']: item_data}
|
_item_data = {_item_data['durability']: _item_data}
|
||||||
else:
|
else:
|
||||||
if item_data.get('type') == 'bomb':
|
if item_data.get('type') == 'bomb':
|
||||||
firepower = 0
|
firepower = 0
|
||||||
@ -983,7 +983,7 @@ class CitizenEconomy(CitizenTravel):
|
|||||||
def check_house_durability(self) -> Dict[int, datetime]:
|
def check_house_durability(self) -> Dict[int, datetime]:
|
||||||
ret = {}
|
ret = {}
|
||||||
inv = self.get_inventory()
|
inv = self.get_inventory()
|
||||||
for house_quality, active_house in inv['active'].get('house', {}).items():
|
for house_quality, active_house in inv['active'].get('House', {}).items():
|
||||||
till = utils.good_timedelta(self.now, timedelta(seconds=active_house['time_left']))
|
till = utils.good_timedelta(self.now, timedelta(seconds=active_house['time_left']))
|
||||||
ret.update({house_quality: till})
|
ret.update({house_quality: till})
|
||||||
return ret
|
return ret
|
||||||
@ -996,10 +996,10 @@ class CitizenEconomy(CitizenTravel):
|
|||||||
countries = [self.details.citizenship, ]
|
countries = [self.details.citizenship, ]
|
||||||
if self.details.current_country != self.details.citizenship:
|
if self.details.current_country != self.details.citizenship:
|
||||||
countries.append(self.details.current_country)
|
countries.append(self.details.current_country)
|
||||||
offers = [self.get_market_offers("house", q, country)[f"q{q}"] for country in countries]
|
offers = [self.get_market_offers("House", q, country)[f"q{q}"] for country in countries]
|
||||||
local_cheapest = sorted(offers, key=lambda o: o.price)[0]
|
local_cheapest = sorted(offers, key=lambda o: o.price)[0]
|
||||||
|
|
||||||
global_cheapest = self.get_market_offers("house", q)[f"q{q}"]
|
global_cheapest = self.get_market_offers("House", q)[f"q{q}"]
|
||||||
if global_cheapest.price + 200 < local_cheapest.price:
|
if global_cheapest.price + 200 < local_cheapest.price:
|
||||||
if self.travel_to_country(global_cheapest.country):
|
if self.travel_to_country(global_cheapest.country):
|
||||||
buy = self.buy_from_market(global_cheapest.offer_id, 1)
|
buy = self.buy_from_market(global_cheapest.offer_id, 1)
|
||||||
@ -1036,7 +1036,7 @@ class CitizenEconomy(CitizenTravel):
|
|||||||
r: Dict[str, Any] = self._post_economy_activate_house(quality).json()
|
r: Dict[str, Any] = self._post_economy_activate_house(quality).json()
|
||||||
self._update_inventory_data(r)
|
self._update_inventory_data(r)
|
||||||
if r.get("status") and not r.get("error"):
|
if r.get("status") and not r.get("error"):
|
||||||
house: Dict[str, Union[int, str]] = self.get_inventory()['active']['house'][quality]
|
house: Dict[str, Union[int, str]] = self.get_inventory()['active']['House'][quality]
|
||||||
time_left = timedelta(seconds=house["time_left"])
|
time_left = timedelta(seconds=house["time_left"])
|
||||||
active_until = utils.good_timedelta(self.now, time_left)
|
active_until = utils.good_timedelta(self.now, time_left)
|
||||||
self._report_action(
|
self._report_action(
|
||||||
@ -1140,13 +1140,11 @@ class CitizenEconomy(CitizenTravel):
|
|||||||
def buy_from_market(self, offer: int, amount: int) -> dict:
|
def buy_from_market(self, offer: int, amount: int) -> dict:
|
||||||
ret = self._post_economy_marketplace_actions('buy', offer=offer, amount=amount)
|
ret = self._post_economy_marketplace_actions('buy', offer=offer, amount=amount)
|
||||||
json_ret = ret.json()
|
json_ret = ret.json()
|
||||||
if json_ret.get('error'):
|
if not json_ret.get('error', True):
|
||||||
return json_ret
|
|
||||||
else:
|
|
||||||
self.details.cc = ret.json()['currency']
|
self.details.cc = ret.json()['currency']
|
||||||
self.details.gold = ret.json()['gold']
|
self.details.gold = ret.json()['gold']
|
||||||
json_ret.pop("offerUpdate", None)
|
json_ret.pop("offerUpdate", None)
|
||||||
self._report_action("BOUGHT_PRODUCTS", "", kwargs=json_ret)
|
self._report_action("BOUGHT_PRODUCTS", json_ret.get('message'), kwargs=json_ret)
|
||||||
return json_ret
|
return json_ret
|
||||||
|
|
||||||
def get_market_offers(
|
def get_market_offers(
|
||||||
@ -1167,7 +1165,7 @@ class CitizenEconomy(CitizenTravel):
|
|||||||
if quality:
|
if quality:
|
||||||
offers[f"q{quality}"] = classes.OfferItem()
|
offers[f"q{quality}"] = classes.OfferItem()
|
||||||
else:
|
else:
|
||||||
max_quality = 1 if product_name in q1_industries else 5 if product_name == 'house' else 7
|
max_quality = 1 if product_name in q1_industries else 5 if product_name.lower() == 'house' else 7
|
||||||
for q in range(max_quality):
|
for q in range(max_quality):
|
||||||
offers[f"q{q + 1}"] = classes.OfferItem()
|
offers[f"q{q + 1}"] = classes.OfferItem()
|
||||||
|
|
||||||
@ -2571,6 +2569,10 @@ class Citizen(CitizenAnniversary, CitizenCompanies, CitizenEconomy, CitizenLeade
|
|||||||
raw_kind = raw_kind.group(1)
|
raw_kind = raw_kind.group(1)
|
||||||
result = response.get("result", {})
|
result = response.get("result", {})
|
||||||
amount_needed = round(result.get("consume", 0) - result.get("stock", 0) + 0.49)
|
amount_needed = round(result.get("consume", 0) - result.get("stock", 0) + 0.49)
|
||||||
|
self._report_action(
|
||||||
|
'WORK_AS_MANAGER', f"Unable to wam! Missing {amount_needed} {raw_kind}, will try to buy.",
|
||||||
|
kwargs=response
|
||||||
|
)
|
||||||
start_place = (self.details.current_country, self.details.current_region)
|
start_place = (self.details.current_country, self.details.current_region)
|
||||||
while amount_needed > 0:
|
while amount_needed > 0:
|
||||||
amount = amount_needed
|
amount = amount_needed
|
||||||
@ -2579,17 +2581,25 @@ 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")
|
||||||
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
|
||||||
else:
|
else:
|
||||||
self.write_log(rj.get('message', ""))
|
self.write_log(rj.get('message', ""))
|
||||||
|
self._report_action(
|
||||||
|
"ECONOMY_BUY", f"Unable to buy products! Reason: {rj.get('message')}", kwargs=rj
|
||||||
|
)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
if not start_place == (self.details.current_country, self.details.current_region):
|
if not start_place == (self.details.current_country, self.details.current_region):
|
||||||
self.travel_to_holding(holding)
|
self.travel_to_holding(holding)
|
||||||
self._wam(holding)
|
self._wam(holding)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if not start_place == (self.details.current_country, self.details.current_region):
|
||||||
|
self.travel_to_residence()
|
||||||
|
return
|
||||||
elif response.get("message") == "not_enough_health_food":
|
elif response.get("message") == "not_enough_health_food":
|
||||||
self.buy_food()
|
self.buy_food()
|
||||||
self._wam(holding)
|
self._wam(holding)
|
||||||
|
@ -2,15 +2,15 @@ bump2version==1.0.1
|
|||||||
coverage==5.3
|
coverage==5.3
|
||||||
edx-sphinx-theme==1.5.0
|
edx-sphinx-theme==1.5.0
|
||||||
flake8==3.8.4
|
flake8==3.8.4
|
||||||
ipython>=7.18.1
|
ipython>=7.19.0
|
||||||
isort==5.6.4
|
isort==5.6.4
|
||||||
pip==20.2.4
|
pip==20.2.4
|
||||||
PyInstaller==4.0
|
PyInstaller==4.0
|
||||||
pytz==2020.1
|
pytz==2020.4
|
||||||
pytest==6.1.1
|
pytest==6.1.2
|
||||||
responses==0.12.0
|
responses==0.12.0
|
||||||
setuptools==50.3.2
|
setuptools==50.3.2
|
||||||
Sphinx==3.2.1
|
Sphinx==3.3.0
|
||||||
requests==2.24.0
|
requests==2.24.0
|
||||||
PySocks==1.7.1
|
PySocks==1.7.1
|
||||||
tox==3.20.1
|
tox==3.20.1
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 0.22.1.3
|
current_version = 0.22.1.5
|
||||||
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+)?
|
||||||
|
4
setup.py
4
setup.py
@ -12,7 +12,7 @@ with open('HISTORY.rst') as history_file:
|
|||||||
history = history_file.read()
|
history = history_file.read()
|
||||||
|
|
||||||
requirements = [
|
requirements = [
|
||||||
'pytz==2020.1',
|
'pytz==2020.4',
|
||||||
'requests==2.24.0',
|
'requests==2.24.0',
|
||||||
'PySocks==1.7.1'
|
'PySocks==1.7.1'
|
||||||
]
|
]
|
||||||
@ -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.22.1.3',
|
version='0.22.1.5',
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user