Skip to content

Commit

Permalink
define logic helper items for starting locations; grant proper logic …
Browse files Browse the repository at this point in the history
…helper item to player depending on starting location
  • Loading branch information
nbrochu committed Nov 1, 2024
1 parent d02b9b0 commit 38050e2
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 4 deletions.
63 changes: 62 additions & 1 deletion worlds/zork_grand_inquisitor/data/item_data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, NamedTuple, Optional, Tuple, Union
from typing import Dict, NamedTuple, Optional, Tuple

from BaseClasses import ItemClassification

Expand Down Expand Up @@ -783,4 +783,65 @@ class ZorkGrandInquisitorItemData(NamedTuple):
tags=(ZorkGrandInquisitorTags.FILLER,),
maximum_quantity=None,
),
# Logic Helpers - These virtual items are granted to the player conditionally to simplify logic where possible
ZorkGrandInquisitorItems.LOGIC_HELPER_STARTING_LOCATION_CROSSROADS: ZorkGrandInquisitorItemData(
statemap_keys=None,
archipelago_id=ITEM_OFFSET + 900 + 0,
classification=ItemClassification.progression,
tags=(ZorkGrandInquisitorTags.LOGIC_HELPER,),
),
ZorkGrandInquisitorItems.LOGIC_HELPER_STARTING_LOCATION_DM_LAIR: ZorkGrandInquisitorItemData(
statemap_keys=None,
archipelago_id=ITEM_OFFSET + 900 + 1,
classification=ItemClassification.progression,
tags=(ZorkGrandInquisitorTags.LOGIC_HELPER,),
),
ZorkGrandInquisitorItems.LOGIC_HELPER_STARTING_LOCATION_DM_LAIR_HOUSE: ZorkGrandInquisitorItemData(
statemap_keys=None,
archipelago_id=ITEM_OFFSET + 900 + 2,
classification=ItemClassification.progression,
tags=(ZorkGrandInquisitorTags.LOGIC_HELPER,),
),
ZorkGrandInquisitorItems.LOGIC_HELPER_STARTING_LOCATION_FLOOD_CONTROL_DAM_3: ZorkGrandInquisitorItemData(
statemap_keys=None,
archipelago_id=ITEM_OFFSET + 900 + 3,
classification=ItemClassification.progression,
tags=(ZorkGrandInquisitorTags.LOGIC_HELPER,),
),
ZorkGrandInquisitorItems.LOGIC_HELPER_STARTING_LOCATION_GUE_TECH: ZorkGrandInquisitorItemData(
statemap_keys=None,
archipelago_id=ITEM_OFFSET + 900 + 4,
classification=ItemClassification.progression,
tags=(ZorkGrandInquisitorTags.LOGIC_HELPER,),
),
ZorkGrandInquisitorItems.LOGIC_HELPER_STARTING_LOCATION_HADES_SHORE: ZorkGrandInquisitorItemData(
statemap_keys=None,
archipelago_id=ITEM_OFFSET + 900 + 5,
classification=ItemClassification.progression,
tags=(ZorkGrandInquisitorTags.LOGIC_HELPER,),
),
ZorkGrandInquisitorItems.LOGIC_HELPER_STARTING_LOCATION_MONASTERY_EXHIBIT: ZorkGrandInquisitorItemData(
statemap_keys=None,
archipelago_id=ITEM_OFFSET + 900 + 6,
classification=ItemClassification.progression,
tags=(ZorkGrandInquisitorTags.LOGIC_HELPER,),
),
ZorkGrandInquisitorItems.LOGIC_HELPER_STARTING_LOCATION_MONASTERY_TOTEMIZER: ZorkGrandInquisitorItemData(
statemap_keys=None,
archipelago_id=ITEM_OFFSET + 900 + 7,
classification=ItemClassification.progression,
tags=(ZorkGrandInquisitorTags.LOGIC_HELPER,),
),
ZorkGrandInquisitorItems.LOGIC_HELPER_STARTING_LOCATION_PORT_FOOZLE: ZorkGrandInquisitorItemData(
statemap_keys=None,
archipelago_id=ITEM_OFFSET + 900 + 8,
classification=ItemClassification.progression,
tags=(ZorkGrandInquisitorTags.LOGIC_HELPER,),
),
ZorkGrandInquisitorItems.LOGIC_HELPER_STARTING_LOCATION_SPELL_LAB: ZorkGrandInquisitorItemData(
statemap_keys=None,
archipelago_id=ITEM_OFFSET + 900 + 9,
classification=ItemClassification.progression,
tags=(ZorkGrandInquisitorTags.LOGIC_HELPER,),
),
}
39 changes: 39 additions & 0 deletions worlds/zork_grand_inquisitor/data/mapping_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from typing import Dict

