Skip to content

Commit

Permalink
client-side entrance randomizer
Browse files Browse the repository at this point in the history
  • Loading branch information
nbrochu committed Feb 27, 2025
1 parent bca2dc0 commit b4b1c87
Show file tree
Hide file tree
Showing 8 changed files with 278 additions and 115 deletions.
12 changes: 12 additions & 0 deletions worlds/zork_grand_inquisitor/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
id_to_client_seed_information,
id_to_craftable_spell_behaviors,
id_to_deathsanity,
id_to_entrance_randomizer,
id_to_hotspots,
id_to_items,
id_to_landmarksanity,
Expand Down Expand Up @@ -174,6 +175,14 @@ def on_package(self, cmd: str, _args: Any) -> None:
id_to_landmarksanity()[_args["slot_data"]["landmarksanity"]]
)

self.game_controller.option_entrance_randomizer = (
id_to_entrance_randomizer()[_args["slot_data"]["entrance_randomizer"]]
)

self.game_controller.option_entrance_randomizer_include_subway_destinations = (
_args["slot_data"]["entrance_randomizer_include_subway_destinations"] == 1
)

self.game_controller.option_trap_percentage = _args["slot_data"]["trap_percentage"]

self.game_controller.option_grant_missable_location_checks = (
Expand All @@ -197,6 +206,9 @@ def on_package(self, cmd: str, _args: Any) -> None:
_args["slot_data"]["initial_totemizer_destination"]
]

# Entrance Randomizer Data
self.game_controller.entrance_randomizer_data = _args["slot_data"]["entrance_randomizer_data"]

# Save IDs
self.game_controller.save_ids = tuple(_args["slot_data"]["save_ids"])

Expand Down
5 changes: 4 additions & 1 deletion worlds/zork_grand_inquisitor/data/entrance_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@
),
),
(ZorkGrandInquisitorRegions.HADES, ZorkGrandInquisitorRegions.HADES_SHORE): (
(ZorkGrandInquisitorItems.POUCH_OF_ZORKMIDS,),
(
ZorkGrandInquisitorItems.POUCH_OF_ZORKMIDS,
ZorkGrandInquisitorItems.SPELL_SNAVIG,
),
),
(ZorkGrandInquisitorRegions.HADES_BEYOND_GATES, ZorkGrandInquisitorRegions.DRAGON_ARCHIPELAGO): (
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
(ZGIRegions.SUBWAY_MONASTERY, ZGIRegions.SUBWAY_HADES),
)

relevant_game_locations: Set[str] = set()
relevant_game_locations: Set[str] = {"cd20", "qs1e", "sg60"}

