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.
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
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_fight_results,
|
||||
get_bonuses_from_names)
|
||||
from flashcards.types import ArmorClasses, BonusTypes
|
||||
from flashcards.fighting import (generate_all_combinations,
|
||||
generate_fight_results_from_names)
|
||||
|
||||
|
||||
|
||||
@@ -17,39 +19,43 @@ namelist = 'units-buildings-trimmed.txt'
|
||||
name_json_keys = 'units_buildings'
|
||||
data_json_keys = ('data', 'Unit')
|
||||
|
||||
_, nums = create_maps(namelist, name_json_keys)
|
||||
data = read_data_to_dict(data_json_keys)
|
||||
|
||||
# --- Fight details start here
|
||||
|
||||
attacker = 'Spearman'
|
||||
defender = 'Scout Cavalry'
|
||||
bonus_range = range(-3, 5)
|
||||
armor_class = ArmorClasses.MELEE
|
||||
notes = 'with Bloodlines'
|
||||
suffix = ''
|
||||
attacker_line = 'Spearman'
|
||||
defender_line = 'Knight'
|
||||
#defender_line = 'Scout Cavalry'
|
||||
range_type = 'standard'
|
||||
|
||||
hp_bonus_names = ['Bloodlines']
|
||||
# extra bonuses beyond the usual blacksmith upgrades and bloodlines
|
||||
hp_bonus_names = []
|
||||
attack_bonus_names = []
|
||||
armor_bonus_names = []
|
||||
|
||||
# --- You shouldn't need to change below this line
|
||||
# --- Shouldn't need to change below this line
|
||||
|
||||
hp_bonuses = get_bonuses_from_names(BonusTypes.HP, hp_bonus_names)
|
||||
attack_bonuses = get_bonuses_from_names(BonusTypes.ATTACK, attack_bonus_names)
|
||||
armor_bonuses = get_bonuses_from_names(BonusTypes.ARMOR, armor_bonus_names)
|
||||
_, nums = create_maps(namelist, name_json_keys)
|
||||
data = read_data_to_dict(data_json_keys)
|
||||
|
||||
results = generate_fight_results(attacker,
|
||||
defender,
|
||||
armor_class,
|
||||
bonus_range,
|
||||
data,
|
||||
nums,
|
||||
notes=notes,
|
||||
extra_attack_bonuses=attack_bonuses,
|
||||
extra_armor_bonuses=armor_bonuses,
|
||||
hp_bonuses=hp_bonuses,
|
||||
verbose=True)
|
||||
attack_type = UnitLines.get_attack(attacker_line)
|
||||
bonus_range = ranges[attack_type][range_type]
|
||||
|
||||
# --- TODO write file
|
||||
print(results)
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user