from ..enums import ZorkGrandInquisitorItems, ZorkGrandInquisitorStartingLocations


starting_location_to_logic_helper_item: Dict[
ZorkGrandInquisitorStartingLocations, ZorkGrandInquisitorItems
] = {
ZorkGrandInquisitorStartingLocations.PORT_FOOZLE: (
ZorkGrandInquisitorItems.LOGIC_HELPER_STARTING_LOCATION_PORT_FOOZLE
),
ZorkGrandInquisitorStartingLocations.CROSSROADS: (
ZorkGrandInquisitorItems.LOGIC_HELPER_STARTING_LOCATION_CROSSROADS
),
ZorkGrandInquisitorStartingLocations.DM_LAIR: (
ZorkGrandInquisitorItems.LOGIC_HELPER_STARTING_LOCATION_DM_LAIR
),
ZorkGrandInquisitorStartingLocations.DM_LAIR_HOUSE: (
ZorkGrandInquisitorItems.LOGIC_HELPER_STARTING_LOCATION_DM_LAIR_HOUSE
),
ZorkGrandInquisitorStartingLocations.GUE_TECH: (
ZorkGrandInquisitorItems.LOGIC_HELPER_STARTING_LOCATION_GUE_TECH
),
ZorkGrandInquisitorStartingLocations.SPELL_LAB: (
ZorkGrandInquisitorItems.LOGIC_HELPER_STARTING_LOCATION_SPELL_LAB
),
ZorkGrandInquisitorStartingLocations.HADES_SHORE: (
ZorkGrandInquisitorItems.LOGIC_HELPER_STARTING_LOCATION_HADES_SHORE
),
ZorkGrandInquisitorStartingLocations.FLOOD_CONTROL_DAM_3: (
ZorkGrandInquisitorItems.LOGIC_HELPER_STARTING_LOCATION_FLOOD_CONTROL_DAM_3
),
ZorkGrandInquisitorStartingLocations.MONASTERY_TOTEMIZER: (
ZorkGrandInquisitorItems.LOGIC_HELPER_STARTING_LOCATION_MONASTERY_TOTEMIZER
),
ZorkGrandInquisitorStartingLocations.MONASTERY_EXHIBIT: (
ZorkGrandInquisitorItems.LOGIC_HELPER_STARTING_LOCATION_MONASTERY_EXHIBIT
),
}
7 changes: 7 additions & 0 deletions worlds/zork_grand_inquisitor/data_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from .data.entrance_rule_data import entrance_rule_data
from .data.item_data import item_data, ZorkGrandInquisitorItemData
from .data.location_data import location_data, ZorkGrandInquisitorLocationData
from .data.mapping_data import starting_location_to_logic_item