entrance_pairs: Tuple[Tuple[str, str]]
for entrance_pairs in entrances_to_game_locations.values():
Expand Down
2 changes: 1 addition & 1 deletion worlds/zork_grand_inquisitor/data/location_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@ class ZorkGrandInquisitorLocationData(NamedTuple):
tags=(ZorkGrandInquisitorTags.CORE,),
),
ZorkGrandInquisitorLocations.OPEN_THE_GATES_OF_HELL: ZorkGrandInquisitorLocationData(
game_state_trigger=((8730, 1),),
game_state_trigger=((8651, 1),),
archipelago_id=LOCATION_OFFSET + 90,
region=ZorkGrandInquisitorRegions.HADES,
tags=(ZorkGrandInquisitorTags.CORE,),
Expand Down
5 changes: 5 additions & 0 deletions worlds/zork_grand_inquisitor/data/mapping_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
ZorkGrandInquisitorClientSeedInformation,
ZorkGrandInquisitorCraftableSpellBehaviors,
ZorkGrandInquisitorDeathsanity,
ZorkGrandInquisitorEntranceRandomizer,
ZorkGrandInquisitorGoals,
ZorkGrandInquisitorHotspots,
ZorkGrandInquisitorItems,
Expand Down Expand Up @@ -665,6 +666,7 @@
Union[
ZorkGrandInquisitorCraftableSpellBehaviors,
ZorkGrandInquisitorDeathsanity,
ZorkGrandInquisitorEntranceRandomizer,
ZorkGrandInquisitorGoals,
ZorkGrandInquisitorHotspots,
ZorkGrandInquisitorLandmarksanity,
Expand All @@ -680,6 +682,9 @@
ZorkGrandInquisitorCraftableSpellBehaviors.ANYTHING: "Anything",
ZorkGrandInquisitorDeathsanity.OFF: "Off",
ZorkGrandInquisitorDeathsanity.ON: "On",
ZorkGrandInquisitorEntranceRandomizer.DISABLED: "Disabled",
ZorkGrandInquisitorEntranceRandomizer.COUPLED: "Enabled (Coupled Entrances)",
ZorkGrandInquisitorEntranceRandomizer.UNCOUPLED: "Enabled (Uncoupled Entrances)",
ZorkGrandInquisitorGoals.THREE_ARTIFACTS: "Three Artifacts",
ZorkGrandInquisitorGoals.ARTIFACT_OF_MAGIC_HUNT: "Artifact of Magic Hunt",
ZorkGrandInquisitorGoals.SPELL_HEIST: "Spell Heist",
Expand Down
341 changes: 232 additions & 109 deletions worlds/zork_grand_inquisitor/game_controller.py

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions worlds/zork_grand_inquisitor/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ class GrantMissableLocationChecks(Toggle):
Otherwise, the player is expected to potentially have to use the save system to reach those location checks. If you
don't like the idea of rarely having to reload an earlier save to get a location check, make sure this option is
enabled.
Note: This option is incompatible with the entrance randomizer and will be forced off in the scenario where
entrances are randomized.
"""

display_name: str = "Grant Missable Checks"
Expand Down
23 changes: 20 additions & 3 deletions worlds/zork_grand_inquisitor/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,15 @@ def generate_early(self) -> None:

self.grant_missable_location_checks = bool(self.options.grant_missable_location_checks)

if self.grant_missable_location_checks:
if self.entrance_randomizer != ZorkGrandInquisitorEntranceRandomizer.DISABLED:
self.grant_missable_location_checks = False

logging.warning(
f"Zork Grand Inquisitor: {self.player_name} wants to grant missable location checks but "
"has the entrance randomizer enabled. Disabling the grantinmg of missable location checks..."
)

self.entrance_rule_data = entrance_rule_data

self.item_data = prepare_item_data(
Expand Down Expand Up @@ -621,6 +630,8 @@ def interpret_slot_data(slot_data: Dict[str, Any]) -> Dict[str, Any]:
slot_data["deathsanity"] = id_to_deathsanity()[slot_data["deathsanity"]]
slot_data["landmarksanity"] = id_to_landmarksanity()[slot_data["landmarksanity"]]
slot_data["entrance_randomizer"] = id_to_entrance_randomizer()[slot_data["entrance_randomizer"]]
slot_data["entrance_randomizer_include_subway_destinations"] = bool(slot_data["entrance_randomizer"])

slot_data["starter_kit"] = tuple([ZorkGrandInquisitorItems(item) for item in slot_data["starter_kit"]])

slot_data["initial_totemizer_destination"] = ZorkGrandInquisitorItems(
Expand All @@ -646,6 +657,10 @@ def _apply_ut_passthrough(self) -> None:
self.landmarksanity = passthrough["landmarksanity"]
self.entrance_randomizer = passthrough["entrance_randomizer"]

self.entrance_randomizer_include_subway_destinations = passthrough[
"entrance_randomizer_include_subway_destinations"
]

self.item_data = prepare_item_data(
self.starting_location,
self.goal,
Expand All @@ -666,15 +681,17 @@ def _apply_ut_passthrough(self) -> None:
self.trap_percentage = passthrough["trap_percentage"] / 100
self.trap_weights = passthrough["trap_weights"]

def _prepare_entrance_randomizer_slot_data(self) -> Dict[Tuple[str, str], Tuple[str, str]]:
entrance_randomizer_slot_data: Dict[Tuple[str, str], Tuple[str, str]] = dict()
def _prepare_entrance_randomizer_slot_data(self) -> Dict[str, str]:
entrance_randomizer_slot_data: Dict[str, str] = dict()

entrance_from: Tuple[ZorkGrandInquisitorRegions, ZorkGrandInquisitorRegions]
entrance_to: Tuple[ZorkGrandInquisitorRegions, ZorkGrandInquisitorRegions]
for entrance_from, entrance_to in self.entrance_randomizer_pairings.items():
game_locations_pair: Tuple[str, str]
for game_locations_pair in entrances_to_game_locations[entrance_from]:
entrance_randomizer_slot_data[game_locations_pair] = entrances_to_game_location_teleports[entrance_to]
entrance_randomizer_slot_data["-".join(game_locations_pair)] = (
" ".join(entrances_to_game_location_teleports[entrance_to])
)

return entrance_randomizer_slot_data

Expand Down

0 comments on commit b4b1c87

Please sign in to comment.