41 lines
1.0 KiB
Python
41 lines
1.0 KiB
Python
from flashcards.decks import create_deck
|
|
from flashcards.maps import (create_maps,
|
|
read_data_to_dict)
|
|
|
|
|
|
|
|
# your choice of deck name and filename
|
|
deck_name = 'Unit Upgrades'
|
|
deck_fname = 'unit-upgrades'
|
|
|
|
# key into json file specifying which data you want
|
|
data_json_keys = ('data', 'unit_upgrades',)
|
|
|
|
# --- create list of notes ---
|
|
|
|
data = read_data_to_dict(data_json_keys)
|
|
|
|
# create cards based on data and maps
|
|
order = ['Wood', 'Food', 'Gold', 'Stone']
|
|
notes = []
|
|
completed = set()
|
|
for d in data.values():
|
|
front = d['internal_name']
|
|
|
|
if front not in completed:
|
|
completed.add(front)
|
|
|
|
cost = d['Cost']
|
|
all_cost = '\n'.join([f'{k}: {cost[k]}' for k in order
|
|
if k in cost.keys() and cost[k] != 0])
|
|
|
|
time_text = f'Research time: {d["ResearchTime"]}'
|
|
|
|
back = '\n\n'.join([all_cost, time_text])
|
|
|
|
notes.append((front, back))
|
|
#print(f'front: {front}\tback: {back}')
|
|
|
|
# write deck to .apkg file
|
|
deck = create_deck(notes, deck_name, deck_fname)
|