recipes: pull type and machine variables out of the recipe list

This commit is contained in:
Danny Robson 2019-04-28 11:03:27 +10:00
parent 79df7638a8
commit 14fe028fe1
44 changed files with 844 additions and 500 deletions

View File

@ -1,12 +1,21 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "circuit_board": 1, "quickwire": 18 }, ],
"output": { "ai_limiter": 1 }, "machine": "assembler",
"machine": "assembler", "recipes": [
"crafting_time": 12, {
"clicks": 3, "input": {
"stack_size": 100, "circuit_board": 1,
"requires": "caterium_electronics" "quickwire": 18
} },
] "output": {
"ai_limiter": 1
},
"crafting_time": 12,
"clicks": 3,
"stack_size": 100,
"requires": "caterium_electronics"
}
]
}

View File

@ -1,10 +1,19 @@
[ {
{ "type": [
"type": [ "component", "item" ], "component",
"input": { "wire": 2 }, "item"
"output": { "cable": 1 }, ],
"machine": "constructor", "machine": "constructor",
"crafting_time": 4, "recipes": [
"clicks": 1 {
} "input": {
] "wire": 2
},
"output": {
"cable": 1
},
"crafting_time": 4,
"clicks": 1
}
]
}

View File

@ -1,11 +1,19 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "caterium_ore": 4 }, ],
"output": { "caterium_ingot": 1 }, "machine": "smelter",
"machine": "smelter", "recipes": [
"crafting_time": 4, {
"clicks": 4, "input": {
"requires": "caterium_technology" "caterium_ore": 4
} },
] "output": {
"caterium_ingot": 1
},
"crafting_time": 4,
"clicks": 4,
"requires": "caterium_technology"
}
]
}

View File

@ -1,12 +1,21 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "wire": 12, "plastic": 6 }, ],
"output": { "circuit_board": 1 }, "machine": "assembler",
"machine": "assembler", "stack_size": 100,
"crafting_time": 12, "recipes": [
"clicks": 3, {
"stack_size": 100, "input": {
"stage": "expansion" "wire": 12,
} "plastic": 6
] },
"output": {
"circuit_board": 1
},
"crafting_time": 12,
"clicks": 3,
"stage": "expansion"
}
]
}

View File

@ -1,12 +1,23 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "circuit_board": 5, "cable": 12, "plastic": 18, "screw": 60 }, ],
"output": { "computer": 1 }, "machine": "manufacturer",
"machine": "manufacturer", "stack_size": 50,
"crafting_time": 32, "recipes": [
"clicks": 8, {
"stack_size": 50, "input": {
"stage": "expansion" "circuit_board": 5,
} "cable": 12,
] "plastic": 18,
"screw": 60
},
"output": {
"computer": 1
},
"crafting_time": 32,
"clicks": 8,
"stage": "expansion"
}
]
}

View File

@ -1,11 +1,19 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "limestone": 3 }, ],
"output": { "concrete": 1 }, "machine": "constructor",
"machine": "constructor", "recipes": [
"crafting_time": 4, {
"clicks": 1, "input": {
"requires": "hub_upgrade_2" "limestone": 3
} },
] "output": {
"concrete": 1
},
"crafting_time": 4,
"clicks": 1,
"requires": "hub_upgrade_2"
}
]
}

View File

@ -1,12 +1,20 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "copper_ore": 1 }, ],
"output": { "copper_ingot": 1 }, "machine": "smelter",
"machine": "smelter", "stack_size": 100,
"crafting_time": 2, "recipes": [
"clicks": 2, {
"stack_size": 100, "input": {
"stage": "establishing" "copper_ore": 1
} },
] "output": {
"copper_ingot": 1
},
"crafting_time": 2,
"clicks": 2,
"stage": "establishing"
}
]
}

View File

@ -1,12 +1,21 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "steel_beam": 4, "concrete": 5 }, ],
"output": { "encased_industrial_beam": 1 }, "machine": "assembler",
"machine": "assembler", "stack_size": 100,
"crafting_time": 15, "recipes": [
"clicks": 4, {
"stack_size": 100, "input": {
"stage": "development" "steel_beam": 4,
} "concrete": 5
] },
"output": {
"encased_industrial_beam": 1
},
"crafting_time": 15,
"clicks": 4,
"stage": "development"
}
]
}

