Created
November 27, 2018 15:21
-
-
Save LokiSharp/fbeda414668cfd59b29b37008c52c000 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
LAND_COMBAT_ORG_DICE_SIZE = 4 | |
LAND_COMBAT_STR_DICE_SIZE = 2 | |
LAND_COMBAT_ORG_ARMOR_ON_SOFT_DICE_SIZE = 6 | |
LAND_COMBAT_STR_ARMOR_ON_SOFT_DICE_SIZE = 2 | |
LAND_COMBAT_STR_DAMAGE_MODIFIER = 0.05 | |
LAND_COMBAT_ORG_DAMAGE_MODIFIER = 0.05 | |
LAND_COMBAT_STR_ARMOR_DEFLECTION_FACTOR = 0.5 | |
LAND_COMBAT_ORG_ARMOR_DEFLECTION_FACTOR = 0.5 | |
BASE_CHANCE_TO_AVOID_HIT = 90 | |
CHANCE_TO_AVOID_HIT_AT_NO_DEF = 60 | |
armor_list = ['medium_armor'] | |
d1 = { | |
'Armor': 1000, | |
'Breakthrough': 122.2, | |
'Defense': 602.2, | |
'HP': 282.8, | |
'Hard attack': 200, | |
'Hardness': 0.0, | |
'Organisation': 35, | |
'Piercing': 8.9, | |
'Priority': {'artillery': 0, 'medium_armo': 12000}, | |
'Soft attack': 1000, | |
} | |
d2 = { | |
'Armor': 52.4, | |
'Breakthrough': 451.8, | |
'Defense': 500, | |
'HP': 169.8, | |
'Hard attack': 174.8, | |
'Hardness': 0.7, | |
'Organisation': 21, | |
'Piercing': 51.1, | |
'Priority': {'artillery': 0, 'medium_armor': 25788}, | |
'Soft attack': 560.1, | |
} | |
def get_damage_of_avoid_hit(dice_size, chance_to_avoid_hit): | |
return (1 + dice_size) / 2 * (100 - chance_to_avoid_hit) / 100 * LAND_COMBAT_ORG_DAMAGE_MODIFIER | |
def get_hits(sa_or_ha: int, def_or_bt: int) -> (int, int): | |
hit_at_def = 0 | |
hit_at_no_def = 0 | |
if sa_or_ha <= def_or_bt: | |
hit_at_def = sa_or_ha | |
hit_at_no_def = 0 | |
elif sa_or_ha > def_or_bt: | |
hit_at_def = def_or_bt | |
hit_at_no_def = sa_or_ha - def_or_bt | |
return round(hit_at_def), round(hit_at_no_def) | |
def sum_for_result_with_func(func, *avgs, n: int): | |
_list = [] | |
for i in range(n): | |
_list.append(func(*avgs)) | |
result = sum(_list) | |
return result | |
def calc_damage(a, b): | |
atk_sa = a['Soft attack'] | |
atk_ha = a['Hard attack'] | |
def_ = b['Defense'] | |
a_division_type = max(a['Priority'], key=a['Priority'].get) | |
b_division_type = max(b['Priority'], key=b['Priority'].get) | |
org_soft_dice_size = LAND_COMBAT_ORG_DICE_SIZE | |
org_hard_dice_size = LAND_COMBAT_ORG_DICE_SIZE | |
if a_division_type in armor_list and a['Armor'] > b['Piercing']: | |
org_soft_dice_size = LAND_COMBAT_ORG_ARMOR_ON_SOFT_DICE_SIZE | |
org_chance_to_avoid_hit_at_def = BASE_CHANCE_TO_AVOID_HIT | |
org_chance_to_avoid_hit_at_no_def = CHANCE_TO_AVOID_HIT_AT_NO_DEF | |
soft_hits = round(atk_sa * (1 - b['Hardness'])) | |
hard_hits = round(atk_ha * b['Hardness']) | |
total_hits = soft_hits + hard_hits | |
hits_at_def, hits_at_no_def = get_hits(total_hits, round(def_)) | |
soft_hits_at_def = round(hits_at_def / total_hits * soft_hits) | |
hard_hits_at_def = round(hits_at_def / total_hits * hard_hits) | |
soft_hits_at_no_def = round(hits_at_no_def / total_hits * soft_hits) | |
hard_hits_at_no_def = round(hits_at_no_def / total_hits * hard_hits) | |
org_soft_damage_at_def = sum_for_result_with_func(get_damage_of_avoid_hit, | |
org_soft_dice_size, | |
org_chance_to_avoid_hit_at_def, | |
n=soft_hits_at_def) | |
org_hard_damage_at_def = sum_for_result_with_func(get_damage_of_avoid_hit, | |
org_hard_dice_size, | |
org_chance_to_avoid_hit_at_def, | |
n=hard_hits_at_def) | |
org_soft_damage_at_no_def = sum_for_result_with_func(get_damage_of_avoid_hit, | |
org_soft_dice_size, | |
org_chance_to_avoid_hit_at_no_def, | |
n=soft_hits_at_no_def) | |
org_hard_damage_at_no_def = sum_for_result_with_func(get_damage_of_avoid_hit, | |
org_hard_dice_size, | |
org_chance_to_avoid_hit_at_no_def, | |
n=hard_hits_at_no_def) | |
org_damage = org_soft_damage_at_def + org_hard_damage_at_def + org_soft_damage_at_no_def + org_hard_damage_at_no_def | |
print(hits_at_def, hits_at_no_def) | |
print(a_division_type, a['Soft attack'], a['Hard attack'], b['Defense']) | |
print(b_division_type, b['Soft attack'], b['Hard attack'], a['Breakthrough']) | |
print(org_damage) | |
if __name__ == '__main__': | |
calc_damage(d1, d2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment