2021-08-03 19:03:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import collections
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-20 04:47:19 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import typing
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-03 19:03:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 14:22:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from ..AutoWorld import World
							 | 
						
					
						
							
								
									
										
										
										
											2021-05-13 01:34:59 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-14 19:40:35 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from BaseClasses import Region, Entrance, Location, Item, RegionType
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-20 04:47:19 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from .Technologies import base_tech_table, recipe_sources, base_technology_table, \
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-24 01:41:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    all_ingredient_names, all_product_sources, required_technologies, get_rocket_requirements, rocket_recipes, \
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-07 10:14:58 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    progressive_technology_table, common_tech_table, tech_to_progressive_lookup, progressive_tech_table, \
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-25 09:44:01 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    get_science_pack_pools, Recipe, recipes, technology_table, tech_table, factorio_base_id, useless_technologies, \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    liquids
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-11 18:19:47 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from .Shapes import get_shapes
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 14:22:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from .Mod import generate_mod
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-30 23:18:17 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								from .Options import factorio_options, MaxSciencePack, Silo, Satellite, TechTreeInformation, Goal
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-01 11:40:58 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-24 01:41:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import logging
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-12 13:54:47 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								class FactorioItem(Item):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    game = "Factorio"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-04 05:40:51 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								all_items = tech_table.copy()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								all_items["Attack Trap"] = factorio_base_id - 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								all_items["Evolution Trap"] = factorio_base_id - 2
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-05-13 01:34:59 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								class Factorio(World):
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-31 17:28:46 -04:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    """
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    Factorio is a game about automation. You play as an engineer who has crash landed on the planet
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    Nauvis, an inhospitable world filled with dangerous creatures called biters. Build a factory,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    research new technologies, and become more efficient in your quest to build a rocket and return home.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    """
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 14:22:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    game: str = "Factorio"
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-15 15:32:40 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    static_nodes = {"automation", "logistics", "rocket-silo"}
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-14 19:40:35 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    custom_recipes: typing.Dict[str, Recipe]
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-20 04:47:19 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    advancement_technologies: typing.Set[str]
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 14:22:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-04 05:40:51 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    item_name_to_id = all_items
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-12 18:05:46 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    location_name_to_id = base_tech_table
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-05 15:49:19 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    item_name_groups = {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        "Progressive": set(progressive_tech_table.values()),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    }
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-06 08:14:16 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    data_version = 5
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-01 06:15:50 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-19 19:44:34 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    def __init__(self, world, player: int):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        super(Factorio, self).__init__(world, player)
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-20 04:47:19 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        self.advancement_technologies = set()
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-14 19:40:35 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        self.custom_recipes = {}
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-19 19:44:34 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-22 18:21:31 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    def generate_basic(self):
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-04 05:40:51 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        player = self.player
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        want_progressives = collections.defaultdict(lambda: self.world.progressive[player].
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-03 19:03:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                                                    want_progressives(self.world.random))
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-04 05:40:51 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        skip_silo = self.world.silo[player].value == Silo.option_spawn
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        evolution_traps_wanted = self.world.evolution_traps[player].value
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        attack_traps_wanted = self.world.attack_traps[player].value
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        traps_wanted = ["Evolution Trap"] * evolution_traps_wanted + ["Attack Trap"] * attack_traps_wanted
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        self.world.random.shuffle(traps_wanted)
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-12 13:54:47 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        for tech_name in base_tech_table:
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-04 05:40:51 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            if traps_wanted and tech_name in useless_technologies:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                self.world.itempool.append(self.create_item(traps_wanted.pop()))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            elif skip_silo and tech_name == "rocket-silo":
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                pass
							 | 
						
					
						
							
								
									
										
										
										
											2021-05-13 01:34:59 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            else:
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-04 05:40:51 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                progressive_item_name = tech_to_progressive_lookup.get(tech_name, tech_name)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                want_progressive = want_progressives[progressive_item_name]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                item_name = progressive_item_name if want_progressive else tech_name
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                tech_item = self.create_item(item_name)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                if tech_name in self.static_nodes:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    self.world.get_location(tech_name, player).place_locked_item(tech_item)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    self.world.itempool.append(tech_item)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        map_basic_settings = self.world.world_gen[player].value["basic"]
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-19 01:02:23 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if map_basic_settings.get("seed", None) is None:  # allow seed 0
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-04 05:40:51 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            map_basic_settings["seed"] = self.world.slot_seeds[player].randint(0, 2 ** 32 - 1)  # 32 bit uint
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-01 11:40:58 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-09 21:03:03 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        self.sending_visible = self.world.tech_tree_information[player] == TechTreeInformation.option_full
							 | 
						
					
						
							
								
									
										
										
										
											2021-10-09 20:38:53 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-07 10:14:58 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    generate_output = generate_mod
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-01 11:40:58 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 18:02:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    def create_regions(self):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        player = self.player
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-14 19:40:35 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        menu = Region("Menu", RegionType.Generic, "Menu", player, self.world)
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 14:22:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        crash = Entrance(player, "Crash Land", menu)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        menu.exits.append(crash)
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-14 19:40:35 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        nauvis = Region("Nauvis", RegionType.Generic, "Nauvis", player, self.world)
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-01 11:40:58 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-25 22:12:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        skip_silo = self.world.silo[self.player].value == Silo.option_spawn
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-04 22:21:53 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        for tech_name, tech_id in base_tech_table.items():
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-25 22:12:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            if skip_silo and tech_name == "rocket-silo":
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                continue
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 14:22:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            tech = Location(player, tech_name, tech_id, nauvis)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            nauvis.locations.append(tech)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            tech.game = "Factorio"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        location = Location(player, "Rocket Launch", None, nauvis)
							 | 
						
					
						
							
								
									
										
										
										
											2021-05-22 10:06:21 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        nauvis.locations.append(location)
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-07 10:14:58 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        location.game = "Factorio"
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 14:22:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        event = Item("Victory", True, None, player)
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-07 10:14:58 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        event.game = "Factorio"
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 18:02:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        self.world.push_item(location, event, False)
							 | 
						
					
						
							
								
									
										
										
										
											2021-05-22 10:06:21 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        location.event = location.locked = True
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-26 06:05:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        for ingredient in self.world.max_science_pack[self.player].get_allowed_packs():
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 14:22:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            location = Location(player, f"Automate {ingredient}", None, nauvis)
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-07 10:14:58 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            location.game = "Factorio"
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 14:22:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            nauvis.locations.append(location)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            event = Item(f"Automated {ingredient}", True, None, player)
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 18:02:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            self.world.push_item(location, event, False)
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 14:22:44 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            location.event = location.locked = True
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        crash.connect(nauvis)
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 18:02:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        self.world.regions += [menu, nauvis]
							 | 
						
					
						
							
								
									
										
										
										
											2021-04-01 11:40:58 +02:00
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 18:02:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    def set_rules(self):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        world = self.world
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        player = self.player
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-07 10:14:58 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        self.custom_technologies = self.set_custom_technologies()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        self.set_custom_recipes()
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 18:02:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        shapes = get_shapes(self)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if world.logic[player] != 'nologic':
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            from worlds.generic import Rules
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-26 06:05:38 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            for ingredient in self.world.max_science_pack[self.player].get_allowed_packs():
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 18:02:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                location = world.get_location(f"Automate {ingredient}", player)
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-07 10:14:58 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                if self.world.recipe_ingredients[self.player]:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    custom_recipe = self.custom_recipes[ingredient]
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-09-22 08:08:29 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    location.access_rule = lambda state, ingredient=ingredient, custom_recipe=custom_recipe: \
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-07 10:14:58 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                        (ingredient not in technology_table or state.has(ingredient, player)) and \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                        all(state.has(technology.name, player) for sub_ingredient in custom_recipe.ingredients
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                            for technology in required_technologies[sub_ingredient])
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    location.access_rule = lambda state, ingredient=ingredient: \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                        all(state.has(technology.name, player) for technology in required_technologies[ingredient])
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-25 22:12:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            skip_silo = self.world.silo[self.player].value == Silo.option_spawn
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 18:02:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            for tech_name, technology in self.custom_technologies.items():
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-25 22:12:03 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                if skip_silo and tech_name == "rocket-silo":
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    continue
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 18:02:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                location = world.get_location(tech_name, player)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                Rules.set_rule(location, technology.build_rule(player))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                prequisites = shapes.get(tech_name)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                if prequisites:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    locations = {world.get_location(requisite, player) for requisite in prequisites}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    Rules.add_rule(location, lambda state,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                                    locations=locations: all(state.can_reach(loc) for loc in locations))
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-07 10:14:58 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 10:54:11 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            silo_recipe = None
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if self.world.silo[self.player] == Silo.option_spawn:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                silo_recipe = self.custom_recipes["rocket-silo"] if "rocket-silo" in self.custom_recipes \
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-02 16:29:29 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    else next(iter(all_product_sources.get("rocket-silo")))
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-24 01:41:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            part_recipe = self.custom_recipes["rocket-part"]
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 10:54:11 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            satellite_recipe = None
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if self.world.goal[self.player] == Goal.option_satellite:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                satellite_recipe = self.custom_recipes["satellite"] if "satellite" in self.custom_recipes \
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-02 16:29:29 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    else next(iter(all_product_sources.get("satellite")))
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-20 12:35:51 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            victory_tech_names = get_rocket_requirements(silo_recipe, part_recipe, satellite_recipe)
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-11 18:02:48 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            world.get_location("Rocket Launch", player).access_rule = lambda state: all(state.has(technology, player)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                                                                        for technology in
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                                                                        victory_tech_names)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        world.completion_condition[player] = lambda state: state.has('Victory', player)
							 | 
						
					
						
							
								
									
										
										
										
											2021-05-22 10:06:21 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-21 06:55:08 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    def collect_item(self, state, item, remove=False):
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-04 22:21:53 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if item.advancement and item.name in progressive_technology_table:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            prog_table = progressive_technology_table[item.name].progressive
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-21 06:55:08 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            if remove:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                for item_name in reversed(prog_table):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    if state.has(item_name, item.player):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                        return item_name
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                for item_name in prog_table:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    if not state.has(item_name, item.player):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                        return item_name
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-10 09:47:28 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-21 06:55:08 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return super(Factorio, self).collect_item(state, item, remove)
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-04 22:21:53 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-27 00:23:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    def get_required_client_version(self) -> tuple:
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-24 00:51:31 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return max((0, 2, 6), super(Factorio, self).get_required_client_version())
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-27 00:23:42 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-06-25 23:32:13 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    options = factorio_options
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-02 12:29:29 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    @classmethod
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    def stage_write_spoiler(cls, world, spoiler_handle):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        factorio_players = world.get_game_players(cls.game)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        spoiler_handle.write('\n\nFactorio Recipes:\n')
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for player in factorio_players:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            name = world.get_player_name(player)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            for recipe in world.worlds[player].custom_recipes.values():
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                spoiler_handle.write(f"\n{recipe.name} ({name}): {recipe.ingredients} -> {recipe.products}")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-25 18:27:16 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    @staticmethod
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    def get_category(category: str, liquids: int) -> str:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        categories = {1: "crafting-with-fluid",
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                      2: "chemistry"}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return categories.get(liquids, category)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    def make_quick_recipe(self, original: Recipe, pool: list, allow_liquids: int = 2) -> Recipe:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        new_ingredients = {}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        liquids_used = 0
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for _ in original.ingredients:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            new_ingredient = pool.pop()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if new_ingredient in liquids:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                while liquids_used == allow_liquids and new_ingredient in liquids:
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-15 14:02:05 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    # liquids already at max for current recipe.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                    # Return the liquid to the pool and get a new ingredient.
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-25 18:27:16 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    pool.append(new_ingredient)
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-15 14:02:05 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    new_ingredient = pool.pop(0)
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-25 18:27:16 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                liquids_used += 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            new_ingredients[new_ingredient] = 1
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-02 16:29:29 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return Recipe(original.name, self.get_category(original.category, liquids_used), new_ingredients,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                      original.products, original.energy)
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-25 18:27:16 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-26 02:37:15 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    def make_balanced_recipe(self, original: Recipe, pool: list, factor: float = 1, allow_liquids: int = 2) -> \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            Recipe:
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-24 01:41:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        """Generate a recipe from pool with time and cost similar to original * factor"""
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        new_ingredients = {}
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-14 19:40:35 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        pool = sorted(pool, key=lambda x: self.world.random.random())
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-24 01:41:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        target_raw = int(sum((count for ingredient, count in original.base_cost.items())) * factor)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        target_energy = original.total_energy * factor
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        target_num_ingredients = len(original.ingredients)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        remaining_raw = target_raw
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        remaining_energy = target_energy
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        remaining_num_ingredients = target_num_ingredients
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        fallback_pool = []
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-25 09:44:01 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        liquids_used = 0
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-24 01:41:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        # fill all but one slot with random ingredients, last with a good match
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-19 19:44:34 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        while remaining_num_ingredients > 0 and pool:
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-26 02:37:15 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            ingredient = pool.pop()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if liquids_used == allow_liquids and ingredient in liquids:
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-02 16:29:29 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                continue  # can't use this ingredient as we already have maximum liquid in our recipe.
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-26 02:37:15 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            if ingredient in all_product_sources:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                ingredient_recipe = min(all_product_sources[ingredient], key=lambda recipe: recipe.rel_cost)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                ingredient_raw = sum((count for ingredient, count in ingredient_recipe.base_cost.items()))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                ingredient_energy = ingredient_recipe.total_energy
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                # assume simple ore TODO: remove if tree when mining data is harvested from Factorio
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                ingredient_raw = 1
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                ingredient_energy = 2
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-24 01:41:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            if remaining_num_ingredients == 1:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                max_raw = 1.1 * remaining_raw
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                min_raw = 0.9 * remaining_raw
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                max_energy = 1.1 * remaining_energy
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-21 18:24:25 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                min_energy = 0.9 * remaining_energy
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-24 01:41:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            else:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                max_raw = remaining_raw * 0.75
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                min_raw = (remaining_raw - max_raw) / remaining_num_ingredients
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                max_energy = remaining_energy * 0.75
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                min_energy = (remaining_energy - max_energy) / remaining_num_ingredients
							 | 
						
					
						
							
								
									
										
										
										
											2021-09-22 08:08:29 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            min_num_raw = min_raw / ingredient_raw
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            max_num_raw = max_raw / ingredient_raw
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            min_num_energy = min_energy / ingredient_energy
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            max_num_energy = max_energy / ingredient_energy
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-24 01:41:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            min_num = int(max(1, min_num_raw, min_num_energy))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            max_num = int(min(1000, max_num_raw, max_num_energy))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if min_num > max_num:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                fallback_pool.append(ingredient)
							 | 
						
					
						
							
								
									
										
										
										
											2021-09-22 08:08:29 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                continue  # can't use that ingredient
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            num = self.world.random.randint(min_num, max_num)
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-24 01:41:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            new_ingredients[ingredient] = num
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            remaining_raw -= num * ingredient_raw
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            remaining_energy -= num * ingredient_energy
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            remaining_num_ingredients -= 1
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-25 09:44:01 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            if ingredient in liquids:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                liquids_used += 1
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-24 01:41:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        # fill failed slots with whatever we got
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        pool = fallback_pool
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-19 19:44:34 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        while remaining_num_ingredients > 0 and pool:
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-24 01:41:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            ingredient = pool.pop()
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-26 02:37:15 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            if liquids_used == allow_liquids and ingredient in liquids:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                continue  # can't use this ingredient as we already have maximum liquid in our recipe.
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-25 16:38:33 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            ingredient_recipe = recipes.get(ingredient, None)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if not ingredient_recipe and ingredient.endswith("-barrel"):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                ingredient_recipe = recipes.get(f"fill-{ingredient}", None)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if not ingredient_recipe:
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-24 01:41:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                logging.warning(f"missing recipe for {ingredient}")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                continue
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            ingredient_raw = sum((count for ingredient, count in ingredient_recipe.base_cost.items()))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            ingredient_energy = ingredient_recipe.total_energy
							 | 
						
					
						
							
								
									
										
										
										
											2021-09-22 08:08:29 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            num_raw = remaining_raw / ingredient_raw / remaining_num_ingredients
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            num_energy = remaining_energy / ingredient_energy / remaining_num_ingredients
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-24 01:41:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            num = int(min(num_raw, num_energy))
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-26 02:37:15 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            if num < 1:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                continue
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-24 01:41:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            new_ingredients[ingredient] = num
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            remaining_raw -= num * ingredient_raw
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            remaining_energy -= num * ingredient_energy
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            remaining_num_ingredients -= 1
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-25 09:44:01 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            if ingredient in liquids:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                liquids_used += 1
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-24 01:41:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if remaining_num_ingredients > 1:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            logging.warning("could not randomize recipe")
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-02-02 16:29:29 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        return Recipe(original.name, self.get_category(original.category, liquids_used), new_ingredients,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                      original.products, original.energy)
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-24 01:41:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-07 10:14:58 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    def set_custom_technologies(self):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        custom_technologies = {}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        allowed_packs = self.world.max_science_pack[self.player].get_allowed_packs()
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for technology_name, technology in base_technology_table.items():
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            custom_technologies[technology_name] = technology.get_custom(self.world, allowed_packs, self.player)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return custom_technologies
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    def set_custom_recipes(self):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        original_rocket_part = recipes["rocket-part"]
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-09 17:44:24 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        science_pack_pools = get_science_pack_pools()
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-07 10:14:58 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        valid_pool = sorted(science_pack_pools[self.world.max_science_pack[self.player].get_max_pack()])
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        self.world.random.shuffle(valid_pool)
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-25 09:44:01 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        while any([valid_pool[x] in liquids for x in range(3)]):
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            self.world.random.shuffle(valid_pool)
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-07 10:14:58 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        self.custom_recipes = {"rocket-part": Recipe("rocket-part", original_rocket_part.category,
							 | 
						
					
						
							
								
									
										
										
										
											2021-09-22 08:08:29 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                                                     {valid_pool[x]: 10 for x in range(3)},
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-24 01:41:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                                                     original_rocket_part.products,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                                     original_rocket_part.energy)}
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-07 10:14:58 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if self.world.recipe_ingredients[self.player]:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            valid_pool = []
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            for pack in self.world.max_science_pack[self.player].get_ordered_science_packs():
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                valid_pool += sorted(science_pack_pools[pack])
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                self.world.random.shuffle(valid_pool)
							 | 
						
					
						
							
								
									
										
										
										
											2021-09-22 08:08:29 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                if pack in recipes:  # skips over space science pack
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-25 18:27:16 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    new_recipe = self.make_quick_recipe(recipes[pack], valid_pool)
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-07 10:14:58 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                    self.custom_recipes[pack] = new_recipe
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-20 16:27:17 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if self.world.silo[self.player].value == Silo.option_randomize_recipe \
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                or self.world.satellite[self.player].value == Satellite.option_randomize_recipe:
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-24 01:41:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            valid_pool = []
							 | 
						
					
						
							
								
									
										
										
										
											2021-09-26 14:02:19 -07:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            for pack in sorted(self.world.max_science_pack[self.player].get_allowed_packs()):
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-24 01:41:41 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                valid_pool += sorted(science_pack_pools[pack])
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-20 16:27:17 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            if self.world.silo[self.player].value == Silo.option_randomize_recipe:
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-14 19:40:35 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                new_recipe = self.make_balanced_recipe(recipes["rocket-silo"], valid_pool,
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-20 16:27:17 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                                                       factor=(self.world.max_science_pack[self.player].value + 1) / 7)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                self.custom_recipes["rocket-silo"] = new_recipe
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            if self.world.satellite[self.player].value == Satellite.option_randomize_recipe:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                new_recipe = self.make_balanced_recipe(recipes["satellite"], valid_pool,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                                                       factor=(self.world.max_science_pack[self.player].value + 1) / 7)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                self.custom_recipes["satellite"] = new_recipe
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-14 19:40:35 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        bridge = "ap-energy-bridge"
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        new_recipe = self.make_quick_recipe(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            Recipe(bridge, "crafting", {"replace_1": 1, "replace_2": 1, "replace_3": 1},
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                   {bridge: 1}, 10),
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            sorted(science_pack_pools[self.world.max_science_pack[self.player].get_ordered_science_packs()[0]]))
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for ingredient_name in new_recipe.ingredients:
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-15 14:01:15 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            new_recipe.ingredients[ingredient_name] = self.world.random.randint(10, 100)
							 | 
						
					
						
							
								
									
										
										
										
											2022-03-14 19:40:35 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        self.custom_recipes[bridge] = new_recipe
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-20 16:27:17 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        needed_recipes = self.world.max_science_pack[self.player].get_allowed_packs() | {"rocket-part"}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if self.world.silo[self.player] != Silo.option_spawn:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            needed_recipes |= {"rocket-silo"}
							 | 
						
					
						
							
								
									
										
										
										
											2021-12-04 06:20:16 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if self.world.goal[self.player].value == Goal.option_satellite:
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-20 12:35:51 -08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            needed_recipes |= {"satellite"}
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-20 04:47:19 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        for recipe in needed_recipes:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            recipe = self.custom_recipes.get(recipe, recipes[recipe])
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            self.advancement_technologies |= {tech.name for tech in recipe.recursive_unlocking_technologies}
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-07 10:14:58 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        # handle marking progressive techs as advancement
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        prog_add = set()
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-20 04:47:19 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        for tech in self.advancement_technologies:
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-07 10:14:58 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            if tech in tech_to_progressive_lookup:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								                prog_add.add(tech_to_progressive_lookup[tech])
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-20 04:47:19 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        self.advancement_technologies |= prog_add
							 | 
						
					
						
							
								
									
										
										
										
											2021-07-12 13:54:47 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    def create_item(self, name: str) -> Item:
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-04 05:40:51 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								        if name in tech_table:
							 | 
						
					
						
							
								
									
										
										
										
											2021-11-20 04:47:19 +01:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								            return FactorioItem(name, name in self.advancement_technologies,
							 | 
						
					
						
							
								
									
										
										
										
											2021-08-04 05:40:51 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								                                tech_table[name], self.player)
							 | 
						
					
						
							
								
									
										
										
										
											2021-09-29 05:21:33 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        item = FactorioItem(name, False, all_items[name], self.player)
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        if "Trap" in name:
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								            item.trap = True
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        return item
							 |