satisfactory: implement the 'resources' query
This commit is contained in:
parent
65eb55e409
commit
8cb5d5a76c
@ -9,5 +9,6 @@ if __name__ == '__main__':
|
|||||||
recipe_root = os.path.join(root, 'data', 'recipes')
|
recipe_root = os.path.join(root, 'data', 'recipes')
|
||||||
cookbook = satisfactory.Cookbook(recipe_root)
|
cookbook = satisfactory.Cookbook(recipe_root)
|
||||||
|
|
||||||
print(i for i in cookbook.resources())
|
for i in cookbook.resources():
|
||||||
|
print(i)
|
||||||
|
|
||||||
|
@ -26,19 +26,11 @@ class Cookbook(object):
|
|||||||
def is_component(self, name):
|
def is_component(self, name):
|
||||||
return 'component' in self.__recipes[name]['type']
|
return 'component' in self.__recipes[name]['type']
|
||||||
|
|
||||||
def is_resource(self, name):
|
|
||||||
return ''
|
|
||||||
|
|
||||||
def components(self):
|
def components(self):
|
||||||
found = set()
|
return (i for i in self.all() if self.is_component(i))
|
||||||
|
|
||||||
for _, descriptor in self.__recipes.items():
|
def is_resource(self, name):
|
||||||
for variation in descriptor['recipes']:
|
return 'resource' in self.__recipes[name]['type']
|
||||||
for need, _ in variation['input'].items():
|
|
||||||
if need in found:
|
|
||||||
continue
|
|
||||||
found.add(need)
|
|
||||||
if not self.is_component(need):
|
|
||||||
continue
|
|
||||||
yield need
|
|
||||||
|
|
||||||
|
def resources(self):
|
||||||
|
return (i for i in self.all() if self.is_resource(i))
|
||||||
|
Loading…
Reference in New Issue
Block a user