Fixed medal amounts, removed military related stuff
This commit is contained in:
5
.flake8
Normal file
5
.flake8
Normal file
@ -0,0 +1,5 @@
|
||||
[flake8]
|
||||
ignore = E203,E722
|
||||
exclude = .git,__pycache__,venv,docs,debug,log
|
||||
max-line-length = 120
|
||||
#max-complexity = 10
|
16
docs/conf.py
16
docs/conf.py
@ -23,10 +23,12 @@ import sys
|
||||
|
||||
sys.path.insert(0, os.path.abspath(".."))
|
||||
|
||||
import erepublik
|
||||
import edx_theme
|
||||
import datetime
|
||||
|
||||
import edx_theme
|
||||
|
||||
import erepublik
|
||||
|
||||
# -- General configuration ---------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
@ -146,5 +148,13 @@ man_pages = [(master_doc, "erepublik", "eRepublik script Documentation", [author
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, "erepublik", "eRepublik script Documentation", author, "erepublik", "One line description of project.", "Miscellaneous"),
|
||||
(
|
||||
master_doc,
|
||||
"erepublik",
|
||||
"eRepublik script Documentation",
|
||||
author,
|
||||
"erepublik",
|
||||
"One line description of project.",
|
||||
"Miscellaneous",
|
||||
),
|
||||
]
|
||||
|
@ -133,7 +133,9 @@ class ErepublikErrorHTTTPHandler(handlers.HTTPHandler):
|
||||
except: # noqa
|
||||
resp_time = slugify(response.headers.get("date"))
|
||||
return dict(
|
||||
name=f"{resp_time}_{name}.{ext}", content=html.encode("utf-8"), mimetype="application/json" if ext == "json" else "text/html"
|
||||
name=f"{resp_time}_{name}.{ext}",
|
||||
content=html.encode("utf-8"),
|
||||
mimetype="application/json" if ext == "json" else "text/html",
|
||||
)
|
||||
|
||||
def _get_local_vars(self) -> str:
|
||||
|
@ -115,7 +115,9 @@ class SlowRequests(Session):
|
||||
firefox_template = "Mozilla/5.0 ({osystem}; rv:{version}.0) Gecko/20100101 Firefox/{version}.0"
|
||||
firefox_versions = range(85, 92)
|
||||
|
||||
chrome_template = "Mozilla/5.0 ({osystem}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{version} Safari/537.36"
|
||||
chrome_template = (
|
||||
"Mozilla/5.0 ({osystem}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{version} Safari/537.36"
|
||||
)
|
||||
chrome_versions = [
|
||||
"85.0.4183.121",
|
||||
"86.0.4240.183",
|
||||
@ -192,7 +194,11 @@ class CitizenBaseAPI:
|
||||
cookies_hash = hashlib.sha256(",".join(env["c"]).encode("utf8")).hexdigest()
|
||||
|
||||
cookie_kwargs = dict(
|
||||
expires=int(time.time()) + 120, path="/en/main/sessionUnlock", domain=".www.erepublik.com", secure=True, rest={"HttpOnly": True}
|
||||
expires=int(time.time()) + 120,
|
||||
path="/en/main/sessionUnlock",
|
||||
domain=".www.erepublik.com",
|
||||
secure=True,
|
||||
rest={"HttpOnly": True},
|
||||
)
|
||||
self._req.cookies.set("sh", session_hash, **cookie_kwargs)
|
||||
self._req.cookies.set("ch", cookies_hash, **cookie_kwargs)
|
||||
@ -271,7 +277,13 @@ class ErepublikArticleAPI(CitizenBaseAPI):
|
||||
return self.post(f"{self.url}/main/donate-article", data=data)
|
||||
|
||||
def _post_main_write_article(self, title: str, content: str, country_id: int, kind_id: int) -> Response:
|
||||
data = dict(_token=self.token, article_name=title, article_body=content, article_location=country_id, article_category=kind_id)
|
||||
data = dict(
|
||||
_token=self.token,
|
||||
article_name=title,
|
||||
article_body=content,
|
||||
article_location=country_id,
|
||||
article_category=kind_id,
|
||||
)
|
||||
return self.post(f"{self.url}/main/write-article", data=data)
|
||||
|
||||
def _post_main_vote_article(self, article_id: int) -> Response:
|
||||
@ -286,7 +298,9 @@ class ErepublikCompanyAPI(CitizenBaseAPI):
|
||||
|
||||
def _post_economy_create_company(self, industry_id: int, building_type: int = 1) -> Response:
|
||||
data = {"_token": self.token, "company[industry_id]": industry_id, "company[building_type]": building_type}
|
||||
return self.post(f"{self.url}/economy/create-company", data=data, headers={"Referer": f"{self.url}/economy/create-company"})
|
||||
return self.post(
|
||||
f"{self.url}/economy/create-company", data=data, headers={"Referer": f"{self.url}/economy/create-company"}
|
||||
)
|
||||
|
||||
def _get_economy_inventory_items(self) -> Response:
|
||||
return self.get(f"{self.url}/economy/inventory-items/")
|
||||
@ -366,9 +380,13 @@ class ErepublikCountryAPI(CitizenBaseAPI):
|
||||
def _get_country_military(self, country_name: str) -> Response:
|
||||
return self.get(f"{self.url}/country/military/{country_name}")
|
||||
|
||||
def _post_main_country_donate(self, country_id: int, action: str, value: Union[int, float], quality: int = None) -> Response:
|
||||
def _post_main_country_donate(
|
||||
self, country_id: int, action: str, value: Union[int, float], quality: int = None
|
||||
) -> Response:
|
||||
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, headers={"Referer": f"{self.url}/country/economy/Latvia"})
|
||||
return self.post(
|
||||
f"{self.url}/main/country-donate", data=data, headers={"Referer": f"{self.url}/country/economy/Latvia"}
|
||||
)
|
||||
|
||||
|
||||
class ErepublikEconomyAPI(CitizenBaseAPI):
|
||||
@ -396,13 +414,17 @@ class ErepublikEconomyAPI(CitizenBaseAPI):
|
||||
def _post_economy_donate_items_action(self, citizen_id: int, amount: int, industry: int, quality: int) -> Response:
|
||||
data = dict(citizen_id=citizen_id, amount=amount, industry_id=industry, quality=quality, _token=self.token)
|
||||
return self.post(
|
||||
f"{self.url}/economy/donate-items-action", data=data, headers={"Referer": f"{self.url}/economy/donate-items/{citizen_id}"}
|
||||
f"{self.url}/economy/donate-items-action",
|
||||
data=data,
|
||||
headers={"Referer": f"{self.url}/economy/donate-items/{citizen_id}"},
|
||||
)
|
||||
|
||||
def _post_economy_donate_money_action(self, citizen_id: int, amount: float = 0.0, currency: int = 62) -> Response:
|
||||
data = dict(citizen_id=citizen_id, _token=self.token, currency_id=currency, amount=amount)
|
||||
return self.post(
|
||||
f"{self.url}/economy/donate-money-action", data=data, headers={"Referer": f"{self.url}/economy/donate-money/{citizen_id}"}
|
||||
f"{self.url}/economy/donate-money-action",
|
||||
data=data,
|
||||
headers={"Referer": f"{self.url}/economy/donate-money/{citizen_id}"},
|
||||
)
|
||||
|
||||
def _post_economy_exchange_purchase(self, amount: float, currency: int, offer: int) -> Response:
|
||||
@ -434,7 +456,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
|
||||
_token=self.token,
|
||||
offerId=kwargs["offer"],
|
||||
amount=kwargs["amount"],
|
||||
orderBy="price_asc",
|
||||
currentPage=1,
|
||||
buyAction=1,
|
||||
)
|
||||
elif action == "sell":
|
||||
data = dict(
|
||||
@ -454,16 +481,24 @@ 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: # 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")
|
||||
|
||||
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}")
|
||||
|
||||
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")
|
||||
|
||||
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}")
|
||||
|
||||
|
||||
@ -543,7 +578,14 @@ class ErepublikMilitaryAPI(CitizenBaseAPI):
|
||||
return self.post(f"{self.url}/military/battle-console", data=data)
|
||||
|
||||
def _post_military_deploy_bomb(self, battle_id: int, division_id: int, side_id: int, bomb_id: int) -> Response:
|
||||
data = dict(battleId=battle_id, battleZoneId=division_id, sideId=side_id, sideCountryId=side_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)
|
||||
|
||||
def _post_military_fight_air(self, battle_id: int, side_id: int, zone_id: int) -> Response:
|
||||
@ -599,7 +641,9 @@ class ErepublikPoliticsAPI(CitizenBaseAPI):
|
||||
return self.get(f"{self.url}/main/presidential-elections/{country_id}/{timestamp}")
|
||||
|
||||
def _post_propose_president_candidate(self, party_slug: str, citizen_id: int) -> Response:
|
||||
return self.post(f"{self.url}/propose-president-candidate/{party_slug}", data=dict(_token=self.token, citizen=citizen_id))
|
||||
return self.post(
|
||||
f"{self.url}/propose-president-candidate/{party_slug}", data=dict(_token=self.token, citizen=citizen_id)
|
||||
)
|
||||
|
||||
def _get_auto_propose_president_candidate(self, party_slug: str) -> Response:
|
||||
return self.get(f"{self.url}/auto-propose-president-candidate/{party_slug}")
|
||||
@ -611,11 +655,24 @@ class ErepublikPresidentAPI(CitizenBaseAPI):
|
||||
return self.post(f"{self.url}/wars/attack-region/{war_id}/{region_id}", data=data)
|
||||
|
||||
def _post_new_war(self, self_country_id: int, attack_country_id: int, debate: str = "") -> Response:
|
||||
data = dict(requirments=1, _token=self.token, debate=debate, countryNameConfirm=constants.COUNTRIES[attack_country_id].link)
|
||||
data = dict(
|
||||
requirments=1,
|
||||
_token=self.token,
|
||||
debate=debate,
|
||||
countryNameConfirm=constants.COUNTRIES[attack_country_id].link,
|
||||
)
|
||||
return self.post(f"{self.url}/{constants.COUNTRIES[self_country_id].link}/new-war", data=data)
|
||||
|
||||
def _post_new_donation(self, country_id: int, amount: int, org_name: str, debate: str = "") -> Response:
|
||||
data = dict(requirments=1, _token=self.token, debate=debate, currency=1, value=amount, commit="Propose", type_name=org_name)
|
||||
data = dict(
|
||||
requirments=1,
|
||||
_token=self.token,
|
||||
debate=debate,
|
||||
currency=1,
|
||||
value=amount,
|
||||
commit="Propose",
|
||||
type_name=org_name,
|
||||
)
|
||||
return self.post(f"{self.url}/{constants.COUNTRIES[country_id].link}/new-donation", data=data)
|
||||
|
||||
|
||||
@ -705,7 +762,12 @@ class ErepublikProfileAPI(CitizenBaseAPI):
|
||||
|
||||
def _post_main_messages_compose(self, subject: str, body: str, citizens: List[int]) -> Response:
|
||||
url_pk = 0 if len(citizens) > 1 else str(citizens[0])
|
||||
data = dict(citizen_name=",".join([str(x) for x in citizens]), citizen_subject=subject, _token=self.token, citizen_message=body)
|
||||
data = dict(
|
||||
citizen_name=",".join([str(x) for x in citizens]),
|
||||
citizen_subject=subject,
|
||||
_token=self.token,
|
||||
citizen_message=body,
|
||||
)
|
||||
return self.post(f"{self.url}/main/messages-compose/{url_pk}", data=data)
|
||||
|
||||
def _post_military_group_missions(self) -> Response:
|
||||
@ -810,7 +872,8 @@ class ErepublikWallPostAPI(CitizenBaseAPI):
|
||||
# ## Medal posting
|
||||
def _post_main_wall_post_automatic(self, message: str, achievement_id: int) -> Response:
|
||||
return self.post(
|
||||
f"{self.url}/main/wall-post/automatic", data=dict(_token=self.token, message=message, achievementId=achievement_id)
|
||||
f"{self.url}/main/wall-post/automatic",
|
||||
data=dict(_token=self.token, message=message, achievementId=achievement_id),
|
||||
)
|
||||
|
||||
|
||||
|
1938
erepublik/citizen.py
1938
erepublik/citizen.py
File diff suppressed because it is too large
Load Diff
@ -129,7 +129,13 @@ class Holding:
|
||||
|
||||
@property
|
||||
def as_dict(self) -> Dict[str, Union[str, int, List[Dict[str, Union[str, int, bool, float, Decimal]]]]]:
|
||||
return dict(name=self.name, id=self.id, region=self.region, companies=[c.as_dict for c in self.companies], wam_count=self.wam_count)
|
||||
return dict(
|
||||
name=self.name,
|
||||
id=self.id,
|
||||
region=self.region,
|
||||
companies=[c.as_dict for c in self.companies],
|
||||
wam_count=self.wam_count,
|
||||
)
|
||||
|
||||
@property
|
||||
def citizen(self):
|
||||
@ -303,7 +309,13 @@ class MyCompanies:
|
||||
"""
|
||||
for holding in holdings.values():
|
||||
if holding.get("id") not in self.holdings:
|
||||
self.holdings.update({int(holding.get("id")): Holding(holding["id"], holding["region_id"], self.citizen, holding["name"])})
|
||||
self.holdings.update(
|
||||
{
|
||||
int(holding.get("id")): Holding(
|
||||
holding["id"], holding["region_id"], self.citizen, holding["name"]
|
||||
)
|
||||
}
|
||||
)
|
||||
if not self.holdings.get(0):
|
||||
self.holdings.update({0: Holding(0, 0, self.citizen, "Unassigned")}) # unassigned
|
||||
|
||||
@ -373,7 +385,12 @@ class MyCompanies:
|
||||
self,
|
||||
) -> Dict[
|
||||
str,
|
||||
Union[str, int, datetime.datetime, Dict[str, Dict[str, Union[str, int, List[Dict[str, Union[str, int, bool, float, Decimal]]]]]]],
|
||||
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),
|
||||
@ -530,12 +547,16 @@ class Energy:
|
||||
|
||||
@property
|
||||
def is_recoverable_full(self):
|
||||
warnings.warn("Deprecated since auto auto-eat! Will be removed soon. Use Energy.is_energy_full", DeprecationWarning)
|
||||
warnings.warn(
|
||||
"Deprecated since auto auto-eat! Will be removed soon. Use Energy.is_energy_full", DeprecationWarning
|
||||
)
|
||||
return self.is_energy_full
|
||||
|
||||
@property
|
||||
def is_recovered_full(self):
|
||||
warnings.warn("Deprecated since auto auto-eat! Will be removed soon. Use Energy.is_energy_full", DeprecationWarning)
|
||||
warnings.warn(
|
||||
"Deprecated since auto auto-eat! Will be removed soon. Use Energy.is_energy_full", DeprecationWarning
|
||||
)
|
||||
return self.is_energy_full
|
||||
|
||||
@property
|
||||
@ -691,7 +712,12 @@ class Reporter:
|
||||
@property
|
||||
def as_dict(self) -> Dict[str, Union[bool, int, str, List[Dict[Any, Any]]]]:
|
||||
return dict(
|
||||
name=self.name, email=self.email, citizen_id=self.citizen_id, key=self.key, allowed=self.allowed, queue=self.__to_update
|
||||
name=self.name,
|
||||
email=self.email,
|
||||
citizen_id=self.citizen_id,
|
||||
key=self.key,
|
||||
allowed=self.allowed,
|
||||
queue=self.__to_update,
|
||||
)
|
||||
|
||||
def __init__(self, citizen):
|
||||
@ -751,7 +777,10 @@ class Reporter:
|
||||
r = self.__bot_update(dict(key=self.key, check=True, player_id=self.citizen_id))
|
||||
if r:
|
||||
if not r.json().get("status"):
|
||||
self._req.post(f"{self.url}/bot/register", json=dict(name=self.name, email=self.email, player_id=self.citizen_id))
|
||||
self._req.post(
|
||||
f"{self.url}/bot/register",
|
||||
json=dict(name=self.name, email=self.email, player_id=self.citizen_id),
|
||||
)
|
||||
self.__registered = True
|
||||
self.allowed = True
|
||||
self.report_action("STARTED", value=utils.now().strftime("%F %T"))
|
||||
@ -790,7 +819,9 @@ class Reporter:
|
||||
self._bot_update(data)
|
||||
|
||||
def report_action(self, action: str, json_val: Dict[Any, Any] = None, value: str = None):
|
||||
json_data = dict(player_id=getattr(self, "citizen_id", None), log={"action": action}, key=getattr(self, "key", None))
|
||||
json_data = dict(
|
||||
player_id=getattr(self, "citizen_id", None), log={"action": action}, key=getattr(self, "key", None)
|
||||
)
|
||||
if json_val:
|
||||
json_data["log"].update(dict(json=json_val))
|
||||
if value:
|
||||
@ -836,14 +867,18 @@ class Reporter:
|
||||
try:
|
||||
battle_response = self._req.get(f"{self.url}/api/v1/battles/{country.id}")
|
||||
return [
|
||||
self.citizen.all_battles[bid] for bid in battle_response.json().get("battle_ids", []) if bid in self.citizen.all_battles
|
||||
self.citizen.all_battles[bid]
|
||||
for bid in battle_response.json().get("battle_ids", [])
|
||||
if bid in self.citizen.all_battles
|
||||
]
|
||||
except: # noqa
|
||||
return []
|
||||
|
||||
def fetch_tasks(self) -> List[Dict[str, Any]]:
|
||||
try:
|
||||
task_response = self._req.post(f"{self.url}/api/v1/command", data=dict(citizen=self.citizen_id, key=self.key)).json()
|
||||
task_response = self._req.post(
|
||||
f"{self.url}/api/v1/command", data=dict(citizen=self.citizen_id, key=self.key)
|
||||
).json()
|
||||
if task_response.get("status"):
|
||||
return task_response.get("data")
|
||||
else:
|
||||
@ -894,7 +929,13 @@ class BattleSide:
|
||||
|
||||
@property
|
||||
def as_dict(self) -> Dict[str, Union[int, constants.Country, bool, List[constants.Country]]]:
|
||||
return dict(points=self.points, country=self.country, is_defender=self.is_defender, allies=self.allies, deployed=self.deployed)
|
||||
return dict(
|
||||
points=self.points,
|
||||
country=self.country,
|
||||
is_defender=self.is_defender,
|
||||
allies=self.allies,
|
||||
deployed=self.deployed,
|
||||
)
|
||||
|
||||
@property
|
||||
def battle(self):
|
||||
@ -917,7 +958,12 @@ class BattleDivision:
|
||||
@property
|
||||
def as_dict(self):
|
||||
return dict(
|
||||
id=self.id, division=self.div, terrain=(self.terrain, self.terrain_display), wall=self.wall, epic=self.epic, end=self.div_end
|
||||
id=self.id,
|
||||
division=self.div,
|
||||
terrain=(self.terrain, self.terrain_display),
|
||||
wall=self.wall,
|
||||
epic=self.epic,
|
||||
end=self.div_end,
|
||||
)
|
||||
|
||||
@property
|
||||
@ -1210,7 +1256,8 @@ class TelegramReporter:
|
||||
|
||||
def report_item_donation(self, citizen_id: int, amount: float, product: str):
|
||||
self.send_message(
|
||||
f"*Donation*: {amount} x {product} to citizen " f"[{citizen_id}](https://www.erepublik.com/en/citizen/profile/{citizen_id})"
|
||||
f"*Donation*: {amount} x {product} to citizen "
|
||||
f"[{citizen_id}](https://www.erepublik.com/en/citizen/profile/{citizen_id})"
|
||||
)
|
||||
|
||||
def report_money_donation(self, citizen_id: int, amount: float, is_currency: bool = True):
|
||||
@ -1228,7 +1275,9 @@ class TelegramReporter:
|
||||
message = "\n\n".join(self.__queue)
|
||||
if self.player_name:
|
||||
message = f"Player *{self.player_name}*\n\n" + message
|
||||
response = post(f"{self.api_url}/sendMessage", json=dict(chat_id=self.chat_id, text=message, parse_mode="Markdown"))
|
||||
response = post(
|
||||
f"{self.api_url}/sendMessage", json=dict(chat_id=self.chat_id, text=message, parse_mode="Markdown")
|
||||
)
|
||||
self._last_time = utils.now()
|
||||
if response.json().get("ok"):
|
||||
self.__queue.clear()
|
||||
@ -1275,5 +1324,11 @@ class Inventory:
|
||||
@property
|
||||
def as_dict(self) -> Dict[str, Union[types.InvFinal, types.InvRaw, int]]:
|
||||
return dict(
|
||||
active=self.active, final=self.final, boosters=self.boosters, raw=self.raw, offers=self.offers, total=self.total, used=self.used
|
||||
active=self.active,
|
||||
final=self.final,
|
||||
boosters=self.boosters,
|
||||
raw=self.raw,
|
||||
offers=self.offers,
|
||||
total=self.total,
|
||||
used=self.used,
|
||||
)
|
||||
|
@ -182,7 +182,14 @@ def slugify(value, allow_unicode=False) -> str:
|
||||
|
||||
|
||||
def calculate_hit(
|
||||
strength: float, rang: int, tp: bool, elite: bool, ne: bool, booster: int = 0, weapon: int = 200, is_deploy: bool = False
|
||||
strength: float,
|
||||
rang: int,
|
||||
tp: bool,
|
||||
elite: bool,
|
||||
ne: bool,
|
||||
booster: int = 0,
|
||||
weapon: int = 200,
|
||||
is_deploy: bool = False,
|
||||
) -> Decimal:
|
||||
dec = 3 if is_deploy else 0
|
||||
base_str = 1 + Decimal(str(round(strength, 3))) / 400
|
||||
@ -217,7 +224,12 @@ def get_air_hit_dmg_value(
|
||||
|
||||
|
||||
def get_final_hit_dmg(
|
||||
base_dmg: Union[Decimal, float, str], rang: int, tp: bool = False, elite: bool = False, ne: bool = False, booster: int = 0
|
||||
base_dmg: Union[Decimal, float, str],
|
||||
rang: int,
|
||||
tp: bool = False,
|
||||
elite: bool = False,
|
||||
ne: bool = False,
|
||||
booster: int = 0,
|
||||
) -> Decimal:
|
||||
dmg = Decimal(str(base_dmg))
|
||||
|
||||
@ -313,7 +325,11 @@ class ErepublikJSONEncoder(json.JSONEncoder):
|
||||
return dict(__type__="date", date=o.strftime("%Y-%m-%d"))
|
||||
elif isinstance(o, datetime.timedelta):
|
||||
return dict(
|
||||
__type__="timedelta", days=o.days, seconds=o.seconds, microseconds=o.microseconds, total_seconds=o.total_seconds()
|
||||
__type__="timedelta",
|
||||
days=o.days,
|
||||
seconds=o.seconds,
|
||||
microseconds=o.microseconds,
|
||||
total_seconds=o.total_seconds(),
|
||||
)
|
||||
elif isinstance(o, Response):
|
||||
return dict(headers=dict(o.__dict__["headers"]), url=o.url, text=o.text, status_code=o.status_code)
|
||||
|
@ -60,7 +60,9 @@ def main():
|
||||
player.write_log("Doing task: Work as manager")
|
||||
success = player.work_as_manager()
|
||||
if success:
|
||||
next_time = utils.good_timedelta(now.replace(hour=14, minute=0, second=0, microsecond=0), timedelta(days=1))
|
||||
next_time = utils.good_timedelta(
|
||||
now.replace(hour=14, minute=0, second=0, microsecond=0), timedelta(days=1)
|
||||
)
|
||||
else:
|
||||
next_time = utils.good_timedelta(now.replace(second=0, microsecond=0), timedelta(minutes=30))
|
||||
|
||||
@ -86,7 +88,9 @@ def main():
|
||||
if sleep_seconds <= 0:
|
||||
player.write_log(f"Loop detected! Offending task: '{next_tasks[0]}'")
|
||||
player.write_log("My next Tasks and there time:\n" + "\n".join(sorted(next_tasks)))
|
||||
player.write_log(f"Sleeping until (eRep): {closest_next_time.strftime('%F %T')}" f" (sleeping for {sleep_seconds}s)")
|
||||
player.write_log(
|
||||
f"Sleeping until (eRep): {closest_next_time.strftime('%F %T')}" f" (sleeping for {sleep_seconds}s)"
|
||||
)
|
||||
seconds_to_sleep = sleep_seconds if sleep_seconds > 0 else 0
|
||||
player.sleep(seconds_to_sleep)
|
||||
except Exception as e:
|
||||
|
@ -1,4 +1,11 @@
|
||||
[tool.black]
|
||||
line-length = 140
|
||||
line-length = 120
|
||||
target-version = ['py38', 'py39']
|
||||
extend-exclude = 'venv'
|
||||
workers = 4
|
||||
|
||||
|
||||
[tool.isort]
|
||||
profile = "black"
|
||||
multi_line_output = 3
|
||||
line_length = 120
|
||||
|
4
setup.py
4
setup.py
@ -19,7 +19,9 @@ setup_requirements = []
|
||||
|
||||
with open("requirements-tests.txt") as test_req_file:
|
||||
test_requirements = test_req_file.read()
|
||||
test_requirements = [line.strip() for line in test_requirements.split() if line.strip()[:2].strip() not in ("#", "-r")]
|
||||
test_requirements = [
|
||||
line.strip() for line in test_requirements.split() if line.strip()[:2].strip() not in ("#", "-r")
|
||||
]
|
||||
|
||||
setup(
|
||||
author="Eriks Karls",
|
||||
|
Reference in New Issue
Block a user