Skip to content

Commit b4b1c87

Browse files
committed
client-side entrance randomizer
1 parent bca2dc0 commit b4b1c87

8 files changed

+278
-115
lines changed

worlds/zork_grand_inquisitor/client.py

+12
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
id_to_client_seed_information,
1414
id_to_craftable_spell_behaviors,
1515
id_to_deathsanity,
16+
id_to_entrance_randomizer,
1617
id_to_hotspots,
1718
id_to_items,
1819
id_to_landmarksanity,
@@ -174,6 +175,14 @@ def on_package(self, cmd: str, _args: Any) -> None:
174175
id_to_landmarksanity()[_args["slot_data"]["landmarksanity"]]
175176
)
176177

178+
self.game_controller.option_entrance_randomizer = (
179+
id_to_entrance_randomizer()[_args["slot_data"]["entrance_randomizer"]]
180+
)
181+
182+
self.game_controller.option_entrance_randomizer_include_subway_destinations = (
183+
_args["slot_data"]["entrance_randomizer_include_subway_destinations"] == 1
184+
)
185+
177186
self.game_controller.option_trap_percentage = _args["slot_data"]["trap_percentage"]
178187

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

209+
# Entrance Randomizer Data
210+
self.game_controller.entrance_randomizer_data = _args["slot_data"]["entrance_randomizer_data"]
211+
200212
# Save IDs
201213
self.game_controller.save_ids = tuple(_args["slot_data"]["save_ids"])
202214

worlds/zork_grand_inquisitor/data/entrance_data.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,10 @@
180180
),
181181
),
182182
(ZorkGrandInquisitorRegions.HADES, ZorkGrandInquisitorRegions.HADES_SHORE): (
183-
(ZorkGrandInquisitorItems.POUCH_OF_ZORKMIDS,),
183+
(
184+
ZorkGrandInquisitorItems.POUCH_OF_ZORKMIDS,
185+
ZorkGrandInquisitorItems.SPELL_SNAVIG,
186+
),
184187
),
185188
(ZorkGrandInquisitorRegions.HADES_BEYOND_GATES, ZorkGrandInquisitorRegions.DRAGON_ARCHIPELAGO): (
186189
(

worlds/zork_grand_inquisitor/data/entrance_randomizer_data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@
177177
(ZGIRegions.SUBWAY_MONASTERY, ZGIRegions.SUBWAY_HADES),
178178
)
179179

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

182182
entrance_pairs: Tuple[Tuple[str, str]]
183183
for entrance_pairs in entrances_to_game_locations.values():

worlds/zork_grand_inquisitor/data/location_data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ class ZorkGrandInquisitorLocationData(NamedTuple):
966966
tags=(ZorkGrandInquisitorTags.CORE,),
967967
),
968968
ZorkGrandInquisitorLocations.OPEN_THE_GATES_OF_HELL: ZorkGrandInquisitorLocationData(
969-
game_state_trigger=((8730, 1),),
969+
game_state_trigger=((8651, 1),),
970970
archipelago_id=LOCATION_OFFSET + 90,
971971
region=ZorkGrandInquisitorRegions.HADES,
972972
tags=(ZorkGrandInquisitorTags.CORE,),

worlds/zork_grand_inquisitor/data/mapping_data.py

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
ZorkGrandInquisitorClientSeedInformation,
55
ZorkGrandInquisitorCraftableSpellBehaviors,
66
ZorkGrandInquisitorDeathsanity,
7+
ZorkGrandInquisitorEntranceRandomizer,
78
ZorkGrandInquisitorGoals,
89
ZorkGrandInquisitorHotspots,
910
ZorkGrandInquisitorItems,
@@ -665,6 +666,7 @@
665666
Union[
666667
ZorkGrandInquisitorCraftableSpellBehaviors,
667668
ZorkGrandInquisitorDeathsanity,
669+
ZorkGrandInquisitorEntranceRandomizer,
668670
ZorkGrandInquisitorGoals,
669671
ZorkGrandInquisitorHotspots,
670672
ZorkGrandInquisitorLandmarksanity,
@@ -680,6 +682,9 @@
680682
ZorkGrandInquisitorCraftableSpellBehaviors.ANYTHING: "Anything",
681683
ZorkGrandInquisitorDeathsanity.OFF: "Off",
682684
ZorkGrandInquisitorDeathsanity.ON: "On",
685+
ZorkGrandInquisitorEntranceRandomizer.DISABLED: "Disabled",
686+
ZorkGrandInquisitorEntranceRandomizer.COUPLED: "Enabled (Coupled Entrances)",
687+
ZorkGrandInquisitorEntranceRandomizer.UNCOUPLED: "Enabled (Uncoupled Entrances)",
683688
ZorkGrandInquisitorGoals.THREE_ARTIFACTS: "Three Artifacts",
684689
ZorkGrandInquisitorGoals.ARTIFACT_OF_MAGIC_HUNT: "Artifact of Magic Hunt",
685690
ZorkGrandInquisitorGoals.SPELL_HEIST: "Spell Heist",

worlds/zork_grand_inquisitor/game_controller.py

+232-109
Large diffs are not rendered by default.

worlds/zork_grand_inquisitor/options.py

+3
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ class GrantMissableLocationChecks(Toggle):
317317
Otherwise, the player is expected to potentially have to use the save system to reach those location checks. If you
318318
don't like the idea of rarely having to reload an earlier save to get a location check, make sure this option is
319319
enabled.
320+
321+
Note: This option is incompatible with the entrance randomizer and will be forced off in the scenario where
322+
entrances are randomized.
320323
"""
321324

322325
display_name: str = "Grant Missable Checks"

worlds/zork_grand_inquisitor/world.py

+20-3
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,15 @@ def generate_early(self) -> None:
226226

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

229+
if self.grant_missable_location_checks:
230+
if self.entrance_randomizer != ZorkGrandInquisitorEntranceRandomizer.DISABLED:
231+
self.grant_missable_location_checks = False
232+
233+
logging.warning(
234+
f"Zork Grand Inquisitor: {self.player_name} wants to grant missable location checks but "
235+
"has the entrance randomizer enabled. Disabling the grantinmg of missable location checks..."
236+
)
237+
229238
self.entrance_rule_data = entrance_rule_data
230239

231240
self.item_data = prepare_item_data(
@@ -621,6 +630,8 @@ def interpret_slot_data(slot_data: Dict[str, Any]) -> Dict[str, Any]:
621630
slot_data["deathsanity"] = id_to_deathsanity()[slot_data["deathsanity"]]
622631
slot_data["landmarksanity"] = id_to_landmarksanity()[slot_data["landmarksanity"]]
623632
slot_data["entrance_randomizer"] = id_to_entrance_randomizer()[slot_data["entrance_randomizer"]]
633+
slot_data["entrance_randomizer_include_subway_destinations"] = bool(slot_data["entrance_randomizer"])
634+
624635
slot_data["starter_kit"] = tuple([ZorkGrandInquisitorItems(item) for item in slot_data["starter_kit"]])
625636

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

660+
self.entrance_randomizer_include_subway_destinations = passthrough[
661+
"entrance_randomizer_include_subway_destinations"
662+
]
663+
649664
self.item_data = prepare_item_data(
650665
self.starting_location,
651666
self.goal,
@@ -666,15 +681,17 @@ def _apply_ut_passthrough(self) -> None:
666681
self.trap_percentage = passthrough["trap_percentage"] / 100
667682
self.trap_weights = passthrough["trap_weights"]
668683

669-
def _prepare_entrance_randomizer_slot_data(self) -> Dict[Tuple[str, str], Tuple[str, str]]:
670-
entrance_randomizer_slot_data: Dict[Tuple[str, str], Tuple[str, str]] = dict()
684+
def _prepare_entrance_randomizer_slot_data(self) -> Dict[str, str]:
685+
entrance_randomizer_slot_data: Dict[str, str] = dict()
671686

672687
entrance_from: Tuple[ZorkGrandInquisitorRegions, ZorkGrandInquisitorRegions]
673688
entrance_to: Tuple[ZorkGrandInquisitorRegions, ZorkGrandInquisitorRegions]
674689
for entrance_from, entrance_to in self.entrance_randomizer_pairings.items():
675690
game_locations_pair: Tuple[str, str]
676691
for game_locations_pair in entrances_to_game_locations[entrance_from]:
677-
entrance_randomizer_slot_data[game_locations_pair] = entrances_to_game_location_teleports[entrance_to]
692+
entrance_randomizer_slot_data["-".join(game_locations_pair)] = (
693+
" ".join(entrances_to_game_location_teleports[entrance_to])
694+
)
678695

679696
return entrance_randomizer_slot_data
680697

0 commit comments

Comments
 (0)