View File

@ -1,12 +1,23 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "modular_frame": 5, "steel_pipe": 15, "encased_industrial_beam": 5, "screw": 90 }, ],
"output": { "heavy_modular_frame": 1 }, "machine": "assembler",
"machine": "assembler", "stack_size": 50,
"crafting_time": 30, "recipes": [
"clicks": 8, {
"stack_size": 50, "input": {
"stage": "development" "modular_frame": 5,
} "steel_pipe": 15,
] "encased_industrial_beam": 5,
"screw": 90
},
"output": {
"heavy_modular_frame": 1
},
"crafting_time": 30,
"clicks": 8,
"stage": "development"
}
]
}

View File

@ -1,12 +1,22 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "quickwire": 40, "cable": 10, "plastic": 6 }, ],
"output": { "high_speed_connector": 1 }, "machine": "manufacturer",
"machine": "manufacturer", "stack_size": 100,
"crafting_time": 24, "recipes": [
"clicks": 6, {
"stack_size": 100, "input": {
"requires": "caterium_electronics" "quickwire": 40,
} "cable": 10,
] "plastic": 6
},
"output": {
"high_speed_connector": 1
},
"crafting_time": 24,
"clicks": 6,
"requires": "caterium_electronics"
}
]
}

View File

@ -1,10 +1,18 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "iron_ore": 1 }, ],
"output": { "iron_ingot": 1 }, "machine": "smelter",
"machine": "smelter", "recipes": [
"crafting_time": 2, {
"clicks": 2 "input": {
} "iron_ore": 1
] },
"output": {
"iron_ingot": 1
},
"crafting_time": 2,
"clicks": 2
}
]
}

View File

@ -1,9 +1,17 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "iron_ingot": 2 }, ],
"output": { "iron_plate": 1 }, "recipes": [
"crafting_time": 4, {
"clicks": 1 "input": {
} "iron_ingot": 2
] },
"output": {
"iron_plate": 1
},
"crafting_time": 4,
"clicks": 1
}
]
}

View File

@ -1,10 +1,18 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "iron_ingot": 1 }, ],
"output": { "iron_rod": 1 }, "machine": "constructor",
"machine": "constructor", "recipes": [
"crafting_time": 4, {
"clicks": 1 "input": {
} "iron_ingot": 1
] },
"output": {
"iron_rod": 1
},
"crafting_time": 4,
"clicks": 1
}
]
}

View File

@ -1,12 +1,21 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "reinforced_iron_plate": 3, "iron_rod": 3 }, ],
"output": { "modular_frame": 1 }, "machine": "assembler",
"machine": "assembler", "stack_size": 50,
"crafting_time": 15, "recipes": [
"clicks": 4, {
"stack_size": 50, "input": {
"stage": "establishing" "reinforced_iron_plate": 3,
} "iron_rod": 3
] },
"output": {
"modular_frame": 1
},
"crafting_time": 15,
"clicks": 4,
"stage": "establishing"
}
]
}

View File

@ -1,10 +1,19 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "rotor": 2, "stator": 2 }, ],
"output": { "motor": 1 }, "machine": "assembler",
"machine": "assembler", "recipes": [
"crafting_time": 12, {
"clicks": 3 "input": {
} "rotor": 2,
] "stator": 2
},
"output": {
"motor": 1
},
"crafting_time": 12,
"clicks": 3
}
]
}

View File

@ -1,12 +1,20 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "crude_oil": 4 }, ],
"output": { "plastic": 3 }, "machine": "oil_refinery",
"machine": "oil_refinery", "stack_size": 100,
"crafting_time": 8, "recipes": [
"clicks": 2, {
"stack_size": 100, "input": {
"stage": "expansion" "crude_oil": 4
} },
] "output": {
"plastic": 3
},
"crafting_time": 8,
"clicks": 2,
"stage": "expansion"
}
]
}

View File

@ -1,12 +1,20 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "caterium_ingot": 1 }, ],
"output": { "quickwire": 4 }, "machine": "constructor",
"machine": "constructor", "stack_size": 500,
"crafting_time": 4, "recipes": [
"clicks": 1, {
"stack_size": 500, "input": {
"requires": "caterium_technology" "caterium_ingot": 1
} },
] "output": {
"quickwire": 4
},
"crafting_time": 4,
"clicks": 1,
"requires": "caterium_technology"
}
]
}

View File

@ -1,11 +1,20 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "iron_plate": 4, "screw": 24 }, ],
"output": { "reinforced_iron_plate": 1 }, "machine": "assembler",
"machine": "assembler", "recipes": [
"crafting_time": 12, {
"clicks": 3, "input": {
"requires": "hub_upgrade_2" "iron_plate": 4,
} "screw": 24
] },
"output": {
"reinforced_iron_plate": 1
},
"crafting_time": 12,
"clicks": 3,
"requires": "hub_upgrade_2"
}
]
}

View File

@ -1,12 +1,21 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "iron_rod": 3, "screw": 22 }, ],
"output": { "rotor": 1 }, "machine": "smelter",
"machine": "smelter", "stack_size": 100,
"crafting_time": 10, "recipes": [
"clicks": 3, {
"stack_size": 100, "input": {
"stage": "establishing" "iron_rod": 3,
} "screw": 22
] },
"output": {
"rotor": 1
},
"crafting_time": 10,
"clicks": 3,
"stage": "establishing"
}
]
}

View File

@ -1,12 +1,20 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "crude_oil": 4 }, ],
"output": { "rubber": 4 }, "machine": "oil_refinery",
"machine": "oil_refinery", "stack_size": 100,
"crafting_time": 8, "recipes": [
"clicks": 2, {
"stack_size": 100, "input": {
"stage": "expansion" "crude_oil": 4
} },
] "output": {
"rubber": 4
},
"crafting_time": 8,
"clicks": 2,
"stage": "expansion"
}
]
}

View File

@ -1,11 +1,19 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "iron_rod": 1 }, ],
"output": { "screw": 6 }, "machine": "constructor",
"machine": "constructor", "recipes": [
"crafting_time": 4, {
"clicks": 2, "input": {
"requires": "hub_upgrade_2" "iron_rod": 1
} },
] "output": {
"screw": 6
},
"crafting_time": 4,
"clicks": 2,
"requires": "hub_upgrade_2"
}
]
}

View File

@ -1,10 +1,19 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "steel_pipe": 3, "wire": 10 }, ],
"output": { "stator": 1 }, "recipes": [
"machine": "assembler", {
"crafting_time": 10, "input": {
"clicks": 3 "steel_pipe": 3,
} "wire": 10
] },
"output": {
"stator": 1
},
"machine": "assembler",
"crafting_time": 10,
"clicks": 3
}
]
}

View File

@ -1,11 +1,19 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "steel_ingot": 3 }, ],
"output": { "steel_beam": 1 }, "machine": "constructor",
"machine": "constructor", "stack_size": 100,
"crafting_time": 6, "recipes": [
"clicks": 2, {
"stack_size": 100 "input": {
} "steel_ingot": 3
] },
"output": {
"steel_beam": 1
},
"crafting_time": 6,
"clicks": 2
}
]
}

View File

@ -1,12 +1,21 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "iron_ore": 3, "coal": 3 }, ],
"output": { "steel_ingot": 2 }, "machine": "foundry",
"machine": "foundry", "stack_size": 100,
"crafting_time": 4, "recipes": [
"clicks": 4, {
"stack_size": 100, "input": {
"stage": "development" "iron_ore": 3,
} "coal": 3
] },
"output": {
"steel_ingot": 2
},
"crafting_time": 4,
"clicks": 4,
"stage": "development"
}
]
}

View File

@ -1,12 +1,20 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "steel_ingot": 1 }, ],
"output": { "steel_pipe": 1 }, "machine": "constructor",
"machine": "constructor", "stack_size": 100,
"crafting_time": 4, "recipes": [
"clicks": 1, {
"stack_size": 100, "input": {
"stage": "development" "steel_ingot": 1
} },
] "output": {
"steel_pipe": 1
},
"crafting_time": 4,
"clicks": 1,
"stage": "development"
}
]
}

View File

@ -1,12 +1,23 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "computer": 2, "ai_limiter": 2, "high_speed_connector": 3, "plastic": 21 }, ],
"output": { "supercomputer": 1 }, "machine": "manufacturer",
"machine": "manufacturer", "stack_size": 50,
"crafting_time": 32, "recipes": [
"clicks": 8, {
"stack_size": 50, "input": {
"requires": "advanced_caterium_electronics" "computer": 2,
} "ai_limiter": 2,
] "high_speed_connector": 3,
"plastic": 21
},
"output": {
"supercomputer": 1
},
"crafting_time": 32,
"clicks": 8,
"requires": "advanced_caterium_electronics"
}
]
}

View File

@ -1,12 +1,20 @@
[ {
{ "type": [
"type": [ "component" ], "component"
"input": { "copper_ingot": 1 }, ],
"output": { "wire": 3 }, "machine": "constructor",
"machine": "constructor", "stack_size": 500,
"crafting_time": 4, "recipes": [
"clicks": 1, {
"stack_size": 500, "input": {
"stage": "establishing" "copper_ingot": 1
} },
] "output": {
"wire": 3
},
"crafting_time": 4,
"clicks": 1,
"stage": "establishing"
}
]
}

View File

@ -1,10 +1,24 @@
[ {
{ "type": [
"type": [ "machine" ], "machine"
"input": { "modular_frame": 3, "rotor": 4, "cable": 10 }, ],
"output": { "assembler": 1 }, "machine": "_craft_bench",
"machine": "_craft_bench", "power_usage": 15,
"power_usage": 15, "size": [
"size": [ 11, 14, 8 ] 11,
} 14,
] 8
],
"recipes": [
{
"input": {
"modular_frame": 3,
"rotor": 4,
"cable": 10
},
"output": {
"assembler": 1
}
}
]
}

View File

@ -1,11 +1,24 @@
[ {
{ "type": [
"type": [ "machine" ], "machine"
"input": { "reinforced_iron_plate": 3, "cable": 2 }, ],
"output": { "constructor": 1 }, "machine": "_craft_bench",
"machine": "_craft_bench", "requires": "hub_upgrade_2",
"requires": "hub_upgrade_2", "power_usage": 4,
"power_usage": 4, "size": [
"size": [ 9, 11, 8 ] 9,
} 11,
] 8
],
"recipes": [
{
"input": {
"reinforced_iron_plate": 3,
"cable": 2
},
"output": {
"constructor": 1
}
}
]
}

View File

@ -1,10 +1,25 @@
[ {
{ "type": [
"type": [ "machine" ], "machine"
"input": { "heavy_modular_frame": 2, "motor": 2, "cable": 25, "computer": 3 }, ],
"output": { "manufacturer": 1 }, "machine": "_craft_bench",
"machine": "_craft_bench", "power_usage": 55,
"power_usage": 55, "size": [
"size": [ 20, 22, 12 ] 20,
} 22,
] 12
],
"recipes": [
{
"input": {
"heavy_modular_frame": 2,
"motor": 2,
"cable": 25,
"computer": 3
},
"output": {
"manufacturer": 1
}
}
]
}

View File

@ -1,12 +1,26 @@
[ {
{ "type": [
"type": [ "machine" ], "machine"
"input": { "portable_miner": 1, "iron_rod": 5, "concrete": 5 }, ],
"output": { "miner_mk1": 1 }, "is": "miner",
"is": "miner", "machine": "_craft_bench",
"machine": "_craft_bench", "power_usage": 5,
"power_usage": 5, "size": [
"size": [ 8, 14, 18 ], 8,
"requires": "hub_upgrade_4" 14,
} 18
] ],
"recipes": [
{
"input": {
"portable_miner": 1,
"iron_rod": 5,
"concrete": 5
},
"output": {
"miner_mk1": 1
},
"requires": "hub_upgrade_4"
}
]
}

