Last active
November 30, 2018 06:42
-
-
Save LokiSharp/849000c48c91d3d7a38f9e36cab4e27c 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
from src.division_builder.division_builder import LandDivisionBuilder | |
from src.land_warfare.land_warfare_calc import calc_damage | |
from src.division_builder.technologies import technologies, equipments | |
from src.utils import round_util, round_sum, round_min, round_max | |
builder = LandDivisionBuilder("data/") | |
division_template_dict1 = { | |
'name': 'Test-Division_01 11I 6A', | |
'division_names_group': 'Test_Arm_01', | |
'regiments': ['infantry'] * 11 + ['artillery_brigade'] * 6, | |
'supports': ['engineer', 'recon', 'artillery', 'anti_air', 'anti_tank'], | |
'equipments': equipments, | |
'technologies': technologies, | |
} | |
division_template_dict2 = { | |
'name': 'Test-Division_02 8MI 6SHT 4SHSP', | |
'division_names_group': 'Test_Arm_02', | |
'regiments': ['mechanized'] * 8 + ['super_heavy_armor'] * 6 + ['super_heavy_sp_artillery_brigade'] * 4, | |
'supports': ['engineer', 'recon', 'artillery', 'anti_air', 'anti_tank'], | |
'equipments': equipments, | |
'technologies': technologies, | |
} | |
division_template_dict3 = { | |
'name': 'Test-Division_03 25I', | |
'division_names_group': 'Test_Arm_03', | |
'regiments': ['infantry'] * 25, | |
'supports': ['engineer', 'recon', 'artillery', 'anti_air', 'anti_tank'], | |
'equipments': equipments, | |
'technologies': technologies, | |
} | |
division_template_dict4 = { | |
'name': 'Test-Division_02 8MI 6MODT 4MODSP', | |
'division_names_group': 'Test_Arm_02', | |
'regiments': ['mechanized'] * 8 + ['modern_armor'] * 6 + ['modern_sp_artillery_brigade'] * 4, | |
'supports': ['engineer', 'recon', 'artillery', 'anti_air', 'anti_tank'], | |
'equipments': equipments, | |
'technologies': technologies, | |
} | |
division_template_dict5 = { | |
'name': 'Test-Division_05 11I 5A 1HTD', | |
'division_names_group': 'Test_Arm_05', | |
'regiments': ['infantry'] * 11 + ['artillery_brigade'] * 5 + ['heavy_tank_destroyer_brigade'] * 1, | |
'supports': ['engineer', 'recon', 'artillery', 'anti_air', 'anti_tank'], | |
'equipments': equipments, | |
'technologies': technologies, | |
} | |
division_1 = builder.calculate_stats(division_template_dict1) | |
division_2 = builder.calculate_stats(division_template_dict2) | |
division_3 = builder.calculate_stats(division_template_dict3) | |
division_4 = builder.calculate_stats(division_template_dict4) | |
division_5 = builder.calculate_stats(division_template_dict5) | |
print(division_1) | |
print(division_2) | |
print(division_3) | |
print(division_4) | |
print(division_5) | |
round_degree = 2 | |
test_temp = { | |
"Name": "test_temp", | |
"Division Names Group": "Test_Arm_02", | |
"Organisation": 10, | |
"HP": 10, | |
"Soft attack": 10, | |
"Hard attack": 10, | |
"Defense": 0, | |
"Breakthrough": 0, | |
"Armor": 0, | |
"Piercing": 0, | |
"Combat Width": 10, | |
"Hardness": 0, | |
} | |
def print_result(result_1, result_2): | |
print( | |
f"Attack Damage: " | |
f"Total: {round_sum(result_1):.2f} " | |
f"Avg: {round_util(sum(result_1) / len(result_1)):.2f} " | |
f"Max: {round_max(result_1):.2f} " | |
f"Min: {round_min(result_1):.2f}" | |
) | |
print( | |
f"Back Damage: " | |
f"Total: {round_sum(result_2):.2f} " | |
f"Avg: {round_util(sum(result_2) / len(result_2)):.2f} " | |
f"Max: {round_max(result_2):.2f} " | |
f"Min: {round_min(result_2):.2f}" | |
) | |
def print_division_stats(division): | |
print(f"Combat Width: {division['Combat Width']:.2f} " | |
f"HP: {division['HP']:.2f} " | |
f"Organisation: {division['Organisation']:.2f} " | |
f"Soft attack: {division['Soft attack']:.2f} " | |
f"Hard attack: {division['Hard attack']:.2f} " | |
f"Defense: {division['Defense']:.2f} " | |
f"Breakthrough: {division['Breakthrough']:.2f} " | |
f"Armor: {division['Armor']:.2f} " | |
f"Piercing: {division['Piercing']:.2f} " | |
f"Hardness: {division['Hardness']:.2f} ") | |
def cal_range(division_1, division_2): | |
division_a = division_1.copy() | |
division_b = division_2.copy() | |
print(f"Attacker: ") | |
print_division_stats(division_a) | |
print(f"Defender: ") | |
print_division_stats(division_b) | |
org_damage_l = [] | |
org_back_damage_l = [] | |
str_damage_l = [] | |
str_back_damage_l = [] | |
battle_round = 0 | |
while division_a['Organisation'] > 0 and division_b['Organisation'] > 0: | |
battle_round += 1 | |
print(f'Round {battle_round}: ') | |
if division_a['Organisation'] > 0: | |
org_damage, str_damage = calc_damage(division_a, division_b, 'Defense') | |
division_b['Organisation'] = division_b['Organisation'] - org_damage | |
division_b['HP'] = division_b['HP'] - str_damage | |
org_damage_l.append(round_util(org_damage)) | |
str_damage_l.append(round_util(str_damage)) | |
print(f"Defender: Organisation: {org_damage:.2f}({(org_damage/division_2['Organisation']*100):.2f}%) HP: {str_damage:.2f}({(str_damage/division_2['HP']*100):.2f}%)") | |
if division_b['Organisation'] > 0: | |
org_back_damage, str_back_damage = calc_damage(division_b, division_a, 'Breakthrough') | |
division_a['Organisation'] = division_a['Organisation'] - org_back_damage | |
division_a['HP'] = division_a['HP'] - str_back_damage | |
org_back_damage_l.append(round_util(org_back_damage)) | |
str_back_damage_l.append(round_util(str_back_damage)) | |
print(f"Attacker: Organisation: {org_back_damage:.2f}({(org_back_damage/division_1['Organisation']*100):.2f}%) HP: {str_back_damage:.2f}({(str_back_damage/division_1['HP']*100):.2f}%)") | |
print('Combat settlement') | |
print('Organisation: ') | |
print_result(org_damage_l, org_back_damage_l) | |
print('HP: ') | |
print_result(str_damage_l, str_back_damage_l) | |
print(f"Fighting Round {len(org_damage_l)} Fighting Back Round {len(org_back_damage_l)}") | |
print(f"Attacker Organisation {division_a['Organisation']:.2f} Defender Organisation {division_b['Organisation']:.2f}") | |
print(f"Attacker HP: {division_a['HP']:.2f} Defender HP: {division_b['HP']:.2f}") | |
if division_a['Organisation'] > division_b['Organisation']: | |
print('Attacker Win') | |
else: | |
print('Defender Win') | |
if __name__ == '__main__': | |
division_b = test_temp.copy() | |
division_list_a = [division_1] | |
division_list_b = [division_1, division_2, division_3, division_4, division_5] | |
for a in division_list_a: | |
for b in division_list_b: | |
print("=" * 40, f"{a['Name']} vs {b['Name']}", "=" * 40) | |
cal_range(a, b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment