Add examples of deck scripts and namelists

This commit is contained in:
Nate Bowman
2026-11-21 14:49:53 -05:00
parent 6d05bfa7d5
commit a586357cc0
18 changed files with 1506 additions and 1 deletions

View File

@@ -0,0 +1,44 @@
from flashcards.decks import create_deck
from fighting.fighting import Fighting
from flashcards.maps import (create_maps,
read_data_to_dict)
# your choice of deck name and filename
deck_name = 'Fighting (Units, Non-Unique)'
deck_fname = 'fighting-non-unique-units'
# specify the namelist to be used to create the deck
# give the relative path of the file from config.namelists_dir
namelist = 'units-non-unique.txt'
# key into json file specifying which data you want
name_json_keys = 'units_buildings'
data_json_keys = ('data', 'Unit')
# --- create list of notes ---
_, nums = create_maps(namelist, name_json_keys)
data = read_data_to_dict(data_json_keys)
fight = Fighting(data, nums)
results = fight.generate_all_fight_results()
# create cards based on data and maps
notes = []
for k, v in results.items():
attacker, defender = k
title = f'{attacker} attacking {defender}'
for fight in v:
front = '\n'.join([title, fight['notes']])
hits = [f'{bonus}: {hit}' for bonus, hit in fight['hits'].items()]
back = '\n'.join(hits)
notes.append((front, back))
#print(f'front: {front}\tback: {back}')
# write deck to .apkg file
deck = create_deck(notes, deck_name, deck_fname)