55 lines
1.7 KiB
Python
55 lines
1.7 KiB
Python
from flashcards.decks import create_deck
|
|
from flashcards.helpers import parse_research_string
|
|
from flashcards.maps import (create_maps,
|
|
read_data_to_dict,
|
|
read_name_data_to_dict,
|
|
read_string_data_to_dict)
|
|
|
|
|
|
|
|
# your choice of deck name and filename
|
|
deck_name = 'Research (Non-Unique)'
|
|
deck_fname = 'research-non-unique'
|
|
|
|
# specify the namelist to be used to create the deck
|
|
# give the relative path of the file from config.namelists_dir
|
|
namelist = 'research-non-unique.txt'
|
|
|
|
# key into json file specifying which data you want
|
|
name_json_keys = 'techs'
|
|
data_json_keys = ('data', 'Tech',)
|
|
string_json_keys = ()
|
|
|
|
# --- create list of notes ---
|
|
|
|
_, nums = create_maps(namelist, name_json_keys)
|
|
data = read_data_to_dict(data_json_keys)
|
|
names = read_name_data_to_dict(name_json_keys)
|
|
strings = read_string_data_to_dict(string_json_keys)
|
|
|
|
# create cards based on data and maps
|
|
order = ['Wood', 'Food', 'Gold', 'Stone']
|
|
notes = []
|
|
for name, num in nums.items():
|
|
front = name
|
|
|
|
cost = data[num]['Cost']
|
|
# works, but puts wood in the wrong order (i.e., after food)
|
|
#all_cost = '\n'.join([f'{res}: {val}' for res, val in cost.items()
|
|
#if val != 0])
|
|
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: {data[num]["ResearchTime"]}'
|
|
|
|
help_id = str(names[num]['help_converter'])
|
|
help_text = parse_research_string(strings[help_id])
|
|
|
|
back = '\n\n'.join([all_cost, time_text, help_text])
|
|
|
|
notes.append((front, back))
|
|
#print(f'front: {name}\tback: {back}')
|
|
|
|
# write deck to .apkg file
|
|
deck = create_deck(notes, deck_name, deck_fname)
|