Example #1
0
def load(game: str):
    with open(os.path.join('craftingLists', game + '.yaml')) as f:
        data = yaml.safe_load(f)

    tree = Tree()

    for r in data.get('recipes'):
        inputs = [ItemStack.from_data(i) for i in r.get('inputs', [])]
        outputs = [ItemStack.from_data(i) for i in r.get('outputs', [])]
        dependencies = r.get('dependencies', [])
        tools = [Tool.from_data(t) for t in r.get('tools', [])]
        recipe = Recipe(inputs, outputs, dependencies, tools)
        tree.add_recipe(recipe)
        for tool in tools:
            tree.crafting_methods.append(CraftingMethod(recipe, tool))

    print(tree)