 2af510328e
			
		
	
	2af510328e
	
	
	
		
			
			* rename references to `Multiworld` in core to `multiworld` instead of `world` * fix smz3 * fix oot * fix low hanging fruit * revert mysteriously broken spacing in world api.md * fix more randomly broken spacing * hate * that better be all of it * begrudgingly move over smw * ._. * missed some worlds * this is getting tedious now * Missed some self.world definitions Co-authored-by: espeon65536 <espeon65536@gmail.com> Co-authored-by: Zach Parks <zach@alliware.com>
		
			
				
	
	
		
			126 lines
		
	
	
		
			5.8 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			126 lines
		
	
	
		
			5.8 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| from typing import Dict, List, NamedTuple, Optional
 | |
| 
 | |
| from BaseClasses import MultiWorld, Region, RegionType, Entrance
 | |
| from .Items import RLItem
 | |
| from .Locations import RLLocation, location_table, get_locations_by_category
 | |
| 
 | |
| 
 | |
| class RLRegionData(NamedTuple):
 | |
|     locations: Optional[List[str]]
 | |
|     exits: Optional[List[str]]
 | |
| 
 | |
| 
 | |
| def create_regions(world: MultiWorld, player: int):
 | |
|     regions: Dict[str, RLRegionData] = {
 | |
|         "Menu": RLRegionData(None, ["Castle Hamson"]),
 | |
|         "The Manor": RLRegionData([], []),
 | |
|         "Castle Hamson": RLRegionData([], ["Forest Abkhazia",
 | |
|                                            "The Maya",
 | |
|                                            "Land of Darkness",
 | |
|                                            "The Fountain Room",
 | |
|                                            "The Manor"]),
 | |
|         "Forest Abkhazia": RLRegionData([], []),
 | |
|         "The Maya": RLRegionData([], []),
 | |
|         "Land of Darkness": RLRegionData([], []),
 | |
|         "The Fountain Room": RLRegionData([], None),
 | |
|     }
 | |
| 
 | |
|     # Diaries
 | |
|     for diary in range(0, 25):
 | |
|         region: str
 | |
|         if 0 <= diary < 6:
 | |
|             region = "Castle Hamson"
 | |
|         elif 6 <= diary < 12:
 | |
|             region = "Forest Abkhazia"
 | |
|         elif 12 <= diary < 18:
 | |
|             region = "The Maya"
 | |
|         elif 18 <= diary < 24:
 | |
|             region = "Land of Darkness"
 | |
|         else:
 | |
|             region = "The Fountain Room"
 | |
| 
 | |
|         regions[region].locations.append(f"Diary {diary + 1}")
 | |
| 
 | |
|     # Manor & Special
 | |
|     for manor in get_locations_by_category("Manor").keys():
 | |
|         regions["The Manor"].locations.append(manor)
 | |
|     for special in get_locations_by_category("Special").keys():
 | |
|         regions["Castle Hamson"].locations.append(special)
 | |
| 
 | |
|     # Boss Rewards
 | |
|     regions["Castle Hamson"].locations.append("Castle Hamson Boss Reward")
 | |
|     regions["Forest Abkhazia"].locations.append("Forest Abkhazia Boss Reward")
 | |
|     regions["The Maya"].locations.append("The Maya Boss Reward")
 | |
|     regions["Land of Darkness"].locations.append("Land of Darkness Boss Reward")
 | |
| 
 | |
|     # Events
 | |
|     regions["Castle Hamson"].locations.append("Castle Hamson Boss Room")
 | |
|     regions["Forest Abkhazia"].locations.append("Forest Abkhazia Boss Room")
 | |
|     regions["The Maya"].locations.append("The Maya Boss Room")
 | |
|     regions["Land of Darkness"].locations.append("Land of Darkness Boss Room")
 | |
|     regions["The Fountain Room"].locations.append("Fountain Room")
 | |
| 
 | |
|     # Chests
 | |
|     chests = int(world.chests_per_zone[player])
 | |
|     for i in range(0, chests):
 | |
|         if world.universal_chests[player]:
 | |
