mirror of
https://github.com/MarioSpore/Grinch-AP.git
synced 2025-10-21 20:21:32 -06:00
The Messenger: do all empty state validation during portal shuffle (#4971)
This commit is contained in:
@@ -16,8 +16,8 @@ from .portals import PORTALS, add_closed_portal_reqs, disconnect_portals, shuffl
|
|||||||
from .regions import LEVELS, MEGA_SHARDS, LOCATIONS, REGION_CONNECTIONS
|
from .regions import LEVELS, MEGA_SHARDS, LOCATIONS, REGION_CONNECTIONS
|
||||||
from .rules import MessengerHardRules, MessengerOOBRules, MessengerRules
|
from .rules import MessengerHardRules, MessengerOOBRules, MessengerRules
|
||||||
from .shop import FIGURINES, PROG_SHOP_ITEMS, SHOP_ITEMS, USEFUL_SHOP_ITEMS, shuffle_shop_prices
|
from .shop import FIGURINES, PROG_SHOP_ITEMS, SHOP_ITEMS, USEFUL_SHOP_ITEMS, shuffle_shop_prices
|
||||||
from .subclasses import MessengerEntrance, MessengerItem, MessengerRegion, MessengerShopLocation
|
from .subclasses import MessengerItem, MessengerRegion, MessengerShopLocation
|
||||||
from .transitions import shuffle_transitions
|
from .transitions import disconnect_entrances, shuffle_transitions
|
||||||
|
|
||||||
components.append(
|
components.append(
|
||||||
Component("The Messenger", component_type=Type.CLIENT, func=launch_game, game_name="The Messenger", supports_uri=True)
|
Component("The Messenger", component_type=Type.CLIENT, func=launch_game, game_name="The Messenger", supports_uri=True)
|
||||||
@@ -266,6 +266,8 @@ class MessengerWorld(World):
|
|||||||
# MessengerOOBRules(self).set_messenger_rules()
|
# MessengerOOBRules(self).set_messenger_rules()
|
||||||
|
|
||||||
def connect_entrances(self) -> None:
|
def connect_entrances(self) -> None:
|
||||||
|
if self.options.shuffle_transitions:
|
||||||
|
disconnect_entrances(self)
|
||||||
add_closed_portal_reqs(self)
|
add_closed_portal_reqs(self)
|
||||||
# i need portal shuffle to happen after rules exist so i can validate it
|
# i need portal shuffle to happen after rules exist so i can validate it
|
||||||
attempts = 5
|
attempts = 5
|
||||||
|
@@ -292,12 +292,10 @@ def disconnect_portals(world: "MessengerWorld") -> None:
|
|||||||
|
|
||||||
|
|
||||||
def validate_portals(world: "MessengerWorld") -> bool:
|
def validate_portals(world: "MessengerWorld") -> bool:
|
||||||
if world.options.shuffle_transitions:
|
new_state = CollectionState(world.multiworld, True)
|
||||||
return True
|
|
||||||
new_state = CollectionState(world.multiworld)
|
|
||||||
new_state.update_reachable_regions(world.player)
|
new_state.update_reachable_regions(world.player)
|
||||||
reachable_locs = 0
|
reachable_locs = 0
|
||||||
for loc in world.multiworld.get_locations(world.player):
|
for loc in world.get_locations():
|
||||||
reachable_locs += loc.can_reach(new_state)
|
reachable_locs += loc.can_reach(new_state)
|
||||||
if reachable_locs > 5:
|
if reachable_locs > 5:
|
||||||
return True
|
return True
|
||||||
|
@@ -10,25 +10,8 @@ if TYPE_CHECKING:
|
|||||||
from . import MessengerWorld
|
from . import MessengerWorld
|
||||||
|
|
||||||
|
|
||||||
class MessengerEntrance(Entrance):
|
|
||||||
world: "MessengerWorld | None" = None
|
|
||||||
|
|
||||||
def can_connect_to(self, other: Entrance, dead_end: bool, state: "ERPlacementState") -> bool:
|
|
||||||
can_connect = super().can_connect_to(other, dead_end, state)
|
|
||||||
world: MessengerWorld = getattr(self, "world", None)
|
|
||||||
if not world or world.reachable_locs or not can_connect:
|
|
||||||
return can_connect
|
|
||||||
empty_state = CollectionState(world.multiworld, True)
|
|
||||||
self.connected_region = other.connected_region
|
|
||||||
empty_state.update_reachable_regions(world.player)
|
|
||||||
world.reachable_locs = any(loc.can_reach(empty_state) and not loc.is_event for loc in world.get_locations())
|
|
||||||
self.connected_region = None
|
|
||||||
return world.reachable_locs and (not state.coupled or self.name != other.name)
|
|
||||||
|
|
||||||
|
|
||||||
class MessengerRegion(Region):
|
class MessengerRegion(Region):
|
||||||
parent: str | None
|
parent: str | None
|
||||||
entrance_type = MessengerEntrance
|
|
||||||
|
|
||||||
def __init__(self, name: str, world: "MessengerWorld", parent: str | None = None) -> None:
|
def __init__(self, name: str, world: "MessengerWorld", parent: str | None = None) -> None:
|
||||||
super().__init__(name, world.player, world.multiworld)
|
super().__init__(name, world.player, world.multiworld)
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from BaseClasses import Region
|
from BaseClasses import Entrance, Region
|
||||||
from entrance_rando import EntranceType, randomize_entrances
|
from entrance_rando import EntranceType, randomize_entrances
|
||||||
from .connections import RANDOMIZED_CONNECTIONS, TRANSITIONS
|
from .connections import RANDOMIZED_CONNECTIONS, TRANSITIONS
|
||||||
from .options import ShuffleTransitions, TransitionPlando
|
from .options import ShuffleTransitions, TransitionPlando
|
||||||
@@ -9,6 +9,33 @@ if TYPE_CHECKING:
|
|||||||
from . import MessengerWorld
|
from . import MessengerWorld
|
||||||
|
|
||||||
|
|
||||||
|
def disconnect_entrances(world: "MessengerWorld") -> None:
|
||||||
|
def disconnect_entrance() -> None:
|
||||||
|
child = entrance.connected_region.name
|
||||||
|
child_region = entrance.connected_region
|
||||||
|
child_region.entrances.remove(entrance)
|
||||||
|
entrance.connected_region = None
|
||||||
|
|
||||||
|
er_type = EntranceType.ONE_WAY if child == "Glacial Peak - Left" else \
|
||||||
|
EntranceType.TWO_WAY if child in RANDOMIZED_CONNECTIONS else EntranceType.ONE_WAY
|
||||||
|
if er_type == EntranceType.TWO_WAY:
|
||||||
|
mock_entrance = entrance.parent_region.create_er_target(entrance.name)
|
||||||
|
else:
|
||||||
|
mock_entrance = child_region.create_er_target(child)
|
||||||
|
|
||||||
|
entrance.randomization_type = er_type
|
||||||
|
mock_entrance.randomization_type = er_type
|
||||||
|
|
||||||
|
|
||||||
|
for parent, child in RANDOMIZED_CONNECTIONS.items():
|
||||||
|
if child == "Corrupted Future":
|
||||||
|
entrance = world.get_entrance("Artificer's Portal")
|
||||||
|
elif child == "Tower of Time - Left":
|
||||||
|
entrance = world.get_entrance("Artificer's Challenge")
|
||||||
|
else:
|
||||||
|
entrance = world.get_entrance(f"{parent} -> {child}")
|
||||||
|
disconnect_entrance()
|
||||||
|
|
||||||
def connect_plando(world: "MessengerWorld", plando_connections: TransitionPlando) -> None:
|
def connect_plando(world: "MessengerWorld", plando_connections: TransitionPlando) -> None:
|
||||||
def remove_dangling_exit(region: Region) -> None:
|
def remove_dangling_exit(region: Region) -> None:
|
||||||
# find the disconnected exit and remove references to it
|
# find the disconnected exit and remove references to it
|
||||||
@@ -59,32 +86,6 @@ def connect_plando(world: "MessengerWorld", plando_connections: TransitionPlando
|
|||||||
def shuffle_transitions(world: "MessengerWorld") -> None:
|
def shuffle_transitions(world: "MessengerWorld") -> None:
|
||||||
coupled = world.options.shuffle_transitions == ShuffleTransitions.option_coupled
|
coupled = world.options.shuffle_transitions == ShuffleTransitions.option_coupled
|
||||||
|
|
||||||
def disconnect_entrance() -> None:
|
|
||||||
child_region.entrances.remove(entrance)
|
|
||||||
entrance.connected_region = None
|
|
||||||
|
|
||||||
er_type = EntranceType.ONE_WAY if child == "Glacial Peak - Left" else \
|
|
||||||
EntranceType.TWO_WAY if child in RANDOMIZED_CONNECTIONS else EntranceType.ONE_WAY
|
|
||||||
if er_type == EntranceType.TWO_WAY:
|
|
||||||
mock_entrance = parent_region.create_er_target(entrance.name)
|
|
||||||
else:
|
|
||||||
mock_entrance = child_region.create_er_target(child)
|
|
||||||
|
|
||||||
entrance.randomization_type = er_type
|
|
||||||
mock_entrance.randomization_type = er_type
|
|
||||||
|
|
||||||
for parent, child in RANDOMIZED_CONNECTIONS.items():
|
|
||||||
if child == "Corrupted Future":
|
|
||||||
entrance = world.get_entrance("Artificer's Portal")
|
|
||||||
elif child == "Tower of Time - Left":
|
|
||||||
entrance = world.get_entrance("Artificer's Challenge")
|
|
||||||
else:
|
|
||||||
entrance = world.get_entrance(f"{parent} -> {child}")
|
|
||||||
parent_region = entrance.parent_region
|
|
||||||
child_region = entrance.connected_region
|
|
||||||
entrance.world = world
|
|
||||||
disconnect_entrance()
|
|
||||||
|
|
||||||
plando = world.options.plando_connections
|
plando = world.options.plando_connections
|
||||||
if plando:
|
if plando:
|
||||||
connect_plando(world, plando)
|
connect_plando(world, plando)
|
||||||
|
Reference in New Issue
Block a user