shortcut logic for requirement-less technologies
This commit is contained in:
		
							parent
							
								
									2355f9c8d3
								
							
						
					
					
						commit
						1b70d485c0
					
				| 
						 | 
					@ -15,6 +15,7 @@ with open(recipe_source_file) as f:
 | 
				
			||||||
tech_table = {}
 | 
					tech_table = {}
 | 
				
			||||||
technology_table = {}
 | 
					technology_table = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					always = lambda state: True
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Technology():  # maybe make subclass of Location?
 | 
					class Technology():  # maybe make subclass of Location?
 | 
				
			||||||
    def __init__(self, name, ingredients):
 | 
					    def __init__(self, name, ingredients):
 | 
				
			||||||
| 
						 | 
					@ -36,9 +37,12 @@ class Technology():  # maybe make subclass of Location?
 | 
				
			||||||
                    ingredient_rules.append(
 | 
					                    ingredient_rules.append(
 | 
				
			||||||
                        lambda state, technologies=technologies: all(state.has(technology.name, player)
 | 
					                        lambda state, technologies=technologies: all(state.has(technology.name, player)
 | 
				
			||||||
                                                                     for technology in technologies))
 | 
					                                                                     for technology in technologies))
 | 
				
			||||||
 | 
					        if ingredient_rules:
 | 
				
			||||||
            ingredient_rules = frozenset(ingredient_rules)
 | 
					            ingredient_rules = frozenset(ingredient_rules)
 | 
				
			||||||
            return lambda state: all(rule(state) for rule in ingredient_rules)
 | 
					            return lambda state: all(rule(state) for rule in ingredient_rules)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return always
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __hash__(self):
 | 
					    def __hash__(self):
 | 
				
			||||||
        return self.factorio_id
 | 
					        return self.factorio_id
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue