Skip to content

Commit

Permalink
make the amount of needed landmarks and deaths configurable for zork …
Browse files Browse the repository at this point in the history
…tour and grim journey
  • Loading branch information
nbrochu committed Nov 25, 2024
1 parent 31fa87b commit c336529
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 13 deletions.
8 changes: 8 additions & 0 deletions worlds/zork_grand_inquisitor/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ def on_package(self, cmd: str, _args: Any) -> None:
_args["slot_data"]["artifacts_of_magic_total"]
)

self.game_controller.option_landmarks_required = (
_args["slot_data"]["landmarks_required"]
)

self.game_controller.option_deaths_required = (
_args["slot_data"]["deaths_required"]
)

self.game_controller.option_starting_location = (
id_to_starting_locations()[_args["slot_data"]["starting_location"]]
)
Expand Down
4 changes: 2 additions & 2 deletions worlds/zork_grand_inquisitor/data/entrance_rule_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,14 +546,14 @@
ZorkGrandInquisitorGoals.ZORK_TOUR: {
(ZorkGrandInquisitorRegions.PORT_FOOZLE, ZorkGrandInquisitorRegions.ENDGAME): (
(
[ZorkGrandInquisitorItems.LANDMARK, 20],
[ZorkGrandInquisitorItems.LANDMARK, 999], # Will get replaced with the actual number
),
),
},
ZorkGrandInquisitorGoals.GRIM_JOURNEY: {
(ZorkGrandInquisitorRegions.HADES_BEYOND_GATES, ZorkGrandInquisitorRegions.ENDGAME): (
(
[ZorkGrandInquisitorItems.DEATH, 22],
[ZorkGrandInquisitorItems.DEATH, 999], # Will get replaced with the actual number
),
),
},
Expand Down
18 changes: 17 additions & 1 deletion worlds/zork_grand_inquisitor/data_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@ def goal_access_rule_for(
goal: ZorkGrandInquisitorGoals,
player: int,
artifacts_of_magic_required: int,
landmarks_required: int,
deaths_required: int,
) -> str:
dataset: Dict[
Tuple[
Expand All @@ -427,14 +429,28 @@ def goal_access_rule_for(
],
] = endgame_entrance_data_by_goal[goal]

# Replace placeholder with actual number of artifacts of magic required
# Replace placeholder with actual number of goal items required
if goal == ZorkGrandInquisitorGoals.ARTIFACT_OF_MAGIC_HUNT:
dataset[
(
ZorkGrandInquisitorRegions.WALKING_CASTLE,
ZorkGrandInquisitorRegions.ENDGAME
)
][0][0][1] = artifacts_of_magic_required
elif goal == ZorkGrandInquisitorGoals.ZORK_TOUR:
dataset[
(
ZorkGrandInquisitorRegions.PORT_FOOZLE,
ZorkGrandInquisitorRegions.ENDGAME
)
][0][0][1] = landmarks_required
elif goal == ZorkGrandInquisitorGoals.GRIM_JOURNEY:
dataset[
(
ZorkGrandInquisitorRegions.HADES_BEYOND_GATES,
ZorkGrandInquisitorRegions.ENDGAME
)
][0][0][1] = deaths_required

return entrance_access_rule_for(
region,
Expand Down
30 changes: 20 additions & 10 deletions worlds/zork_grand_inquisitor/game_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class GameController:
option_goal: Optional[ZorkGrandInquisitorGoals]
option_artifacts_of_magic_required: Optional[int]
option_artifacts_of_magic_total: Optional[int]
option_landmarks_required: Optional[int]
option_deaths_required: Optional[int]
option_starting_location: Optional[ZorkGrandInquisitorStartingLocations]
option_hotspots: Optional[ZorkGrandInquisitorHotspots]
option_craftable_spells: Optional[ZorkGrandInquisitorCraftableSpellBehaviors]
Expand Down Expand Up @@ -131,6 +133,8 @@ def __init__(self, logger=None) -> None:
self.option_goal = None
self.option_artifacts_of_magic_required = None
self.option_artifacts_of_magic_total = None
self.option_landmarks_required = None
self.option_deaths_required = None
self.option_starting_location = None
self.option_hotspots = None
self.option_craftable_spells = None
Expand Down Expand Up @@ -226,6 +230,10 @@ def output_seed_information(self) -> None:
if self.option_goal == ZorkGrandInquisitorGoals.ARTIFACT_OF_MAGIC_HUNT:
self.log(f" Artifacts of Magic Required: {self.option_artifacts_of_magic_required}")
self.log(f" Artifacts of Magic Total: {self.option_artifacts_of_magic_total}")
elif self.option_goal == ZorkGrandInquisitorGoals.ZORK_TOUR:
self.log(f" Landmarks Required: {self.option_landmarks_required}")
elif self.option_goal == ZorkGrandInquisitorGoals.GRIM_JOURNEY:
self.log(f" Deaths Required: {self.option_deaths_required}")

self.log(f" Starting Location: {labels_for_enum_items[self.option_starting_location]}")
self.log(f" Hotspots: {labels_for_enum_items[self.option_hotspots]}")
Expand Down Expand Up @@ -277,25 +285,25 @@ def output_goal_item_update(self) -> None:

if self.option_goal == ZorkGrandInquisitorGoals.ARTIFACT_OF_MAGIC_HUNT:
self.log(
f"Received Artifact of Magic {self.goal_item_count} of {self.option_artifacts_of_magic_required}"
f"Received {self.goal_item_count} of {self.option_artifacts_of_magic_required} required Artifacts of Magic"
)

if self.goal_item_count >= self.option_artifacts_of_magic_required:
self.log("All needed Artifacts of Magic have been found! Get to the Walking Castle")
self.log("All needed Artifacts of Magic have been found! Get to the Walking Castle to win")
elif self.option_goal == ZorkGrandInquisitorGoals.ZORK_TOUR:
self.log(
f"Visited {self.goal_item_count} of 20 Landmarks"
f"Visited {self.goal_item_count} of {self.option_landmarks_required} required Landmarks"
)

if self.goal_item_count == 20:
self.log("All Landmarks have been visited! Get to the Port Foozle signpost")
if self.goal_item_count >= self.option_landmarks_required:
self.log("All needed Landmarks have been visited! Get to the Port Foozle signpost to win")
elif self.option_goal == ZorkGrandInquisitorGoals.GRIM_JOURNEY:
self.log(
f"Experienced {self.goal_item_count} of 22 Deaths"
f"Experienced {self.goal_item_count} of {self.option_deaths_required} required Deaths"
)

if self.goal_item_count == 22:
self.log("All Deaths have been experienced! Go beyond the gates of hell")
if self.goal_item_count >= self.option_deaths_required:
self.log("All needed Deaths have been experienced! Go beyond the gates of hell to win")

def list_received_brog_items(self) -> None:
self.log("Received Brog Items:")
Expand Down Expand Up @@ -411,6 +419,8 @@ def reset(self) -> None:
self.option_goal = None
self.option_artifacts_of_magic_required = None
self.option_artifacts_of_magic_total = None
self.option_landmarks_required = None
self.option_deaths_required = None
self.option_starting_location = None
self.option_hotspots = None
self.option_craftable_spells = None
Expand Down Expand Up @@ -1411,11 +1421,11 @@ def _check_for_victory(self) -> None:
if self._player_is_at("ps1e"):
self.goal_completed = True
elif self.option_goal == ZorkGrandInquisitorGoals.ZORK_TOUR:
if self.goal_item_count == 20:
if self.goal_item_count >= self.option_landmarks_required:
if self._player_is_at("ps1e"):
self.goal_completed = True
elif self.option_goal == ZorkGrandInquisitorGoals.GRIM_JOURNEY:
if self.goal_item_count == 22:
if self.goal_item_count >= self.option_deaths_required:
if self._player_is_at("hp60"):
self.goal_completed = True

Expand Down
32 changes: 32 additions & 0 deletions worlds/zork_grand_inquisitor/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,36 @@ class ArtifactsOfMagicRequired(Range):
default = 10


class LandmarksRequired(Range):
"""
Determines how many Landmarks are required to win.
Only relevant if the selected goal is Zork Tour.
"""

display_name = "Landmarks Required"

range_start = 10
range_end = 20

default = 20


class DeathsRequired(Range):
"""
Determines how many Deaths are required to win.
Only relevant if the selected goal is Grim Journey.
"""

display_name = "Deaths Required"

range_start = 10
range_end = 22

default = 22


class StartingLocation(Choice):
"""
Determines the in-game location the player will start at.
Expand Down Expand Up @@ -206,6 +236,8 @@ class ZorkGrandInquisitorOptions(PerGameCommonOptions, DeathLinkMixin):
goal: Goal
artifacts_of_magic_total: ArtifactsOfMagicTotal
artifacts_of_magic_required: ArtifactsOfMagicRequired
landmarks_required: LandmarksRequired
deaths_required: DeathsRequired
starting_location: StartingLocation
hotspots: Hotspots
craftable_spells: CraftableSpells
Expand Down
11 changes: 11 additions & 0 deletions worlds/zork_grand_inquisitor/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class ZorkGrandInquisitorWorld(World):
artifacts_of_magic_required: int
artifacts_of_magic_total: int
craftable_spells: ZorkGrandInquisitorCraftableSpellBehaviors
deaths_required: int
deathsanity: ZorkGrandInquisitorDeathsanity
early_items: Tuple[ZorkGrandInquisitorItems, ...]
filler_item_names: List[str] = item_groups()["Filler"]
Expand All @@ -114,6 +115,7 @@ class ZorkGrandInquisitorWorld(World):
initial_totemizer_destination: ZorkGrandInquisitorItems
item_data: Dict[ZorkGrandInquisitorItems, ZorkGrandInquisitorItemData]
item_name_to_item: Dict[str, ZorkGrandInquisitorItems] = item_names_to_item()
landmarks_required: int
landmarksanity: ZorkGrandInquisitorLandmarksanity

location_data: Dict[
Expand All @@ -133,6 +135,9 @@ def generate_early(self) -> None:
if self.artifacts_of_magic_required > self.artifacts_of_magic_total:
self.artifacts_of_magic_total = self.artifacts_of_magic_required

self.landmarks_required = self.options.landmarks_required.value
self.deaths_required = self.options.deaths_required.value

self.starting_location = id_to_starting_locations()[self.options.starting_location.value]

self.starter_kit = tuple()
Expand Down Expand Up @@ -252,6 +257,8 @@ def create_regions(self) -> None:
self.goal,
self.player,
self.artifacts_of_magic_required,
self.landmarks_required,
self.deaths_required,
)

region.connect(region_mapping[ZorkGrandInquisitorRegions.ENDGAME], rule=eval(goal_access_rule))
Expand All @@ -271,6 +278,8 @@ def create_regions(self) -> None:
self.goal,
self.player,
self.artifacts_of_magic_required,
self.landmarks_required,
self.deaths_required,
)

region_menu.connect(region_mapping[ZorkGrandInquisitorRegions.ENDGAME], rule=eval(goal_access_rule))
Expand Down Expand Up @@ -377,6 +386,8 @@ def fill_slot_data(self) -> Dict[str, Any]:
"goal",
"artifacts_of_magic_required",
"artifacts_of_magic_total",
"landmarks_required",
"deaths_required",
"starting_location",
"hotspots",
"craftable_spells",
Expand Down

0 comments on commit c336529

Please sign in to comment.