shortcut logic for requirement-less technologies

This commit is contained in:
Fabian Dill 2021-04-10 00:08:59 +02:00
parent 2355f9c8d3
commit 1b70d485c0
1 changed files with 6 additions and 2 deletions

View File

@ -15,6 +15,7 @@ with open(recipe_source_file) as f:
tech_table = {}
technology_table = {}
always = lambda state: True
class Technology(): # maybe make subclass of Location?
def __init__(self, name, ingredients):
@ -36,8 +37,11 @@ class Technology(): # maybe make subclass of Location?
ingredient_rules.append(
lambda state, technologies=technologies: all(state.has(technology.name, player)
for technology in technologies))
ingredient_rules = frozenset(ingredient_rules)
return lambda state: all(rule(state) for rule in ingredient_rules)
if ingredient_rules:
ingredient_rules = frozenset(ingredient_rules)
return lambda state: all(rule(state) for rule in ingredient_rules)
return always
def __hash__(self):
return self.factorio_id