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

28
decks/building-costs.py Normal file
View File

@@ -0,0 +1,28 @@
from flashcards.decks import create_deck_from_back_function
# your choice of deck name and filename
deck_name = 'Building Costs'
deck_fname = 'building-costs'
# specify the namelist to be used to create the deck
# give the relative path of the file from config.namelists_dir
namelist = 'buildings.txt'
# key into json file specifying which data you want
# uncomment either 'units_buildings' or 'techs'
data_json_key = 'units_buildings'
#data_json_key = 'techs'
def card_back(num, name, data):
cost = data[num]['cost']
back = '\n'.join([f'{res}: {val}' for res, val in cost.items()
if val != 0])
return back
create_deck_from_back_function(namelist,
data_json_key,
card_back,
deck_name,
deck_fname)