| 
									
										
										
										
											2021-07-16 12:41:37 +02:00
										 |  |  | from typing import Set | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from ..AutoWorld import World, LogicMixin | 
					
						
							|  |  |  | from .Items import item_table, default_pool | 
					
						
							|  |  |  | from .Locations import lookup_name_to_id | 
					
						
							|  |  |  | from .Rules import set_rules, location_rules | 
					
						
							|  |  |  | from .Regions import locations_by_region, connectors | 
					
						
							|  |  |  | from .Options import options | 
					
						
							| 
									
										
										
										
											2023-02-13 18:06:43 -06:00
										 |  |  | from BaseClasses import Region, Item, Location, Entrance, ItemClassification | 
					
						
							| 
									
										
										
										
											2021-07-16 12:41:37 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class OriBlindForest(World): | 
					
						
							|  |  |  |     game: str = "Ori and the Blind Forest" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     topology_present = True | 
					
						
							| 
									
										
										
										
											2023-03-20 11:01:08 -05:00
										 |  |  |     data_version = 1 | 
					
						
							| 
									
										
										
										
											2021-07-16 12:41:37 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     item_name_to_id = item_table | 
					
						
							|  |  |  |     location_name_to_id = lookup_name_to_id | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-15 16:46:59 -05:00
										 |  |  |     option_definitions = options | 
					
						
							| 
									
										
										
										
											2021-07-16 12:41:37 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-27 14:52:33 +02:00
										 |  |  |     hidden = True | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-16 12:41:37 +02:00
										 |  |  |     def generate_early(self): | 
					
						
							|  |  |  |         logic_sets = {"casual-core"} | 
					
						
							|  |  |  |         for logic_set in location_rules: | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |             if logic_set != "casual-core" and getattr(self.multiworld, logic_set.replace("-", "_")): | 
					
						
							| 
									
										
										
										
											2021-07-16 12:41:37 +02:00
										 |  |  |                 logic_sets.add(logic_set) | 
					
						
							|  |  |  |         self.logic_sets = logic_sets | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     set_rules = set_rules | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def create_region(self, name: str): | 
					
						
							| 
									
										
										
										
											2023-02-13 18:06:43 -06:00
										 |  |  |         return Region(name, self.player, self.multiworld) | 
					
						
							| 
									
										
										
										
											2021-07-16 12:41:37 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def create_regions(self): | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |         world = self.multiworld | 
					
						
							| 
									
										
										
										
											2021-07-16 12:41:37 +02:00
										 |  |  |         menu = self.create_region("Menu") | 
					
						
							|  |  |  |         world.regions.append(menu) | 
					
						
							|  |  |  |         start = Entrance(self.player, "Start Game", menu) | 
					
						
							|  |  |  |         menu.exits.append(start) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         # workaround for now, remove duplicate locations | 
					
						
							|  |  |  |         already_placed_locations = set() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for region_name, locations in locations_by_region.items(): | 
					
						
							|  |  |  |             locations -= already_placed_locations | 
					
						
							|  |  |  |             already_placed_locations |= locations | 
					
						
							|  |  |  |             region = self.create_region(region_name) | 
					
						
							|  |  |  |             if region_name == "SunkenGladesRunaway":  # starting point | 
					
						
							|  |  |  |                 start.connect(region) | 
					
						
							|  |  |  |             region.locations = {Location(self.player, location, lookup_name_to_id[location], region) | 
					
						
							|  |  |  |                                 for location in locations} | 
					
						
							|  |  |  |             world.regions.append(region) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         for region_name, exits in connectors.items(): | 
					
						
							|  |  |  |             parent = world.get_region(region_name, self.player) | 
					
						
							|  |  |  |             for exit in exits: | 
					
						
							|  |  |  |                 connection = Entrance(self.player, exit, parent) | 
					
						
							|  |  |  |                 connection.connect(world.get_region(exit, self.player)) | 
					
						
							|  |  |  |                 parent.exits.append(connection) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def generate_basic(self): | 
					
						
							|  |  |  |         for item_name, count in default_pool.items(): | 
					
						
							| 
									
										
										
										
											2022-10-31 21:41:21 -05:00
										 |  |  |             self.multiworld.itempool.extend([self.create_item(item_name) for _ in range(count)]) | 
					
						
							| 
									
										
										
										
											2021-07-16 12:41:37 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     def create_item(self, name: str) -> Item: | 
					
						
							| 
									
										
										
										
											2022-06-17 03:23:27 +02:00
										 |  |  |         return Item(name, | 
					
						
							|  |  |  |                     ItemClassification.progression if not name.startswith("EX") else ItemClassification.filler, | 
					
						
							|  |  |  |                     item_table[name], self.player) | 
					
						
							| 
									
										
										
										
											2021-07-16 12:41:37 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class OriBlindForestLogic(LogicMixin): | 
					
						
							|  |  |  |     def _oribf_has_all(self, items: Set[str], player:int): | 
					
						
							|  |  |  |         return all(self.prog_items[item, player] if type(item) == str | 
					
						
							|  |  |  |                    else self.prog_items[item[0], player] >= item[1] for item in items) |