|             regions["Castle Hamson"].locations.append(f"Chest {i + 1}")
 | |
|             regions["Forest Abkhazia"].locations.append(f"Chest {i + 1 + chests}")
 | |
|             regions["The Maya"].locations.append(f"Chest {i + 1 + (chests * 2)}")
 | |
|             regions["Land of Darkness"].locations.append(f"Chest {i + 1 + (chests * 3)}")
 | |
|         else:
 | |
|             regions["Castle Hamson"].locations.append(f"Castle Hamson - Chest {i + 1}")
 | |
|             regions["Forest Abkhazia"].locations.append(f"Forest Abkhazia - Chest {i + 1}")
 | |
|             regions["The Maya"].locations.append(f"The Maya - Chest {i + 1}")
 | |
|             regions["Land of Darkness"].locations.append(f"Land of Darkness - Chest {i + 1}")
 | |
| 
 | |
|     # Fairy Chests
 | |
|     chests = int(world.fairy_chests_per_zone[player])
 | |
|     for i in range(0, chests):
 | |
|         if world.universal_fairy_chests[player]:
 | |
|             regions["Castle Hamson"].locations.append(f"Fairy Chest {i + 1}")
 | |
|             regions["Forest Abkhazia"].locations.append(f"Fairy Chest {i + 1 + chests}")
 | |
|             regions["The Maya"].locations.append(f"Fairy Chest {i + 1 + (chests * 2)}")
 | |
|             regions["Land of Darkness"].locations.append(f"Fairy Chest {i + 1 + (chests * 3)}")
 | |
|         else:
 | |
|             regions["Castle Hamson"].locations.append(f"Castle Hamson - Fairy Chest {i + 1}")
 | |
|             regions["Forest Abkhazia"].locations.append(f"Forest Abkhazia - Fairy Chest {i + 1}")
 | |
|             regions["The Maya"].locations.append(f"The Maya - Fairy Chest {i + 1}")
 | |
|             regions["Land of Darkness"].locations.append(f"Land of Darkness - Fairy Chest {i + 1}")
 | |
| 
 | |
|     # Set up the regions correctly.
 | |
|     for name, data in regions.items():
 | |
|         world.regions.append(create_region(world, player, name, data.locations, data.exits))
 | |
| 
 | |
|     world.get_entrance("Castle Hamson", player).connect(world.get_region("Castle Hamson", player))
 | |
|     world.get_entrance("The Manor", player).connect(world.get_region("The Manor", player))
 | |
|     world.get_entrance("Forest Abkhazia", player).connect(world.get_region("Forest Abkhazia", player))
 | |
|     world.get_entrance("The Maya", player).connect(world.get_region("The Maya", player))
 | |
|     world.get_entrance("Land of Darkness", player).connect(world.get_region("Land of Darkness", player))
 | |
|     world.get_entrance("The Fountain Room", player).connect(world.get_region("The Fountain Room", player))
 | |
| 
 | |
| 
 | |
| def create_region(world: MultiWorld, player: int, name: str, locations=None, exits=None):
 | |
|     ret = Region(name, RegionType.Generic, name, player)
 | |
|     ret.multiworld = world
 | |
|     if locations:
 | |
|         for loc_name in locations:
 | |
|             loc_data = location_table.get(loc_name)
 | |
|             location = RLLocation(player, loc_name, loc_data.code if loc_data else None, ret)
 | |
| 
 | |
|             # Special rule handling for fairy chests.
 | |
|             if "Fairy" in loc_name:
 | |
|                 location.access_rule = lambda state: state.has("Dragons", player) or (
 | |
|                         state.has("Enchantress", player) and (
 | |
|                         state.has("Vault Runes", player) or
 | |
|                         state.has("Sprint Runes", player) or
 | |
|                         state.has("Sky Runes", player)))
 | |
|             ret.locations.append(location)
 | |
|     if exits:
 | |
|         for exit in exits:
 | |
|             entrance = Entrance(player, exit, ret)
 | |
|             ret.exits.append(entrance)
 | |
|     return ret
 | |
| 
 | |
| 
 |