|
|
|
@ -1152,11 +1152,13 @@ class CitizenEconomy(CitizenTravel):
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
def post_market_offer(self, industry: int, quality: int, amount: int, price: float) -> bool:
|
|
|
|
|
if isinstance(industry, str):
|
|
|
|
|
industry = constants.INDUSTRIES[industry]
|
|
|
|
|
if not constants.INDUSTRIES[industry]:
|
|
|
|
|
self.write_log(f"Trying to sell unsupported industry {industry}")
|
|
|
|
|
|
|
|
|
|
_inv_qlt = quality if industry in [1, 2, 3, 4, 23] else 0
|
|
|
|
|
_kind = 'final' if industry in [1, 2, 4, 4, 23] else 'raw'
|
|
|
|
|
_kind = 'final' if industry in [1, 2, 4, 23] else 'raw'
|
|
|
|
|
inventory = self.get_inventory()
|
|
|
|
|
items = inventory[_kind].get(constants.INDUSTRIES[industry], {_inv_qlt: {'amount': 0}})
|
|
|
|
|
if items[_inv_qlt]['amount'] < amount:
|
|
|
|
@ -1181,7 +1183,7 @@ class CitizenEconomy(CitizenTravel):
|
|
|
|
|
self._report_action("ECONOMY_SELL_PRODUCTS", message, kwargs=ret)
|
|
|
|
|
return not bool(ret.get('error', True))
|
|
|
|
|
|
|
|
|
|
def buy_from_market(self, offer: int, amount: int) -> dict:
|
|
|
|
|
def buy_from_market(self, offer: int, amount: int) -> Dict[str, Any]:
|
|
|
|
|
ret = self._post_economy_marketplace_actions('buy', offer=offer, amount=amount)
|
|
|
|
|
json_ret = ret.json()
|
|
|
|
|
if not json_ret.get('error', True):
|
|
|
|
@ -1199,13 +1201,7 @@ class CitizenEconomy(CitizenTravel):
|
|
|
|
|
if not self.details.current_country == offer.country:
|
|
|
|
|
traveled = True
|
|
|
|
|
self.travel_to_country(offer.country)
|
|
|
|
|
ret = self._post_economy_marketplace_actions('buy', offer=offer.offer_id, amount=amount)
|
|
|
|
|
json_ret = ret.json()
|
|
|
|
|
if not json_ret.get('error', True):
|
|
|
|
|
self.details.cc = ret.json()['currency']
|
|
|
|
|
self.details.gold = ret.json()['gold']
|
|
|
|
|
json_ret.pop("offerUpdate", None)
|
|
|
|
|
self._report_action("BOUGHT_PRODUCTS", json_ret.get('message'), kwargs=json_ret)
|
|
|
|
|
json_ret = self.buy_from_market(offer.offer_id, amount)
|
|
|
|
|
if traveled:
|
|
|
|
|
self.travel_to_residence()
|
|
|
|
|
return json_ret
|
|
|
|
@ -2442,10 +2438,8 @@ class Citizen(CitizenAnniversary, CitizenCompanies, CitizenEconomy, CitizenLeade
|
|
|
|
|
self.update_citizen_info()
|
|
|
|
|
self.reporter.do_init()
|
|
|
|
|
if self.config.telegram:
|
|
|
|
|
# noinspection SpellCheckingInspection
|
|
|
|
|
self.telegram.do_init(self.config.telegram_chat_id or 620981703,
|
|
|
|
|
self.config.telegram_token or "864251270:AAFzZZdjspI-kIgJVk4gF3TViGFoHnf8H4o",
|
|
|
|
|
"" if self.config.telegram_chat_id or self.config.telegram_token else self.name)
|
|
|
|
|
if self.config.telegram_chat_id and self.config.telegram_token:
|
|
|
|
|
self.telegram.do_init(self.config.telegram_chat_id, self.config.telegram_token, self.name)
|
|
|
|
|
self.telegram.send_message(f"*Started* {utils.now():%F %T}")
|
|
|
|
|
|
|
|
|
|
self.update_all(True)
|
|
|
|
@ -2466,7 +2460,6 @@ class Citizen(CitizenAnniversary, CitizenCompanies, CitizenEconomy, CitizenLeade
|
|
|
|
|
if self.details.gold >= 54:
|
|
|
|
|
self.buy_tg_contract()
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
|
|
self.write_log(f"Training ground contract active but "
|
|
|
|
|
f"don't have enough gold ({self.details.gold}g {self.details.cc}cc)")
|
|
|
|
|
if self.energy.is_energy_full and self.config.telegram:
|
|
|
|
|