Files
aoe2-flashcard-creator/example-fighting.py
Nate Bowman ec3eb15731 Simplify running more than one fight at a time
This still requires too much manual work, so I probably will change
things up again, but I wanted to have a record just in case.
2026-10-18 17:44:17 -04:00

62 lines
2.3 KiB
Python

import itertools
from flashcards.constants import UnitLines, ranges
from flashcards.maps import (create_maps,
read_data_to_dict,
read_name_data_to_dict)
from flashcards.fighting import (generate_all_combinations,
generate_fight_results_from_names)
# --- General section to read in names and data
# specify the namelist to be used to create the deck
# give the relative path of the file from config.namelists_dir
namelist = 'units-buildings-trimmed.txt'
# key into json file specifying which data you want
name_json_keys = 'units_buildings'
data_json_keys = ('data', 'Unit')
# --- Fight details start here
attacker_line = 'Spearman'
defender_line = 'Knight'
#defender_line = 'Scout Cavalry'
range_type = 'standard'
# extra bonuses beyond the usual blacksmith upgrades and bloodlines
hp_bonus_names = []
attack_bonus_names = []
armor_bonus_names = []
# --- Shouldn't need to change below this line
_, nums = create_maps(namelist, name_json_keys)
data = read_data_to_dict(data_json_keys)
attack_type = UnitLines.get_attack(attacker_line)
bonus_range = ranges[attack_type][range_type]
built_in_hp_bonus_names = UnitLines.get_hp_bonus_names(defender_line)
all_hp_bonus_names = hp_bonus_names + built_in_hp_bonus_names
bonus_names_combinations = generate_all_combinations(attack_bonus_names,
armor_bonus_names,
all_hp_bonus_names)
for attacker, defender in itertools.product(UnitLines.get_names(attacker_line),
UnitLines.get_names(defender_line)):
for combo in bonus_names_combinations:
results = generate_fight_results_from_names(attacker,
defender,
attack_type,
bonus_range,
data,
nums,
combo[0],
combo[1],
combo[2],
True)
print(results)