Skip to content

Commit

Permalink
Adding item and location groups
Browse files Browse the repository at this point in the history
  • Loading branch information
gaithern committed Aug 24, 2024
1 parent 43c71ea commit efee432
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
12 changes: 10 additions & 2 deletions worlds/khrecom/Items.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, NamedTuple, Optional
from typing import Dict, NamedTuple, Optional, Set

from BaseClasses import Item, ItemClassification

Expand All @@ -10,7 +10,7 @@ class KHRECOMItem(Item):
class KHRECOMItemData(NamedTuple):
category: str
sub: str = "None"
code: Optional[int] = None
code: int = 0
classification: ItemClassification = ItemClassification.filler


Expand Down Expand Up @@ -250,3 +250,11 @@ def get_items_by_category(category: str, exclude: list) -> Dict[str, KHRECOMItem
"Friend Card Jack": KHRECOMItemData("Friend Cards", code = 268_5007, classification = ItemClassification.progression),
"Friend Card Pluto": KHRECOMItemData("Friend Cards", code = 268_5008, classification = ItemClassification.progression),
}

# Make item categories
item_name_groups: Dict[str, Set[str]] = {}
for item in item_table.keys():
category = item_table[item].category
if category not in item_name_groups.keys():
item_name_groups[category] = set()
item_name_groups[category].add(item)
10 changes: 9 additions & 1 deletion worlds/khrecom/Locations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, NamedTuple, Optional
from typing import Dict, NamedTuple, Optional, Set


from BaseClasses import Location
Expand Down Expand Up @@ -307,3 +307,11 @@ def get_locations_by_category(category: str) -> Dict[str, KHRECOMLocationData]:
}

lookup_id_to_name: Dict[int, str] = {data.code: item_name for item_name, data in location_table.items() if data.code}

# Make location categories
location_name_groups: Dict[str, Set[str]] = {}
for location in location_table.keys():
category = location_table[location].category
if category not in location_name_groups.keys():
location_name_groups[category] = set()
location_name_groups[category].add(location)
6 changes: 4 additions & 2 deletions worlds/khrecom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from BaseClasses import Tutorial, MultiWorld
from worlds.AutoWorld import WebWorld, World
from .Items import KHRECOMItem, KHRECOMItemData, get_items_by_category, item_table
from .Locations import location_table
from .Items import KHRECOMItem, KHRECOMItemData, get_items_by_category, item_table, item_name_groups
from .Locations import location_table, location_name_groups
from .Options import KHRECOMOptions, khrecom_option_groups
from .Regions import create_regions
from .Rules import set_rules
Expand Down Expand Up @@ -48,6 +48,8 @@ class KHRECOMWorld(World):

item_name_to_id = {name: data.code for name, data in item_table.items()}
location_name_to_id = {name: data.code for name, data in location_table.items()}
item_name_groups = item_name_groups
location_name_groups = location_name_groups

def create_items(self):
self.place_predetermined_items()
Expand Down

0 comments on commit efee432

Please sign in to comment.