History update, WAM actions are now more verbose
This commit is contained in:
parent
e1e3b33d46
commit
bdb13fa4ae
@ -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
|
||||||
|
@ -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(
|
||||||
@ -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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user