View File

@ -1,10 +1,24 @@
[ {
{ "type": [
"type": [ "machine" ], "machine"
"input": { "heavy_modular_frame": 2, "motor": 3, "cable": 10 }, ],
"output": { "oil_pump": 1 }, "machine": "_craft_bench",
"machine": "_craft_bench", "power_usage": 40,
"power_usage": 40, "size": [
"size": [ 8, 14, 20 ] 8,
} 14,
] 20
],
"recipes": [
{
"input": {
"heavy_modular_frame": 2,
"motor": 3,
"cable": 10
},
"output": {
"oil_pump": 1
}
}
]
}

View File

@ -1,9 +1,20 @@
[ {
{ "type": [
"type": [ "machine", "item" ], "machine",
"input": { "iron_plate": 4, "wire": 8, "cable": 4 }, "item"
"output": { "portable_miner": 1 }, ],
"machine": "equipment_workshop", "machine": "equipment_workshop",
"requires": "hub_upgrade_1" "recipes": [
} {
] "input": {
"iron_plate": 4,
"wire": 8,
"cable": 4
},
"output": {
"portable_miner": 1
},
"requires": "hub_upgrade_1"
}
]
}

View File

@ -1,10 +1,19 @@
[ {
{ "type": [
"type": [ "machine" ], "machine"
"input": { "iron_rod": 5, "wire": 8 }, ],
"output": { "smelter": 1 }, "machine": "_craft_bench",
"machine": "_craft_bench", "power_usage": 4,
"power_usage": 4, "recipes": [
"size": [ 6, 10, 10 ] {
} "input": {
] "iron_rod": 5,
"wire": 8
},
"output": {
"smelter": 1
},
"size": [ 6, 10, 10 ]
}
]
}

View File

@ -1,11 +1,14 @@
[ {
{ "type": [ "machine" ],
"type": [ "machine" ], "machine": "_placement",
"input": { "concrete": 500, "iron_plate": 250, "iron_rod": 400, "wire": 1500 }, "power_usage": null,
"output": { "space_elevator": 1 }, "size": [ 54, 54, 118 ],
"machine": "_placement", "recipes":
"power_usage": null, [
"size": [ 54, 54, 118 ], {
"requires": "hub_upgrade_5" "input": { "concrete": 500, "iron_plate": 250, "iron_rod": 400, "wire": 1500 },
} "output": { "space_elevator": 1 },
] "requires": "hub_upgrade_5"
}
]
}

View File

@ -1,8 +1,11 @@
[ {
{ "type": [ "resource" ],
"type": [ "resource" ], "machine": "miner",
"input": { }, "recipes": [
"output": { "caterium_ore": 1 }, {
"machine": "miner" "input": { },
} "output": { "caterium_ore": 1 }
] }
]
}

View File

@ -1,8 +1,11 @@
[ {
{ "type": [ "resource" ],
"type": [ "resource" ], "machine": "miner",
"input": { }, "recipes":
"output": { "coal": 1 }, [
"machine": "miner" {
} "input": { },
] "output": { "coal": 1 }
}
]
}

View File

@ -1,8 +1,14 @@
[ {
{ "type": [
"type": [ "resource" ], "resource"
"input": { }, ],
"output": { "copper_ore": 1 }, "machine": "miner",
"machine": "miner" "recipes": [
} {
] "input": {},
"output": {
"copper_ore": 1
}
}
]
}

View File

@ -1,8 +1,11 @@
[ {
{ "type": [ "resource" ],
"type": [ "resource" ], "machine": "oil_pump",
"input": { }, "recipes":
"output": { "crude_oil": 1 }, [
"machine": "oil_pump" {
} "input": { },
] "output": { "crude_oil": 1 }
}
]
}

View File

@ -1,8 +1,11 @@
[ {
{ "type": [ "resource" ],
"type": [ "resource" ], "machine": "miner",
"input": { }, "recipes":
"output": { "iron_ore": 1 }, [
"machine": "miner" {
} "input": { },
] "output": { "iron_ore": 1 }
}
]
}

