From 5c8e8cfc70ddbd9acadf040618d2143c31eac3a1 Mon Sep 17 00:00:00 2001 From: Ehseezed <97066152+Ehseezed@users.noreply.github.com> Date: Mon, 23 Sep 2024 11:08:51 -0500 Subject: [PATCH] Swap regions to new method --- worlds/am2r/options.py | 32 ++++--- worlds/am2r/regions.py | 192 +++++++++-------------------------------- 2 files changed, 63 insertions(+), 161 deletions(-) diff --git a/worlds/am2r/options.py b/worlds/am2r/options.py index 77f14fb74451..064c5934eebf 100644 --- a/worlds/am2r/options.py +++ b/worlds/am2r/options.py @@ -29,21 +29,33 @@ class AmmoLogic(Choice): alias_easy = 0 +class MetroidsInPool(Range): + """Chose how many Metroids are in the item pool""" + display_name = "Metroids in Pool" + range_start = 0 + range_end = 100 + default = 25 + + class MetroidsRequired(Range): """Chose how many Metroids need to be killed or obtained to go through to the omega nest""" - display_name = "Metroids Required for Omega Nest" + display_name = "Metroids Required" range_start = 0 - range_end = 46 - default = 46 + range_end = 100 + default = 20 -class MetroidsAreChecks(Choice): # I kinda want to explode this option and have it always be on - """Have each of the 46 non lab Metroids be treated as locations""" - display_name = "Metroids are Checks" +class LocationSettings(Choice): + """Chose what items you want in the pool + not including checks via the no_A6 will force them to be excluded + not adding Metroids will force them to be vanilla and will not randomize them into item locations + adding metroids but excluding A6 will leave the A6 and omega nest metroids vanilla but will leave the full amount in the pool""" + display_name = "Locations to Check" default = 2 - option_disabled = 0 - option_exclude_A6 = 1 - option_include_A6 = 2 + option_items_no_A6 = 0 + option_items_and_A6 = 1 + option_add_metroids_no_A6 = 2 + option_add_metroids_and_A6 = 3 class StartLocation(Toggle): @@ -141,7 +153,7 @@ class AM2ROptions(PerGameCommonOptions): logic_dificulty: LogicDificulty ammo_logic: AmmoLogic metroids_required: MetroidsRequired - metroids_are_checks: MetroidsAreChecks + location_settings: LocationSettings start_location: StartLocation area_rando: AreaRando remove_power_grip: RemovePowerGrip diff --git a/worlds/am2r/regions.py b/worlds/am2r/regions.py index 6f1984592314..d39b7cd67094 100644 --- a/worlds/am2r/regions.py +++ b/worlds/am2r/regions.py @@ -1,154 +1,32 @@ -from typing import List, Set, Dict, Tuple, Optional, Callable, NamedTuple -from BaseClasses import CollectionState, MultiWorld, Region, Entrance, Location -from .locations import AM2RLocationData, get_location_datas -from .rules import AM2RLogic - -EventId: Optional[int] = None - - -class LocationData(NamedTuple): - region: str - name: str - code: Optional[int] - rule: Callable[[CollectionState], bool] = lambda state: True - - -def create_regions_and_locations(world: MultiWorld, player: int): - location_datas: Tuple[AM2RLocationData] = get_location_datas(world, player) - - locations_per_region: Dict[str, List[AM2RLocationData]] = split_location_datas_per_region(location_datas) - - regions = [ - create_region(world, player, locations_per_region, "Menu"), - create_region(world, player, locations_per_region, "Main Caves"), - create_region(world, player, locations_per_region, "First Alpha"), - create_region(world, player, locations_per_region, "Guardian"), - create_region(world, player, locations_per_region, "Golden Temple"), - create_region(world, player, locations_per_region, "Golden Temple Nest"), - create_region(world, player, locations_per_region, "Hydro Station"), - create_region(world, player, locations_per_region, "Inner Hydro Station"), - create_region(world, player, locations_per_region, "Hydro Nest"), - create_region(world, player, locations_per_region, "Arachnus"), - create_region(world, player, locations_per_region, "Mines"), - create_region(world, player, locations_per_region, "Industrial Complex Nest"), - create_region(world, player, locations_per_region, "Pre Industrial Complex"), - create_region(world, player, locations_per_region, "Industrial Complex"), - create_region(world, player, locations_per_region, "Torizo Ascended"), - create_region(world, player, locations_per_region, "The Tower"), - create_region(world, player, locations_per_region, "Geothermal"), - create_region(world, player, locations_per_region, "Tester"), - create_region(world, player, locations_per_region, "Tester Upper"), - create_region(world, player, locations_per_region, "Tester Lower"), - create_region(world, player, locations_per_region, "Underwater Distribution Center"), - create_region(world, player, locations_per_region, "Underwater Distro Connection"), - create_region(world, player, locations_per_region, "Serris"), - create_region(world, player, locations_per_region, "Ice Beam"), - create_region(world, player, locations_per_region, "Pipe Hell BL"), - create_region(world, player, locations_per_region, "Pipe Hell BR"), - create_region(world, player, locations_per_region, "Pipe Hell L"), - create_region(world, player, locations_per_region, "Pipe Hell R"), - create_region(world, player, locations_per_region, "Pipe Hell Outside"), - create_region(world, player, locations_per_region, "Fast Travel"), - create_region(world, player, locations_per_region, "Gravity"), - create_region(world, player, locations_per_region, "EMP"), - create_region(world, player, locations_per_region, "Screw Attack"), - create_region(world, player, locations_per_region, "GFS Thoth"), - create_region(world, player, locations_per_region, "Genesis"), - create_region(world, player, locations_per_region, "Deep Caves"), - create_region(world, player, locations_per_region, "Omega Nest"), - create_region(world, player, locations_per_region, "The Lab"), - create_region(world, player, locations_per_region, "Research Station") - ] - - if __debug__: - throwIfAnyLocationIsNotAssignedToARegion(regions, locations_per_region.keys()) - - world.regions += regions - - logic = AM2RLogic(world, player) - - connect(world, player, "Menu", "Main Caves"), - - connect(world, player, "Main Caves", "Guardian"), - connect(world, player, "Guardian", "Main Caves"), - - connect(world, player, "Main Caves", "First Alpha"), - connect(world, player, "First Alpha", "Main Caves"), - - connect(world, player, "Main Caves", "Hydro Station"), - connect(world, player, "Hydro Station", "Main Caves"), - - connect(world, player, "Main Caves", "Mines", lambda state: state.has("Super Missile", player)), - connect(world, player, "Mines", "Main Caves"), - - connect(world, player, "Main Caves", "Industrial Complex Nest"), - connect(world, player, "Industrial Complex Nest", "Main Caves"), - - connect(world, player, "Main Caves", "The Tower"), - connect(world, player, "The Tower", "Main Caves"), - - connect(world, player, "Main Caves", "Underwater Distribution Center", lambda state: (state.has("Power Bomb", player) or state.has("Super Missile", player)) and state.has("Ice Beam", player)), # when s&q is fixed, remove ice beam - connect(world, player, "Underwater Distribution Center", "Main Caves", lambda state: state.has("Ice Beam", player)), - - connect(world, player, "Main Caves", "Deep Caves", logic.AM2R_can_down), - connect(world, player, "Deep Caves", "Main Caves"), - - connect(world, player, "Main Caves", "GFS Thoth"), - connect(world, player, "GFS Thoth", "Main Caves"), - - connect(world, player, "GFS Thoth", "Genesis") - connect(world, player, "GFS Thoth", "Genesis") - - connect(world, player, "Guardian", "Golden Temple"), - connect(world, player, "Golden Temple", "Guardian"), - - connect(world, player, "Guardian", "Golden Temple Nest"), - connect(world, player, "Golden Temple Nest", "Guardian"), - - connect(world, player, "Golden Temple", "Fast Travel", lambda state: state.has("Screw Attack", player)), - connect(world, player, "Fast Travel", "Golden Temple", lambda state: state.has("Screw Attack", player)), - - connect(world, player, "Hydro Station", "Hydro Nest", logic.AM2R_can_jump), - connect(world, player, "Hydro Nest", "Hydro Station"), - - connect(world, player, "Hydro Station", "The Tower", lambda state: state.has("Screw Attack", player)), - connect(world, player, "The Tower", "Hydro Station", lambda state: state.has("Screw Attack", player)), - - connect(world, player, "Hydro Station", "The Lab", logic.AM2R_can_lab), - connect(world, player, "The Lab", "Hydro Station", lambda state: state.has("Screw Attack", player)), - - connect(world, player, "Hydro Station", "Arachnus", lambda state: state.has("Power Bomb", player, 4) or state.has("Bombs", player)), - connect(world, player, "Arachnus", "Hydro Station"), - - connect(world, player, "Hydro Station", "Inner Hydro Station", lambda state: state.has("Screw Attack", player) or logic.AM2R_can_bomb(state)) - connect(world, player, "Inner Hydro Station", "Hydro Station", lambda state: state.has("Screw Attack", player) or logic.AM2R_can_bomb(state)) - - connect(world, player, "Industrial Complex Nest", "Pre Industrial Complex", lambda state: state.has("Speed Booster", player) or logic.AM2R_can_bomb(state)), - connect(world, player, "Pre Industrial Complex", "Industrial Complex Nest", lambda state: state.has("Speed Booster", player) or logic.AM2R_can_bomb(state)), - - connect(world, player, "Pre Industrial Complex", "Industrial Complex"), - connect(world, player, "Industrial Complex", "Pre Industrial Complex", lambda state: state.has("Speed Booster", player)), - - connect(world, player, "Pre Industrial Complex", "Fast Travel", lambda state: state.has("Screw Attack", player)), - connect(world, player, "Fast Travel", "Pre Industrial Complex", lambda state: state.has("Screw Attack", player)), - - connect(world, player, "Pre Industrial Complex", "Torizo Ascended"), - connect(world, player, "Torizo Ascended", "Pre Industrial Complex"), - # A4 to Geothermal - connect(world, player, "The Tower", "Geothermal", lambda state: state.has("Speed Booster", player) and state.has("Power Bomb", player)), - connect(world, player, "Geothermal", "The Tower", lambda state: state.has("Speed Booster", player) and state.has("Power Bomb", player)), - # tower to A5 - connect(world, player, "The Tower", "Fast Travel", lambda state: state.has("Screw Attack", player)), - connect(world, player, "Fast Travel", "The Tower", lambda state: state.has("Screw Attack", player)), - # tester - connect(world, player, "The Tower", "Tester Lower", logic.AM2R_can_bomb), - connect(world, player, "The Tower", "Tester Upper", logic.AM2R_can_bomb), - connect(world, player, "Tester Lower", "Tester"), - connect(world, player, "Tester", "Tester Lower"), - connect(world, player, "Tester", "Tester Upper"), - connect(world, player, "Tester Upper", "Tester"), - connect(world, player, "Tester Lower", "The Tower", logic.AM2R_can_bomb), - connect(world, player, "Tester Upper", "The Tower", logic.AM2R_can_bomb), +from typing import List, Tuple, Dict, Set, Optional, Callable + + +am2r_regions: Dict[str, Set[str]] = { + "Menu": {"Main Caves"}, + "Main Caves": {"Guardian", "First Alpha", "Hydro Station", "Mines", "Industrial Complex Nest", "Lower Main Caves" + "GFS Thoth"}, + "Lower Main Caves": {"The Tower", "Underwater Distribution Center", "Deep Caves"}, + "GFS Thoth": {"Genesis"}, + "Guardian": {"Golden Temple", "Golden Temple Nest"}, + "Golden Temple": set(), + "Golden Temple Nest": set(), + "First Alpha": set(), + "Hydro Station": {"Hydro Nest", "The Tower", "The Lab", "Arachnus", "Inner Hydro Station"}, + "Hydro Nest": set(), + "Arachnus": set(), + "Inner Hydro Station": set(), + "Industrial Complex Nest": {"Pre Industrial Complex"}, + "Pre Industrial Complex": {"Industrial Complex", "Torizo Ascended"}, + "Torizo Ascended": set(), + "Industrial Complex": set(), + "Mines": set(), + "The Tower": {"Tester Lower", "Tester Upper", "Geothermal"}, + "Tester Lower": {"Tester"}, + "Tester Upper": {"Tester"}, + "Tester": set(), + "Geothermal": set(), + "" +} # A5 connect(world, player, "Underwater Distribution Center", "EMP", logic.AM2R_can_bomb), connect(world, player, "EMP", "Underwater Distribution Center", logic.AM2R_can_bomb), @@ -265,3 +143,15 @@ def split_location_datas_per_region(locations: Tuple[LocationData, ...]) -> Dict per_region.setdefault(location.region, []).append(location) return per_region + +from typing import Dict, Set + +snailiad_regions: Dict[str, Set[str]] = { + "Menu": {"Snail Town"}, + "Snail Town": {"Mare Carelia", "Spiralis Silere", "Amastrida Abyssus", "Lux Lirata", "Shrine of Iris"}, + "Mare Carelia": {"Spiralis Silere"}, + "Spiralis Silere": {"Amastrida Abyssus"}, + "Amastrida Abyssus": {"Lux Lirata"}, + "Lux Lirata": set(), + "Shrine of Iris": set() +} \ No newline at end of file