Skip to content

Commit

Permalink
Give keyrings their own item type
Browse files Browse the repository at this point in the history
  • Loading branch information
GSKirox committed Oct 19, 2024
1 parent c7b035d commit 928894e
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Fill.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def fill_dungeons_restrictive(worlds: list[World], search: Search, shuffled_loca
# sort in the order Other, Small Key, Boss Key before placing dungeon items
# python sort is stable, so the ordering is still random within groups
# fill_restrictive processes the resulting list backwards so the Boss Keys will actually be placed first
sort_order = {"BossKey": 3, "GanonBossKey": 3, "SmallKey": 2}
sort_order = {"BossKey": 3, "GanonBossKey": 3, "SmallKey": 2, "SmallKeyRing": 2}
dungeon_items.sort(key=lambda item: sort_order.get(item.type, 1))

# place dungeon items
Expand Down
3 changes: 3 additions & 0 deletions HintList.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,9 @@ def tokens_required_by_settings(world: World) -> int:
'SmallKey': (["a tool for unlocking", "a dungeon pass", "a lock remover", "a lockpick"], "a Small Key", 'item'),
'HideoutSmallKey': (["a get out of jail free card"], "a Jail Key", 'item'),
'TCGSmallKey': (["a key to becoming a winner"], "a Game Key", 'item'),
'SmallKeyRing': (["a toolbox for unlocking", "a dungeon season pass", "a jingling ring", "a skeleton key"], "a Small Key Ring", 'item'),
'HideoutSmallKeyRing': (["a pack of get out of jail free cards"], "a Jail Key Ring", 'item'),
'TCGSmallKeyRing': (["the keys to becoming a winner"], "a Game Key Ring", 'item'),
'SilverRupee': (["an entry fee", "a priced artifact"], "a Silver Rupee", 'item'),
'Boss Key (Forest Temple)': (["a master of unlocking for a deep forest", "a master pass for a deep forest"], "the Forest Temple Boss Key", 'item'),
'Boss Key (Fire Temple)': (["a master of unlocking for a high mountain", "a master pass for a high mountain"], "the Fire Temple Boss Key", 'item'),
Expand Down
8 changes: 4 additions & 4 deletions Hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def is_restricted_dungeon_item(item: Item) -> bool:
return False
return (
((item.map or item.compass) and item.world.settings.shuffle_mapcompass == 'dungeon') or
(item.type == 'SmallKey' and item.world.settings.shuffle_smallkeys == 'dungeon') or
(item.type in ('SmallKey', 'SmallKeyRing') and item.world.settings.shuffle_smallkeys == 'dungeon') or
(item.type == 'BossKey' and item.world.settings.shuffle_bosskeys == 'dungeon') or
(item.type == 'GanonBossKey' and item.world.settings.shuffle_ganon_bosskey == 'dungeon') or
(item.type == 'SilverRupee' and item.world.settings.shuffle_silver_rupees == 'dungeon') or
Expand Down Expand Up @@ -1159,9 +1159,9 @@ def get_important_check_hint(spoiler: Spoiler, world: World, checked: set[str])
or location.item.name == 'Biggoron Sword'
or location.item.name == 'Double Defense'
# Handle make keys not in own dungeon major items
or (location.item.type == 'SmallKey' and not (world.settings.shuffle_smallkeys == 'dungeon' or world.settings.shuffle_smallkeys == 'vanilla'))
or (location.item.type == 'HideoutSmallKey' and not world.settings.shuffle_hideoutkeys == 'vanilla')
or (location.item.type == 'TCGSmallKey' and not world.settings.shuffle_tcgkeys == 'vanilla')
or (location.item.type in ('SmallKey', 'SmallKeyRing') and not (world.settings.shuffle_smallkeys == 'dungeon' or world.settings.shuffle_smallkeys == 'vanilla'))
or (location.item.type in ('HideoutSmallKey', 'HideoutSmallKeyRing') and not world.settings.shuffle_hideoutkeys == 'vanilla')
or (location.item.type in ('TCGSmallKey', 'TCGSmallKeyRing') and not world.settings.shuffle_tcgkeys == 'vanilla')
or (location.item.type == 'BossKey' and not (world.settings.shuffle_bosskeys == 'dungeon' or world.settings.shuffle_bosskeys == 'vanilla'))
or (location.item.type == 'GanonBossKey' and not (world.settings.shuffle_ganon_bosskey == 'vanilla'
or world.settings.shuffle_ganon_bosskey == 'dungeon' or world.settings.shuffle_ganon_bosskey == 'on_lacs'
Expand Down
14 changes: 7 additions & 7 deletions Item.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def key(self) -> bool:

@property
def smallkey(self) -> bool:
return self.type == 'SmallKey' or self.type == 'HideoutSmallKey' or self.type == 'TCGSmallKey'
return self.type in ('SmallKey', 'HideoutSmallKey', 'TCGSmallKey', 'SmallKeyRing', 'HideoutSmallKeyRing','TCGSmallKeyRing')

@property
def bosskey(self) -> bool:
Expand All @@ -136,9 +136,9 @@ def dungeonitem(self) -> bool:
def unshuffled_dungeon_item(self) -> bool:
if self.world is None:
return False
return ((self.type == 'SmallKey' and self.world.settings.shuffle_smallkeys in ('remove', 'vanilla', 'dungeon')) or
(self.type == 'HideoutSmallKey' and self.world.settings.shuffle_hideoutkeys == 'vanilla') or
(self.type == 'TCGSmallKey' and self.world.settings.shuffle_tcgkeys in ('remove', 'vanilla')) or
return ((self.type in ('SmallKey', 'SmallKeyRing') and self.world.settings.shuffle_smallkeys in ('remove', 'vanilla', 'dungeon')) or
(self.type in ('HideoutSmallKey', 'HideoutSmallKeyRing') and self.world.settings.shuffle_hideoutkeys == 'vanilla') or
(self.type in ('TCGSmallKey', 'HideoutSmallKeyRing') and self.world.settings.shuffle_tcgkeys in ('remove', 'vanilla')) or
(self.type == 'BossKey' and self.world.settings.shuffle_bosskeys in ('remove', 'vanilla', 'dungeon')) or
(self.type == 'GanonBossKey' and self.world.settings.shuffle_ganon_bosskey in ('remove', 'vanilla', 'dungeon')) or
((self.map or self.compass) and (self.world.settings.shuffle_mapcompass in ('remove', 'startwith', 'vanilla', 'dungeon'))) or
Expand Down Expand Up @@ -167,11 +167,11 @@ def majoritem(self) -> bool:
return False
if self.type == 'DungeonReward' and self.world.settings.shuffle_dungeon_rewards in ('vanilla', 'reward', 'dungeon'):
return False
if self.type == 'SmallKey' and self.world.settings.shuffle_smallkeys in ('dungeon', 'vanilla'):
if self.type in ('SmallKey', 'SmallKeyRing') and self.world.settings.shuffle_smallkeys in ('dungeon', 'vanilla'):
return False
if self.type == 'HideoutSmallKey' and self.world.settings.shuffle_hideoutkeys == 'vanilla':
if self.type in ('HideoutSmallKey', 'HideoutSmallKeyRing') and self.world.settings.shuffle_hideoutkeys == 'vanilla':
return False
if self.type == 'TCGSmallKey' and self.world.settings.shuffle_tcgkeys == 'vanilla':
if self.type in ('TCGSmallKey','TCGSmallKeyRing') and self.world.settings.shuffle_tcgkeys == 'vanilla':
return False
if self.type == 'BossKey' and self.world.settings.shuffle_bosskeys in ('dungeon', 'vanilla'):
return False
Expand Down
20 changes: 10 additions & 10 deletions ItemList.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,16 +481,16 @@ class GetItemId(IntEnum):
'Scarecrow Song': ('Event', True, None, None),
'Triforce': ('Event', True, None, None),

'Small Key Ring (Forest Temple)': ('SmallKey', True, GetItemId.GI_SMALL_KEY_RING_FOREST_TEMPLE, {'alias': ('Small Key (Forest Temple)', 10), 'progressive': float('Inf')}),
'Small Key Ring (Fire Temple)': ('SmallKey', True, GetItemId.GI_SMALL_KEY_RING_FIRE_TEMPLE, {'alias': ('Small Key (Fire Temple)', 10), 'progressive': float('Inf')}),
'Small Key Ring (Water Temple)': ('SmallKey', True, GetItemId.GI_SMALL_KEY_RING_WATER_TEMPLE, {'alias': ('Small Key (Water Temple)', 10), 'progressive': float('Inf')}),
'Small Key Ring (Spirit Temple)': ('SmallKey', True, GetItemId.GI_SMALL_KEY_RING_SPIRIT_TEMPLE, {'alias': ('Small Key (Spirit Temple)', 10), 'progressive': float('Inf')}),
'Small Key Ring (Shadow Temple)': ('SmallKey', True, GetItemId.GI_SMALL_KEY_RING_SHADOW_TEMPLE, {'alias': ('Small Key (Shadow Temple)', 10), 'progressive': float('Inf')}),
'Small Key Ring (Bottom of the Well)': ('SmallKey', True, GetItemId.GI_SMALL_KEY_RING_BOTTOM_OF_THE_WELL, {'alias': ('Small Key (Bottom of the Well)', 10), 'progressive': float('Inf')}),
'Small Key Ring (Gerudo Training Ground)': ('SmallKey', True, GetItemId.GI_SMALL_KEY_RING_GERUDO_TRAINING, {'alias': ('Small Key (Gerudo Training Ground)', 10), 'progressive': float('Inf')}),
'Small Key Ring (Thieves Hideout)': ('HideoutSmallKey', True, GetItemId.GI_SMALL_KEY_RING_THIEVES_HIDEOUT, {'alias': ('Small Key (Thieves Hideout)', 10), 'progressive': float('Inf')}),
'Small Key Ring (Ganons Castle)': ('SmallKey', True, GetItemId.GI_SMALL_KEY_RING_GANONS_CASTLE, {'alias': ('Small Key (Ganons Castle)', 10), 'progressive': float('Inf')}),
'Small Key Ring (Treasure Chest Game)': ('TCGSmallKey', True, GetItemId.GI_SMALL_KEY_RING_TREASURE_CHEST_GAME, {'alias': ('Small Key (Treasure Chest Game)', 10), 'progressive': float('Inf')}),
'Small Key Ring (Forest Temple)': ('SmallKeyRing', True, GetItemId.GI_SMALL_KEY_RING_FOREST_TEMPLE, {'alias': ('Small Key (Forest Temple)', 10), 'progressive': float('Inf')}),
'Small Key Ring (Fire Temple)': ('SmallKeyRing', True, GetItemId.GI_SMALL_KEY_RING_FIRE_TEMPLE, {'alias': ('Small Key (Fire Temple)', 10), 'progressive': float('Inf')}),
'Small Key Ring (Water Temple)': ('SmallKeyRing', True, GetItemId.GI_SMALL_KEY_RING_WATER_TEMPLE, {'alias': ('Small Key (Water Temple)', 10), 'progressive': float('Inf')}),
'Small Key Ring (Spirit Temple)': ('SmallKeyRing', True, GetItemId.GI_SMALL_KEY_RING_SPIRIT_TEMPLE, {'alias': ('Small Key (Spirit Temple)', 10), 'progressive': float('Inf')}),
'Small Key Ring (Shadow Temple)': ('SmallKeyRing', True, GetItemId.GI_SMALL_KEY_RING_SHADOW_TEMPLE, {'alias': ('Small Key (Shadow Temple)', 10), 'progressive': float('Inf')}),
'Small Key Ring (Bottom of the Well)': ('SmallKeyRing', True, GetItemId.GI_SMALL_KEY_RING_BOTTOM_OF_THE_WELL, {'alias': ('Small Key (Bottom of the Well)', 10), 'progressive': float('Inf')}),
'Small Key Ring (Gerudo Training Ground)': ('SmallKeyRing', True, GetItemId.GI_SMALL_KEY_RING_GERUDO_TRAINING, {'alias': ('Small Key (Gerudo Training Ground)', 10), 'progressive': float('Inf')}),
'Small Key Ring (Thieves Hideout)': ('HideoutSmallKeyRing', True, GetItemId.GI_SMALL_KEY_RING_THIEVES_HIDEOUT, {'alias': ('Small Key (Thieves Hideout)', 10), 'progressive': float('Inf')}),
'Small Key Ring (Ganons Castle)': ('SmallKeyRing', True, GetItemId.GI_SMALL_KEY_RING_GANONS_CASTLE, {'alias': ('Small Key (Ganons Castle)', 10), 'progressive': float('Inf')}),
'Small Key Ring (Treasure Chest Game)': ('TCGSmallKeyRing', True, GetItemId.GI_SMALL_KEY_RING_TREASURE_CHEST_GAME, {'alias': ('Small Key (Treasure Chest Game)', 10), 'progressive': float('Inf')}),

'Silver Rupee (Dodongos Cavern Staircase)': ('SilverRupee', True, GetItemId.GI_SILVER_RUPEE_DODONGOS_CAVERN_STAIRCASE, {'progressive': 5}),
'Silver Rupee (Ice Cavern Spinning Scythe)': ('SilverRupee', True, GetItemId.GI_SILVER_RUPEE_ICE_CAVERN_SPINNING_SCYTHE, {'progressive': 5}),
Expand Down
2 changes: 1 addition & 1 deletion ItemPool.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@
'Map': sorted([name for name, item in ItemInfo.items.items() if item.type == 'Map']),
'Compass': sorted([name for name, item in ItemInfo.items.items() if item.type == 'Compass']),
'BossKey': sorted([name for name, item in ItemInfo.items.items() if item.type == 'BossKey']),
'SmallKey': sorted([name for name, item in ItemInfo.items.items() if item.type == 'SmallKey']),
'SmallKey': sorted([name for name, item in ItemInfo.items.items() if item.type in ('SmallKey', 'SmallKeyRing')]),

'ForestFireWater': ('Forest Medallion', 'Fire Medallion', 'Water Medallion'),
'FireWater': ('Fire Medallion', 'Water Medallion'),
Expand Down
10 changes: 5 additions & 5 deletions Region.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,20 @@ def can_fill(self, item: Item, manual: bool = False) -> bool:
is_dungeon_restricted = False
is_overworld_restricted = False

if item.type in ('Map', 'Compass', 'SmallKey', 'HideoutSmallKey', 'TCGSmallKey', 'BossKey', 'GanonBossKey', 'SilverRupee', 'DungeonReward'):
if item.type in ('Map', 'Compass', 'SmallKey', 'HideoutSmallKey', 'TCGSmallKey', 'SmallKeyRing', 'HideoutSmallKeyRing', 'TCGSmallKeyRing', 'BossKey', 'GanonBossKey', 'SilverRupee', 'DungeonReward'):
shuffle_setting = (
self.world.settings.shuffle_mapcompass if item.type in ('Map', 'Compass') else
self.world.settings.shuffle_smallkeys if item.type == 'SmallKey' else
self.world.settings.shuffle_hideoutkeys if item.type == 'HideoutSmallKey' else
self.world.settings.shuffle_tcgkeys if item.type == 'TCGSmallKey' else
self.world.settings.shuffle_smallkeys if item.type in ('SmallKey', 'SmallKeyRing') else
self.world.settings.shuffle_hideoutkeys if item.type in ('HideoutSmallKey', 'HideoutSmallKeyRing') else
self.world.settings.shuffle_tcgkeys if item.type in ('TCGSmallKey', 'TCGSmallKeyRing') else
self.world.settings.shuffle_bosskeys if item.type == 'BossKey' else
self.world.settings.shuffle_ganon_bosskey if item.type == 'GanonBossKey' else
self.world.settings.shuffle_silver_rupees if item.type == 'SilverRupee' else
self.world.settings.shuffle_dungeon_rewards if item.type == 'DungeonReward' else
None
)

is_self_dungeon_restricted = (shuffle_setting == 'dungeon' or (shuffle_setting == 'vanilla' and item.type != 'DungeonReward')) and item.type not in ('HideoutSmallKey', 'TCGSmallKey')
is_self_dungeon_restricted = (shuffle_setting == 'dungeon' or (shuffle_setting == 'vanilla' and item.type != 'DungeonReward')) and item.type not in ('HideoutSmallKey', 'TCGSmallKey', 'HideoutSmallKeyRing', 'TCGSmallKeyRing')
is_self_region_restricted = [HintArea.GERUDO_FORTRESS, HintArea.THIEVES_HIDEOUT] if shuffle_setting == 'fortress' else None
if item.name in REWARD_COLORS:
is_hint_color_restricted = [REWARD_COLORS[item.name]] if shuffle_setting == 'regional' else None
Expand Down
2 changes: 1 addition & 1 deletion World.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ def initialize_items(self, items: Optional[list[Item]] = None) -> None:
item_dict = defaultdict(list)
for item in items:
item_dict[item.name].append(item)
if (self.settings.shuffle_hideoutkeys in ('fortress', 'regional') and item.type == 'HideoutSmallKey') or (self.settings.shuffle_tcgkeys == 'regional' and item.type == 'TCGSmallKey'):
if (self.settings.shuffle_hideoutkeys in ('fortress', 'regional') and item.type in ('HideoutSmallKey', 'HideoutSmallKeyRing')) or (self.settings.shuffle_tcgkeys == 'regional' and item.type in ('TCGSmallKey', 'TCGSmallKeyRing')):
item.priority = True

for dungeon in self.dungeons:
Expand Down

0 comments on commit 928894e

Please sign in to comment.