View File

@ -1,9 +1,15 @@
[ {
{ "type": [
"type": [ "resource" ], "resource"
"input": { }, ],
"output": { "limestone": 1 }, "machine": "miner",
"machine": "miner", "requires": "hub_upgrade_2",
"requires": "hub_upgrade_2" "recipes": [
} {
] "input": {},
"output": {
"limestone": 1
}
}
]
}

View File

@ -1,31 +1,12 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import json import satisfactory
import typing
import os
if __name__ == '__main__': if __name__ == '__main__':
root = os.path.dirname(__file__) root = os.path.dirname(__file__)
recipe_root = os.path.join(root, 'data', 'recipes') recipe_root = os.path.join(root, 'data', 'recipes')
cookbook = satisfactory.Cookbook(recipe_root)
recipes = dict() print(i for i in cookbook.resources())
for dirname, dirs, files in os.walk(recipe_root):
for f in files:
path = os.path.join(dirname, f)
name, _ = os.path.splitext(f)
with open(path, 'r') as src:
variations = json.load(src)
recipes[name] = variations
resources = set()
for output, variations in recipes.items():
for option in variations:
if len(option['input']) == 0:
resources.add(output)
print("Resources:", resources)

View File

@ -1,48 +1,13 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import json import satisfactory
import os import os
from typing import Iterable from typing import Iterable
class Cookbook(object):
recipes: dict
def __init__(self, root: str): def graph(cookbook: satisfactory.Cookbook, targets: Iterable[str]):
self.recipes = dict()
for dirname, dirs, files in os.walk(root):
for f in files:
path = os.path.join(dirname, f)
name, _ = os.path.splitext(f)
with open(path, 'r') as src:
variations = json.load(src)
self.recipes[name] = variations
def __getitem__(self, item: str):
return self.recipes[item]
def all(self):
return self.recipes.keys()
def is_component(self, name):
return 'component' in self.recipes[name]['type']
def components(self):
found = set()
for target, methods in self.recipes.items():
for variation in methods:
for need, _ in variation['input'].items():
if need in found:
continue
found.add(need)
if not self.is_component(need):
continue
yield need
def graph(recipes: dict, targets: Iterable[str]):
print("digraph G {") print("digraph G {")
seen = set() seen = set()
@ -51,7 +16,7 @@ def graph(recipes: dict, targets: Iterable[str]):
while remain: while remain:
output = remain.pop() output = remain.pop()
for need in recipes[output][0]['input']: for need in cookbook.recipes(output)[0]['input']:
print(f"{need} -> {output}") print(f"{need} -> {output}")
if need not in seen: if need not in seen:
remain.add(need) remain.add(need)
@ -81,7 +46,7 @@ if __name__ == '__main__':
args = parser.parse_args() args = parser.parse_args()
recipes = Cookbook(args.data) recipes = satisfactory.Cookbook(args.data)
if args.target: if args.target:
graph_one(recipes, args.target) graph_one(recipes, args.target)

44
satisfactory/__init__.py Normal file
View File

@ -0,0 +1,44 @@
import os
import json
class Cookbook(object):
__recipes: dict
def __init__(self, root: str):
self.__recipes = dict()
for dirname, dirs, files in os.walk(root):
for f in files:
path = os.path.join(dirname, f)
name, _ = os.path.splitext(f)
with open(path, 'r') as src:
self.__recipes[name] = json.load(src)
def __getitem__(self, item: str):
return self.__recipes[item]
def all(self):
return self.__recipes.keys()
def recipes(self, name: str) -> dict:
return self.__recipes[name]['recipes']
def is_component(self, name):
return 'component' in self.__recipes[name]['type']
def is_resource(self, name):
return ''
def components(self):
found = set()
for _, descriptor in self.__recipes.items():
for variation in descriptor['recipes']:
for need, _ in variation['input'].items():
if need in found:
continue
found.add(need)
if not self.is_component(need):
continue
yield need