Skip to content

Commit

Permalink
SMZ3: keysanity accessibility fix (#1428)
Browse files Browse the repository at this point in the history
  • Loading branch information
lordlou authored Feb 7, 2023
1 parent c360b92 commit cc0540d
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions worlds/smz3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,12 @@ def set_rules(self):
if self.multiworld.accessibility[self.player] != 'locations':
l.always_allow = lambda state, item, loc=loc: \
item.game == "SMZ3" and \
loc.alwaysAllow(TotalSMZ3Item.Item(TotalSMZ3Item.ItemType[item.name], self.smz3World), state.smz3state[self.player])
loc.alwaysAllow(item.item, state.smz3state[self.player])
old_rule = l.item_rule
l.item_rule = lambda item, loc=loc, region=region: (\
item.game != "SMZ3" or \
loc.allow(TotalSMZ3Item.Item(TotalSMZ3Item.ItemType[item.name], self.smz3World), None) and \
region.CanFill(TotalSMZ3Item.Item(TotalSMZ3Item.ItemType[item.name], self.smz3World))) and old_rule(item)
loc.allow(item.item, None) and \
region.CanFill(item.item)) and old_rule(item)
set_rule(l, lambda state, loc=loc: loc.Available(state.smz3state[self.player]))

def create_regions(self):
Expand Down Expand Up @@ -502,24 +502,29 @@ def pre_fill(self):

all_dungeonItems = self.smz3DungeonItems[:]
fill_restrictive(self.multiworld, all_state, locations, all_dungeonItems, True, True)
# some small or big keys (those always_allow) can be unreachable in-game
# while logic still collects some of them (probably to simulate the player collecting pot keys in the logic), some others don't
# so we need to remove those exceptions as progression items
if self.multiworld.accessibility[self.player] != 'locations':
exception_item = [TotalSMZ3Item.ItemType.BigKeySW, TotalSMZ3Item.ItemType.BigKeySP, TotalSMZ3Item.ItemType.KeyTH]
for item in self.smz3DungeonItems:
if item.item.Type in exception_item and item.location.always_allow(all_state, item) and not all_state.can_reach(item.location):
item.classification = ItemClassification.filler
item.item.Progression = False
item.location.event = False
self.unreachable.append(item.location)
self.JunkFillGT(0.5)

def get_pre_fill_items(self):
if (not self.smz3World.Config.Keysanity):
return self.smz3DungeonItems
else:
return []

def post_fill(self):
# some small or big keys (those always_allow) can be unreachable in-game
# while logic still collects some of them (probably to simulate the player collecting pot keys in the logic), some others don't
# so we need to remove those exceptions as progression items
if self.multiworld.accessibility[self.player] == 'items':
state = CollectionState(self.multiworld)
locs = [self.multiworld.get_location("Swamp Palace - Big Chest", self.player),
self.multiworld.get_location("Skull Woods - Big Chest", self.player),
self.multiworld.get_location("Tower of Hera - Big Key Chest", self.player)]
for loc in locs:
if (loc.item.player == self.player and loc.always_allow(state, loc.item)):
loc.item.classification = ItemClassification.filler
loc.item.item.Progression = False
loc.item.location.event = False
self.unreachable.append(loc)

def get_filler_item_name(self) -> str:
return self.multiworld.random.choice(self.junkItemsNames)
Expand Down

0 comments on commit cc0540d

Please sign in to comment.