Make running fights easier
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
from flashcards.maps import (create_maps,
|
||||
read_data_to_dict,
|
||||
read_name_data_to_dict,
|
||||
read_string_data_to_dict)
|
||||
from flashcards.fighting import (calculate_hits_to_kill,
|
||||
generate_bonus_with_value)
|
||||
from flashcards.types import ArmorClasses
|
||||
read_name_data_to_dict)
|
||||
from flashcards.fighting import (generate_fight_results,
|
||||
get_bonuses_from_names)
|
||||
from flashcards.types import ArmorClasses, BonusTypes
|
||||
|
||||
|
||||
|
||||
# --- 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'
|
||||
@@ -15,39 +16,40 @@ namelist = 'units-buildings-trimmed.txt'
|
||||
# key into json file specifying which data you want
|
||||
name_json_keys = 'units_buildings'
|
||||
data_json_keys = ('data', 'Unit')
|
||||
string_json_keys = ()
|
||||
|
||||
#name_data = read_name_data_to_dict(string_json_keys)
|
||||
_, nums = create_maps(namelist, name_json_keys)
|
||||
data = read_data_to_dict(data_json_keys)
|
||||
|
||||
# --- Fight details start here
|
||||
|
||||
attacker = 'Spearman'
|
||||
defender = 'Scout Cavalry'
|
||||
bloodlines = False
|
||||
bonus_range = range(-3, 5)
|
||||
armor_class = ArmorClasses.MELEE
|
||||
notes = 'with Bloodlines'
|
||||
suffix = ''
|
||||
|
||||
print(f'{attacker} attacking {defender} with bloodlines={bloodlines}')
|
||||
print('--------------------------------')
|
||||
hp_bonus_names = ['Bloodlines']
|
||||
attack_bonus_names = []
|
||||
armor_bonus_names = []
|
||||
|
||||
for i in range(-3, 5):
|
||||
attack_bonuses = []
|
||||
armor_bonuses = []
|
||||
hp_bonuses = []
|
||||
# --- You shouldn't need to change below this line
|
||||
|
||||
b = generate_bonus_with_value(abs(i), ArmorClasses.MELEE)
|
||||
if i < 0:
|
||||
armor_bonuses.append(b)
|
||||
else:
|
||||
attack_bonuses.append(b)
|
||||
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)
|
||||
|
||||
if bloodlines:
|
||||
bloodlines_bonus = generate_bonus_with_value(20, ArmorClasses.HP)
|
||||
hp_bonuses.append(bloodlines_bonus)
|
||||
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)
|
||||
|
||||
hits = calculate_hits_to_kill(attacker,
|
||||
defender,
|
||||
data,
|
||||
nums,
|
||||
attack_bonuses=attack_bonuses,
|
||||
armor_bonuses=armor_bonuses,
|
||||
hp_bonuses=hp_bonuses)
|
||||
print(f'Net attack bonus: {i}\thits: {hits}')
|
||||
# --- TODO write file
|
||||
print(results)
|
||||
|
||||
Reference in New Issue
Block a user