Bomb deploy update
This commit is contained in:
parent
d522a4faeb
commit
c462eac369
@ -15,10 +15,14 @@ class SlowRequests(Session):
|
|||||||
timeout: datetime.timedelta = datetime.timedelta(milliseconds=500)
|
timeout: datetime.timedelta = datetime.timedelta(milliseconds=500)
|
||||||
uas: List[str] = [
|
uas: List[str] = [
|
||||||
# Chrome
|
# Chrome
|
||||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36', # noqa
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36',
|
||||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36', # noqa
|
# noqa
|
||||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36', # noqa
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36',
|
||||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36', # noqa
|
# noqa
|
||||||
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36',
|
||||||
|
# noqa
|
||||||
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36',
|
||||||
|
# noqa
|
||||||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36',
|
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36',
|
||||||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36',
|
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36',
|
||||||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36',
|
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36',
|
||||||
@ -285,7 +289,6 @@ class ErepublikCountryAPI(CitizenBaseAPI):
|
|||||||
|
|
||||||
def _post_main_country_donate(self, country_id: int, action: str, value: Union[int, float],
|
def _post_main_country_donate(self, country_id: int, action: str, value: Union[int, float],
|
||||||
quality: int = None) -> Response:
|
quality: int = None) -> Response:
|
||||||
|
|
||||||
data = dict(countryId=country_id, action=action, _token=self.token, value=value, quality=quality)
|
data = dict(countryId=country_id, action=action, _token=self.token, value=value, quality=quality)
|
||||||
return self.post(f"{self.url}/main/country-donate", data=data,
|
return self.post(f"{self.url}/main/country-donate", data=data,
|
||||||
headers={"Referer": f"{self.url}/country/economy/Latvia"})
|
headers={"Referer": f"{self.url}/country/economy/Latvia"})
|
||||||
@ -360,16 +363,20 @@ class ErepublikEconomyAPI(CitizenBaseAPI):
|
|||||||
|
|
||||||
|
|
||||||
class ErepublikLeaderBoardAPI(CitizenBaseAPI):
|
class ErepublikLeaderBoardAPI(CitizenBaseAPI):
|
||||||
def _get_main_leaderboards_damage_aircraft_rankings(self, country_id: int, weeks: int = 0, mu_id: int = 0) -> Response: # noqa
|
def _get_main_leaderboards_damage_aircraft_rankings(self, country_id: int, weeks: int = 0,
|
||||||
|
mu_id: int = 0) -> Response: # noqa
|
||||||
return self.get(f"{self.url}/main/leaderboards-damage-aircraft-rankings/{country_id}/{weeks}/{mu_id}/0")
|
return self.get(f"{self.url}/main/leaderboards-damage-aircraft-rankings/{country_id}/{weeks}/{mu_id}/0")
|
||||||
|
|
||||||
def _get_main_leaderboards_damage_rankings(self, country_id: int, weeks: int = 0, mu_id: int = 0, div: int = 0) -> Response: # noqa
|
def _get_main_leaderboards_damage_rankings(self, country_id: int, weeks: int = 0, mu_id: int = 0,
|
||||||
|
div: int = 0) -> Response: # noqa
|
||||||
return self.get(f"{self.url}/main/leaderboards-damage-rankings/{country_id}/{weeks}/{mu_id}/{div}")
|
return self.get(f"{self.url}/main/leaderboards-damage-rankings/{country_id}/{weeks}/{mu_id}/{div}")
|
||||||
|
|
||||||
def _get_main_leaderboards_kills_aircraft_rankings(self, country_id: int, weeks: int = 0, mu_id: int = 0) -> Response: # noqa
|
def _get_main_leaderboards_kills_aircraft_rankings(self, country_id: int, weeks: int = 0,
|
||||||
|
mu_id: int = 0) -> Response: # noqa
|
||||||
return self.get(f"{self.url}/main/leaderboards-kills-aircraft-rankings/{country_id}/{weeks}/{mu_id}/0")
|
return self.get(f"{self.url}/main/leaderboards-kills-aircraft-rankings/{country_id}/{weeks}/{mu_id}/0")
|
||||||
|
|
||||||
def _get_main_leaderboards_kills_rankings(self, country_id: int, weeks: int = 0, mu_id: int = 0, div: int = 0) -> Response: # noqa
|
def _get_main_leaderboards_kills_rankings(self, country_id: int, weeks: int = 0, mu_id: int = 0,
|
||||||
|
div: int = 0) -> Response: # noqa
|
||||||
return self.get(f"{self.url}/main/leaderboards-kills-rankings/{country_id}/{weeks}/{mu_id}/{div}")
|
return self.get(f"{self.url}/main/leaderboards-kills-rankings/{country_id}/{weeks}/{mu_id}/{div}")
|
||||||
|
|
||||||
|
|
||||||
@ -435,8 +442,9 @@ class ErepublikMilitaryAPI(CitizenBaseAPI):
|
|||||||
data.update(page=page)
|
data.update(page=page)
|
||||||
return self.post(f"{self.url}/military/battle-console", data=data)
|
return self.post(f"{self.url}/military/battle-console", data=data)
|
||||||
|
|
||||||
def _post_military_deploy_bomb(self, battle_id: int, bomb_id: int) -> Response:
|
def _post_military_deploy_bomb(self, battle_id: int, division_id: int, side_id: int, bomb_id: int) -> Response:
|
||||||
data = dict(battleId=battle_id, bombId=bomb_id, _token=self.token)
|
data = dict(battleId=battle_id, battleZoneId=division_id, sideId=side_id, sideCountryId=side_id,
|
||||||
|
bombId=bomb_id, _token=self.token)
|
||||||
return self.post(f"{self.url}/military/deploy-bomb", data=data)
|
return self.post(f"{self.url}/military/deploy-bomb", data=data)
|
||||||
|
|
||||||
def _post_military_fight_air(self, battle_id: int, side_id: int, zone_id: int) -> Response:
|
def _post_military_fight_air(self, battle_id: int, side_id: int, zone_id: int) -> Response:
|
||||||
|
@ -1873,14 +1873,19 @@ class CitizenMilitary(CitizenTravel):
|
|||||||
return hits, err, damage
|
return hits, err, damage
|
||||||
|
|
||||||
@utils.wait_for_lock
|
@utils.wait_for_lock
|
||||||
def deploy_bomb(self, battle: classes.Battle, bomb_id: int, inv_side: bool = None, count: int = 1) -> Optional[int]:
|
def deploy_bomb(self, battle: classes.Battle, division: classes.BattleDivision, bomb_id: int, inv_side: bool, count: int = 1) -> Optional[int]:
|
||||||
"""Deploy bombs in a battle for given side.
|
"""Deploy bombs in a battle for given side.
|
||||||
|
|
||||||
:param battle: Battle
|
:param battle: Battle
|
||||||
:type battle: Battle
|
:type battle: classes.Battle
|
||||||
|
:param division: BattleDivision
|
||||||
|
:type division: classes.BattleDivision
|
||||||
:param bomb_id: int bomb id
|
:param bomb_id: int bomb id
|
||||||
:param inv_side: should deploy on invader side, if None then will deploy in currently available side
|
:type bomb_id: int
|
||||||
:param count: int how many bombs to deploy
|
:param inv_side: should deploy on invader side
|
||||||
|
:type inv_side: bool
|
||||||
|
:param count: how many bombs to deploy
|
||||||
|
:type count: int
|
||||||
:return: Deployed count
|
:return: Deployed count
|
||||||
:rtype: int
|
:rtype: int
|
||||||
"""
|
"""
|
||||||
@ -1895,10 +1900,6 @@ class CitizenMilitary(CitizenTravel):
|
|||||||
good_countries = [battle.invader.country] + battle.invader.deployed
|
good_countries = [battle.invader.country] + battle.invader.deployed
|
||||||
if self.details.current_country not in good_countries:
|
if self.details.current_country not in good_countries:
|
||||||
has_traveled = self.travel_to_battle(battle, good_countries)
|
has_traveled = self.travel_to_battle(battle, good_countries)
|
||||||
elif inv_side is not None:
|
|
||||||
good_countries = [battle.defender.country] + battle.defender.deployed
|
|
||||||
if self.details.current_country not in good_countries:
|
|
||||||
has_traveled = self.travel_to_battle(battle, good_countries)
|
|
||||||
else:
|
else:
|
||||||
involved = [battle.invader.country,
|
involved = [battle.invader.country,
|
||||||
battle.defender.country] + battle.invader.deployed + battle.defender.deployed
|
battle.defender.country] + battle.invader.deployed + battle.defender.deployed
|
||||||
@ -1906,7 +1907,7 @@ class CitizenMilitary(CitizenTravel):
|
|||||||
count = 0
|
count = 0
|
||||||
errors = deployed_count = 0
|
errors = deployed_count = 0
|
||||||
while (not deployed_count == count) and errors < 10:
|
while (not deployed_count == count) and errors < 10:
|
||||||
r = self._post_military_deploy_bomb(battle.id, bomb_id).json()
|
r = self._post_military_deploy_bomb(battle.id, division.id, bomb_id).json()
|
||||||
if not r.get('error'):
|
if not r.get('error'):
|
||||||
deployed_count += 1
|
deployed_count += 1
|
||||||
elif r.get('message') == 'LOCKED':
|
elif r.get('message') == 'LOCKED':
|
||||||
|
Loading…
x
Reference in New Issue
Block a user