|
|
|
@ -238,10 +238,7 @@ class BaseCitizen(access_points.CitizenAPI):
|
|
|
|
|
|
|
|
|
|
def update_inventory(self):
|
|
|
|
|
"""
|
|
|
|
|
Updates class properties and returns structured inventory.
|
|
|
|
|
Return structure: {status: {used: int, total: int}, items: {active/final/raw: {item_token:{quality: data}}}
|
|
|
|
|
If item kind is damageBoosters or aircraftDamageBoosters then kind is renamed to kind+quality and duration is
|
|
|
|
|
used as quality.
|
|
|
|
|
Updates citizen inventory
|
|
|
|
|
"""
|
|
|
|
|
self._update_inventory_data(self._get_economy_inventory_items().json())
|
|
|
|
|
|
|
|
|
@ -312,7 +309,7 @@ class BaseCitizen(access_points.CitizenAPI):
|
|
|
|
|
|
|
|
|
|
if item_data.get('type'):
|
|
|
|
|
# in ['damageBoosters', "aircraftDamageBoosters", 'prestigePointsBoosters']
|
|
|
|
|
if item_data.get('type').endswith('Boosters'):
|
|
|
|
|
if item_data.get('isBooster'):
|
|
|
|
|
is_booster = True
|
|
|
|
|
kind = item_data['type']
|
|
|
|
|
|
|
|
|
@ -1207,7 +1204,7 @@ class CitizenEconomy(CitizenTravel):
|
|
|
|
|
items = (self.inventory.final if final_kind else self.inventory.raw).get(constants.INDUSTRIES[industry],
|
|
|
|
|
{_inv_qlt: {'amount': 0}})
|
|
|
|
|
if items[_inv_qlt]['amount'] < amount:
|
|
|
|
|
self.get_inventory(True)
|
|
|
|
|
self.update_inventory()
|
|
|
|
|
items = (self.inventory.final if final_kind else self.inventory.raw).get(constants.INDUSTRIES[industry],
|
|
|
|
|
{_inv_qlt: {'amount': 0}})
|
|
|
|
|
if items[_inv_qlt]['amount'] < amount:
|
|
|
|
@ -1775,7 +1772,8 @@ class CitizenMilitary(CitizenTravel):
|
|
|
|
|
yield battle, battle_zone, side
|
|
|
|
|
|
|
|
|
|
def find_battle_and_fight(self):
|
|
|
|
|
if self.should_fight()[0]:
|
|
|
|
|
count = self.should_fight()[0]
|
|
|
|
|
if count:
|
|
|
|
|
self.write_log("Checking for battles to fight in...")
|
|
|
|
|
for battle, division, side in self.find_battle_to_fight():
|
|
|
|
|
|
|
|
|
@ -1802,7 +1800,7 @@ class CitizenMilitary(CitizenTravel):
|
|
|
|
|
|
|
|
|
|
if self.change_division(battle, division):
|
|
|
|
|
self.set_default_weapon(battle, division)
|
|
|
|
|
self.fight(battle, division, side)
|
|
|
|
|
self.fight(battle, division, side, count)
|
|
|
|
|
self.travel_to_residence()
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
@ -2020,7 +2018,7 @@ class CitizenMilitary(CitizenTravel):
|
|
|
|
|
|
|
|
|
|
return utils.calculate_hit(0, rang, True, elite, ne, 0, 20 if weapon else 0)
|
|
|
|
|
|
|
|
|
|
def activate_damage_booster(self, ground: bool = True):
|
|
|
|
|
def activate_damage_booster(self, ground: bool = True) -> int:
|
|
|
|
|
kind = 'damageBoosters' if ground else 'aircraftDamageBoosters'
|
|
|
|
|
if self.config.boosters and not self.get_active_damage_booster(ground):
|
|
|
|
|
booster: Optional[types.InvFinalItem] = None
|
|
|
|
@ -2032,9 +2030,11 @@ class CitizenMilitary(CitizenTravel):
|
|
|
|
|
break
|
|
|
|
|
break
|
|
|
|
|
if booster:
|
|
|
|
|
kind = 'damage' if ground else 'air_damage'
|
|
|
|
|
self._report_action("MILITARY_BOOSTER", f"Activated {booster['name']}")
|
|
|
|
|
self._post_economy_activate_booster(booster['quality'], booster['durability'],
|
|
|
|
|
'damage' if ground else 'air_damage')
|
|
|
|
|
resp = self._post_economy_activate_booster(booster['quality'], booster['durability'], kind).json()
|
|
|
|
|
self._update_inventory_data(resp)
|
|
|
|
|
return self.get_active_damage_booster(ground)
|
|
|
|
|
|
|
|
|
|
def get_active_damage_booster(self, ground: bool = True) -> int:
|
|
|
|
|
kind = 'damageBoosters' if ground else 'aircraftDamageBoosters'
|
|
|
|
@ -2051,13 +2051,16 @@ class CitizenMilitary(CitizenTravel):
|
|
|
|
|
def get_active_air_damage_booster(self) -> int:
|
|
|
|
|
return self.get_active_damage_booster(False)
|
|
|
|
|
|
|
|
|
|
def activate_battle_effect(self, battle_id: int, kind: str) -> Response:
|
|
|
|
|
def activate_battle_effect(self, battle_id: int, kind: str) -> bool:
|
|
|
|
|
self._report_action('MILITARY_BOOSTER', f'Activated {kind} booster')
|
|
|
|
|
return self._post_main_activate_battle_effect(battle_id, kind, self.details.citizen_id)
|
|
|
|
|
resp = self._post_main_activate_battle_effect(battle_id, kind, self.details.citizen_id).json()
|
|
|
|
|
return not resp.get('error')
|
|
|
|
|
|
|
|
|
|
def activate_pp_booster(self, pp_item: types.InvFinalItem) -> Response:
|
|
|
|
|
def activate_pp_booster(self, pp_item: types.InvFinalItem) -> bool:
|
|
|
|
|
self._report_action('MILITARY_BOOSTER', f'Activated {pp_item["name"]}')
|
|
|
|
|
return self._post_economy_activate_booster(pp_item['quality'], pp_item['durability'], 'prestige_points')
|
|
|
|
|
resp = self._post_economy_activate_booster(pp_item['quality'], pp_item['durability'], 'prestige_points').json()
|
|
|
|
|
self._update_inventory_data(resp)
|
|
|
|
|
return pp_item.get('kind') in self.inventory.active
|
|
|
|
|
|
|
|
|
|
def _rw_choose_side(self, battle: classes.Battle, side: classes.BattleSide) -> Response:
|
|
|
|
|
return self._post_main_battlefield_travel(side.id, battle.id)
|
|
|
|
@ -2674,7 +2677,6 @@ class Citizen(CitizenAnniversary, CitizenCompanies, CitizenLeaderBoard,
|
|
|
|
|
else:
|
|
|
|
|
start_time = utils.good_timedelta(start_time.replace(minute=0), timedelta(hours=1))
|
|
|
|
|
while not self.stop_threads.is_set():
|
|
|
|
|
self.update_citizen_info()
|
|
|
|
|
start_time = utils.good_timedelta(start_time, timedelta(minutes=30))
|
|
|
|
|
self.send_state_update()
|
|
|
|
|
self.send_inventory_update()
|
|
|
|
@ -2685,6 +2687,7 @@ class Citizen(CitizenAnniversary, CitizenCompanies, CitizenLeaderBoard,
|
|
|
|
|
self.report_error("State updater crashed")
|
|
|
|
|
|
|
|
|
|
def send_state_update(self):
|
|
|
|
|
self.update_all(True)
|
|
|
|
|
data = dict(xp=self.details.xp, cc=self.details.cc, gold=self.details.gold, pp=self.details.pp,
|
|
|
|
|
inv_total=self.inventory.total, inv=self.inventory.used,
|
|
|
|
|
hp_limit=self.energy.limit,
|
|
|
|
|