Lint
This commit is contained in:
parent
e798859105
commit
8aa90a7dbf
@ -9,4 +9,4 @@ __version__ = '0.22.1'
|
||||
from erepublik import classes, utils, constants
|
||||
from erepublik.citizen import Citizen
|
||||
|
||||
__all__ = ["classes", "utils", "Citizen", ]
|
||||
__all__ = ["classes", "utils", "Citizen", 'constants']
|
||||
|
@ -346,11 +346,12 @@ class ErepublikEconomyAPI(CitizenBaseAPI):
|
||||
|
||||
def _post_economy_marketplace_actions(self, action: str, **kwargs) -> Response:
|
||||
if action == 'buy':
|
||||
data = dict(_token=self.token, offerId=kwargs['offer'], amount=kwargs['amount'], orderBy="price_asc", currentPage=1,
|
||||
buyAction=1)
|
||||
data = dict(_token=self.token, offerId=kwargs['offer'], amount=kwargs['amount'],
|
||||
orderBy="price_asc", currentPage=1, buyAction=1)
|
||||
elif action == 'sell':
|
||||
data = dict(_token=self.token, countryId=kwargs["country_id"], price=kwargs["price"],
|
||||
industryId=kwargs["industry"], quality=kwargs["quality"], amount=kwargs['amount'], sellAction='postOffer')
|
||||
industryId=kwargs["industry"], quality=kwargs["quality"], amount=kwargs['amount'],
|
||||
sellAction='postOffer')
|
||||
elif action == 'delete':
|
||||
data = dict(_token=self.token, offerId=kwargs["offer_id"], sellAction='deleteOffer')
|
||||
else:
|
||||
@ -359,16 +360,16 @@ class ErepublikEconomyAPI(CitizenBaseAPI):
|
||||
|
||||
|
||||
class ErepublikLeaderBoardAPI(CitizenBaseAPI):
|
||||
def _get_main_leaderboards_damage_aircraft_rankings(self, country_id: int, weeks: int = 0, mu_id: int = 0) -> Response:
|
||||
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")
|
||||
|
||||
def _get_main_leaderboards_damage_rankings(self, country_id: int, weeks: int = 0, mu_id: int = 0, div: int = 0) -> Response:
|
||||
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}")
|
||||
|
||||
def _get_main_leaderboards_kills_aircraft_rankings(self, country_id: int, weeks: int = 0, mu_id: int = 0) -> Response:
|
||||
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")
|
||||
|
||||
def _get_main_leaderboards_kills_rankings(self, country_id: int, weeks: int = 0, mu_id: int = 0, div: int = 0) -> Response:
|
||||
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}")
|
||||
|
||||
|
||||
|
@ -1494,51 +1494,6 @@ class CitizenMilitary(CitizenTravel):
|
||||
f" new influence {influence}", kwargs=r.json())
|
||||
return influence
|
||||
|
||||
# def check_epic_battles(self):
|
||||
# active_fs = False
|
||||
# for battle_id in self.sorted_battles(self.config.sort_battles_time):
|
||||
# battle = self.all_battles.get(battle_id)
|
||||
# if not battle.is_air:
|
||||
# my_div: BattleDivision = battle.div.get(self.division)
|
||||
# if my_div.epic and my_div.end > self.now:
|
||||
# if self.energy.food_fights > 50:
|
||||
# inv_allies = battle.invader.deployed + [battle.invader.id]
|
||||
# def_allies = battle.defender.deployed + [battle.defender.id]
|
||||
# all_allies = inv_allies + def_allies
|
||||
# if self.details.current_country not in all_allies:
|
||||
# if self.details.current_country in battle.invader.allies:
|
||||
# allies = battle.invader.deployed
|
||||
# side = battle.invader.id
|
||||
# else:
|
||||
# allies = battle.defender.deployed
|
||||
# side = battle.defender.id
|
||||
#
|
||||
# self.travel_to_battle(battle.id, allies)
|
||||
#
|
||||
# else:
|
||||
# if self.details.current_country in inv_allies:
|
||||
# side = battle.invader.id
|
||||
# elif self.details.current_country in def_allies:
|
||||
# side = battle.defender.id
|
||||
# else:
|
||||
# self.write_log(
|
||||
# f"Country {self.details.current_country} not in all allies list ({all_allies}) and "
|
||||
# f"also not in inv allies ({inv_allies}) nor def allies ({def_allies})")
|
||||
# break
|
||||
# error_count = 0
|
||||
# while self.energy.food_fights > 5 and error_count < 20:
|
||||
# errors = self.fight(battle_id, side_id=side, count=self.energy.food_fights - 5)
|
||||
# if errors:
|
||||
# error_count += errors
|
||||
# if self.config.epic_hunt_ebs:
|
||||
# self._eat('orange')
|
||||
# self.travel_to_residence()
|
||||
# break
|
||||
# elif bool(my_div.epic):
|
||||
# active_fs = True
|
||||
#
|
||||
# self.active_fs = active_fs
|
||||
|
||||
def sorted_battles(self, sort_by_time: bool = True, only_tp=False) -> List[classes.Battle]:
|
||||
cs_battles_priority_air: List[classes.Battle] = []
|
||||
cs_battles_priority_ground: List[classes.Battle] = []
|
||||
|
@ -3,7 +3,7 @@ import hashlib
|
||||
import threading
|
||||
import weakref
|
||||
from decimal import Decimal
|
||||
from typing import Any, Dict, List, NamedTuple, Optional, Tuple, Union, NoReturn, Generator, Iterable
|
||||
from typing import Any, Dict, List, NamedTuple, Tuple, Union, NoReturn, Generator, Iterable
|
||||
|
||||
from requests import Response, Session, post
|
||||
|
||||
@ -314,7 +314,9 @@ class MyCompanies:
|
||||
self._companies.clear()
|
||||
|
||||
@property
|
||||
def as_dict(self) -> Dict[str, Union[str, int, datetime.datetime, Dict[str, Dict[str, Union[str, int, List[Dict[str, Union[str, int, bool, float, Decimal]]]]]]]]:
|
||||
def as_dict(self) -> Dict[str, Union[str, int, datetime.datetime, Dict[str, Dict[str, Union[
|
||||
str, int, List[Dict[str, Union[str, int, bool, float, Decimal]]]]
|
||||
]]]]:
|
||||
return dict(name=str(self), work_units=self.work_units, next_ot_time=self.next_ot_time,
|
||||
ff_lockdown=self.ff_lockdown,
|
||||
holdings={str(hi): h.as_dict for hi, h in self.holdings.items()},
|
||||
@ -857,13 +859,15 @@ class Battle:
|
||||
self.invader = BattleSide(
|
||||
self, constants.COUNTRIES[battle.get('inv', {}).get('id')], battle.get('inv', {}).get('points'),
|
||||
[constants.COUNTRIES[row.get('id')] for row in battle.get('inv', {}).get('ally_list')],
|
||||
[constants.COUNTRIES[row.get('id')] for row in battle.get('inv', {}).get('ally_list') if row['deployed']], False
|
||||
[constants.COUNTRIES[row.get('id')] for row in battle.get('inv', {}).get('ally_list') if row['deployed']],
|
||||
False
|
||||
)
|
||||
|
||||
self.defender = BattleSide(
|
||||
self, constants.COUNTRIES[battle.get('def', {}).get('id')], battle.get('def', {}).get('points'),
|
||||
[constants.COUNTRIES[row.get('id')] for row in battle.get('def', {}).get('ally_list')],
|
||||
[constants.COUNTRIES[row.get('id')] for row in battle.get('def', {}).get('ally_list') if row['deployed']], True
|
||||
[constants.COUNTRIES[row.get('id')] for row in battle.get('def', {}).get('ally_list') if row['deployed']],
|
||||
True
|
||||
)
|
||||
|
||||
self.div = {}
|
||||
@ -890,7 +894,8 @@ class Battle:
|
||||
else:
|
||||
time_part = "-{}".format(self.start - time_now)
|
||||
|
||||
return f"Battle {self.id} for {self.region_name[:16]} | {self.invader} : {self.defender} | Round time {time_part}"
|
||||
return (f"Battle {self.id} for {self.region_name[:16]} | "
|
||||
f"{self.invader} : {self.defender} | Round time {time_part}")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Battle #{self.id} {self.invader}:{self.defender} R{self.zone_id}>"
|
||||
|
@ -2,7 +2,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Tests for `erepublik` package."""
|
||||
from typing import Callable
|
||||
|
||||
from erepublik import Citizen
|
||||
|
||||
@ -66,7 +65,8 @@ class TestErepublik(unittest.TestCase):
|
||||
self.assertEqual(self.citizen.next_reachable_energy, 0)
|
||||
|
||||
def test_should_fight(self):
|
||||
is_wc_close: Callable[[], bool] = lambda: self.citizen.max_time_till_full_ff > self.citizen.time_till_week_change
|
||||
def is_wc_close():
|
||||
return self.citizen.max_time_till_full_ff > self.citizen.time_till_week_change
|
||||
self.citizen.config.fight = False
|
||||
self.assertEqual(self.citizen.should_fight(), (0, "Fighting not allowed!", False))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user