Damage calculation

This commit is contained in:
Eriks Karls 2019-10-16 15:09:28 +03:00
parent d548d1bbf1
commit 3d895bd085
2 changed files with 16 additions and 16 deletions

View File

@ -1957,13 +1957,7 @@ class Citizen(classes.CitizenAPI):
if ne: if ne:
tp = True tp = True
dmg = int(10 * (1 + strength / 400) * (1 + rang / 5) * 3) return utils.calculate_hit(strength, rang, tp, elite, ne, 50 if booster_50 else 100 if booster_100 else 0)
booster = 1.5 if booster_50 else 2 if booster_100 else 1
elite = 1.1 if elite else 1
dmg = int(dmg * booster * elite)
legend = 1 if (not tp or rang < 70) else 1 + (rang - 69) / 10
dmg = int(dmg * legend)
return dmg * (1.1 if ne else 1)
def get_air_hit_dmg_value(self, rang: int = None, elite: bool = None, ne: bool = False, def get_air_hit_dmg_value(self, rang: int = None, elite: bool = None, ne: bool = False,
weapon: bool = False) -> float: weapon: bool = False) -> float:
@ -1974,10 +1968,7 @@ class Citizen(classes.CitizenAPI):
if elite is None: if elite is None:
elite = r['citizenAttributes']['level'] > 100 elite = r['citizenAttributes']['level'] > 100
dmg = int(10 * (1 + rang / 5) * (1.2 if weapon else 1)) return utils.calculate_hit(0, rang, True, elite, ne, 0, 20 if weapon else 0)
elite = 1.1 if elite else 1
dmg = int(dmg * elite)
return dmg * (1.1 if ne else 1.)
def endorse_article(self, article_id: int, amount: int) -> bool: def endorse_article(self, article_id: int, amount: int) -> bool:
if amount in (5, 50, 100): if amount in (5, 50, 100):

View File

@ -336,12 +336,21 @@ def slugify(value, allow_unicode=False) -> str:
def calculate_hit(strength: float, rang: int, tp: bool, elite: bool, ne: bool, booster: int = 0, def calculate_hit(strength: float, rang: int, tp: bool, elite: bool, ne: bool, booster: int = 0,
weapon: int = 200) -> float: weapon: int = 200) -> float:
dmg = int(10 * (1 + strength / 400) * (1 + rang / 5) * (1 + weapon / 100)) base_dmg = 10 * (1 + strength / 400) * (1 + rang / 5) * (1 + weapon / 100)
elite = 1.1 if elite else 1 dmg = int(base_dmg * 10 + 5) // 10
booster_multiplier = (100 + booster) / 100 booster_multiplier = (100 + booster) / 100
dmg = int(dmg * booster_multiplier * elite) booster_dmg = dmg * booster_multiplier
dmg = int(booster_dmg * 10 + 5) // 10
elite = 1.1 if elite else 1
elite_dmg = dmg * elite
dmg = int(elite_dmg)
legend = 1 if (not tp or rang < 70) else 1 + (rang - 69) / 10 legend = 1 if (not tp or rang < 70) else 1 + (rang - 69) / 10
dmg = int(dmg * legend) legend_dmg = dmg * legend
dmg = int(legend_dmg)
return dmg * (1.1 if ne else 1) return dmg * (1.1 if ne else 1)
@ -360,6 +369,6 @@ def ground_hit_dmg_value(citizen_id: int, natural_enemy: bool = False, true_patr
def air_hit_dmg_value(citizen_id: int, natural_enemy: bool = False, true_patriot: bool = False, booster: int = 0, def air_hit_dmg_value(citizen_id: int, natural_enemy: bool = False, true_patriot: bool = False, booster: int = 0,
weapon_power: int = 0) -> float: weapon_power: int = 0) -> float:
r = requests.get(f"https://www.erepublik.com/en/main/citizen-profile-json/{citizen_id}").json() r = requests.get(f"https://www.erepublik.com/en/main/citizen-profile-json/{citizen_id}").json()
rang = r['military']['militaryData']['air']['rankNumber'] rang = r['military']['militaryData']['aircraft']['rankNumber']
elite = r['citizenAttributes']['level'] > 100 elite = r['citizenAttributes']['level'] > 100
return calculate_hit(0, rang, true_patriot, elite, natural_enemy, booster, weapon_power) return calculate_hit(0, rang, true_patriot, elite, natural_enemy, booster, weapon_power)