More robust sweep_for_events (supports events that later become unreachable)
Minor fix for AllowSmall key logic
This commit is contained in:
@@ -786,7 +786,21 @@ class CollectionState(object):
|
|||||||
else:
|
else:
|
||||||
door_candidates.append(door.name)
|
door_candidates.append(door.name)
|
||||||
return door_candidates
|
return door_candidates
|
||||||
return None
|
door_candidates, skip = [], set()
|
||||||
|
if state.world.accessibility[player] != 'locations' and remaining_keys == 0:
|
||||||
|
key_logic = state.world.key_logic[player][dungeon_name]
|
||||||
|
for door, paired in key_logic.sm_doors.items():
|
||||||
|
if door.name in key_logic.door_rules:
|
||||||
|
rule = key_logic.door_rules[door.name]
|
||||||
|
key = KeyRuleType.AllowSmall
|
||||||
|
if (key in rule.new_rules and key_total >= rule.new_rules[key] and door.name not in skip
|
||||||
|
and door.name in state.reached_doors[player] and door.name not in state.opened_doors[player]):
|
||||||
|
if paired:
|
||||||
|
door_candidates.append((door.name, paired.name))
|
||||||
|
skip.add(paired.name)
|
||||||
|
else:
|
||||||
|
door_candidates.append(door.name)
|
||||||
|
return door_candidates if door_candidates else None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def print_rrp(rrp):
|
def print_rrp(rrp):
|
||||||
@@ -925,29 +939,30 @@ class CollectionState(object):
|
|||||||
checked_locations = set([l for l in locations if l in self.locations_checked])
|
checked_locations = set([l for l in locations if l in self.locations_checked])
|
||||||
reachable_events = [location for location in locations if location.event and location.can_reach(self)]
|
reachable_events = [location for location in locations if location.event and location.can_reach(self)]
|
||||||
reachable_events = self._do_not_flood_the_keys(reachable_events)
|
reachable_events = self._do_not_flood_the_keys(reachable_events)
|
||||||
|
found_new = False
|
||||||
for event in reachable_events:
|
for event in reachable_events:
|
||||||
if event not in checked_locations:
|
if event not in checked_locations:
|
||||||
self.events.append((event.name, event.player))
|
self.events.append((event.name, event.player))
|
||||||
self.collect(event.item, True, event)
|
self.collect(event.item, True, event)
|
||||||
return len(reachable_events) > len(checked_locations)
|
found_new = True
|
||||||
|
return found_new
|
||||||
|
|
||||||
def sweep_for_events(self, key_only=False, locations=None):
|
def sweep_for_events(self, key_only=False, locations=None):
|
||||||
# this may need improvement
|
# this may need improvement
|
||||||
if locations is None:
|
if locations is None:
|
||||||
locations = self.world.get_filled_locations()
|
locations = self.world.get_filled_locations()
|
||||||
new_locations = True
|
new_locations = True
|
||||||
checked_locations = 0
|
|
||||||
while new_locations:
|
while new_locations:
|
||||||
reachable_events = [location for location in locations if location.event and
|
reachable_events = [location for location in locations if location.event and
|
||||||
(not key_only or (self.world.keyshuffle[location.item.player] == 'none' and location.item.smallkey) or (not self.world.bigkeyshuffle[location.item.player] and location.item.bigkey))
|
(not key_only or (self.world.keyshuffle[location.item.player] == 'none' and location.item.smallkey) or (not self.world.bigkeyshuffle[location.item.player] and location.item.bigkey))
|
||||||
and location.can_reach(self)]
|
and location.can_reach(self)]
|
||||||
reachable_events = self._do_not_flood_the_keys(reachable_events)
|
reachable_events = self._do_not_flood_the_keys(reachable_events)
|
||||||
|
new_locations = False
|
||||||
for event in reachable_events:
|
for event in reachable_events:
|
||||||
if (event.name, event.player) not in self.events:
|
if (event.name, event.player) not in self.events:
|
||||||
self.events.append((event.name, event.player))
|
self.events.append((event.name, event.player))
|
||||||
self.collect(event.item, True, event)
|
self.collect(event.item, True, event)
|
||||||
new_locations = len(reachable_events) > checked_locations
|
new_locations = True
|
||||||
checked_locations = len(reachable_events)
|
|
||||||
|
|
||||||
|
|
||||||
def can_reach_blue(self, region, player):
|
def can_reach_blue(self, region, player):
|
||||||
|
|||||||
Reference in New Issue
Block a user