from .enums import (
ZorkGrandInquisitorEvents,
Expand Down Expand Up @@ -143,6 +144,12 @@ def locations_with_tag(tag: ZorkGrandInquisitorTags) -> Set[ZorkGrandInquisitorL
return {location for location, data in location_data.items() if data.tags is not None and tag in data.tags}


def starting_location_to_logic_helper_item(
starting_location: ZorkGrandInquisitorStartingLocations,
) -> ZorkGrandInquisitorItems:
return starting_location_to_logic_item[starting_location]


def location_access_rule_for(location: ZorkGrandInquisitorLocations, player: int) -> str:
data: ZorkGrandInquisitorLocationData = location_data[location]

Expand Down
11 changes: 11 additions & 0 deletions worlds/zork_grand_inquisitor/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ class ZorkGrandInquisitorItems(enum.Enum):
JAR_OF_HOTBUGS = "Jar of Hotbugs"
LANTERN = "Lantern"
LARGE_TELEGRAPH_HAMMER = "Large Telegraph Hammer"
LOGIC_HELPER_STARTING_LOCATION_CROSSROADS = "Starting Location: Crossroads"
LOGIC_HELPER_STARTING_LOCATION_DM_LAIR = "Starting Location: Dungeon Master's Lair"
LOGIC_HELPER_STARTING_LOCATION_DM_LAIR_HOUSE = "Starting Location: Dungeon Master's House"
LOGIC_HELPER_STARTING_LOCATION_FLOOD_CONTROL_DAM_3 = "Starting Location: Flood Control Dam #3"
LOGIC_HELPER_STARTING_LOCATION_GUE_TECH = "Starting Location: GUE Tech"
LOGIC_HELPER_STARTING_LOCATION_HADES_SHORE = "Starting Location: Hades Shore"
LOGIC_HELPER_STARTING_LOCATION_MONASTERY_EXHIBIT = "Starting Location: Monastery Exhibit"
LOGIC_HELPER_STARTING_LOCATION_MONASTERY_TOTEMIZER = "Starting Location: Monastery Totemizer"
LOGIC_HELPER_STARTING_LOCATION_PORT_FOOZLE = "Starting Location: Port Foozle"
LOGIC_HELPER_STARTING_LOCATION_SPELL_LAB = "Starting Location: Spell Lab"
LUCYS_PLAYING_CARD_1 = "Lucy's Playing Card: 1 Pip"
LUCYS_PLAYING_CARD_2 = "Lucy's Playing Card: 2 Pips"
LUCYS_PLAYING_CARD_3 = "Lucy's Playing Card: 3 Pips"
Expand Down Expand Up @@ -354,6 +364,7 @@ class ZorkGrandInquisitorTags(enum.Enum):
FILLER = "Filler"
HOTSPOT = "Hotspot"
INVENTORY_ITEM = "Inventory Item"
LOGIC_HELPER = "Logic Helper"
MISSABLE = "Missable"
SPELL = "Spell"
SUBWAY_DESTINATION = "Subway Destination"
Expand Down
16 changes: 13 additions & 3 deletions worlds/zork_grand_inquisitor/world.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@

from .data.item_data import item_data, ZorkGrandInquisitorItemData
from .data.location_data import location_data, ZorkGrandInquisitorLocationData
from .data.mapping_data import starting_location_to_logic_helper_item
from .data.region_data import region_data

from .data_funcs import (
item_names_to_id,
item_names_to_item,
location_names_to_id,
id_to_starting_locations,
item_groups,
items_with_tag,
location_groups,
Expand All @@ -25,6 +27,7 @@
ZorkGrandInquisitorItems,
ZorkGrandInquisitorLocations,
ZorkGrandInquisitorRegions,
ZorkGrandInquisitorStartingLocations,
ZorkGrandInquisitorTags,
)

Expand Down Expand Up @@ -74,16 +77,16 @@ class ZorkGrandInquisitorWorld(World):
item_name_groups = item_groups()
location_name_groups = location_groups()

required_client_version: Tuple[int, int, int] = (0, 4, 4)
required_client_version: Tuple[int, int, int] = (0, 5, 0)

web = ZorkGrandInquisitorWebWorld()

filler_item_names: List[str] = item_groups()["Filler"]
item_name_to_item: Dict[str, ZorkGrandInquisitorItems] = item_names_to_item()
starting_location: ZorkGrandInquisitorStartingLocations

def generate_early(self) -> None:
pass
# Set Starting Location
self.starting_location = id_to_starting_locations()[self.options.starting_location.value]

def create_regions(self) -> None:
deathsanity: bool = bool(self.options.deathsanity)
Expand Down Expand Up @@ -158,6 +161,8 @@ def create_items(self) -> None:
continue
elif ZorkGrandInquisitorTags.HOTSPOT in tags and start_with_hotspot_items:
continue
elif ZorkGrandInquisitorTags.LOGIC_HELPER in tags:
continue

item_pool.append(self.create_item(item.value))

Expand All @@ -183,6 +188,11 @@ def create_items(self) -> None:
for item in items_with_tag(ZorkGrandInquisitorTags.HOTSPOT):
self.multiworld.push_precollected(self.create_item(item.value))

# Logic Helper Items
self.multiworld.push_precollected(
self.create_item(starting_location_to_logic_helper_item[self.starting_location].value)
)

def create_item(self, name: str) -> ZorkGrandInquisitorItem:
data: ZorkGrandInquisitorItemData = item_data[self.item_name_to_item[name]]

Expand Down

0 comments on commit 38050e2

Please sign in to comment.