Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit 5d5c98d

Browse files
committed
Make collectItems() more accurate
collectItems() was only checking if the item could be obtained. We need to verify that we can leave the room the item is in, which wasn't being accounted for before this check-in.
1 parent db9d37c commit 5d5c98d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/electron/models/prime/world.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,19 @@ export class PrimeWorld extends World {
192192
const filledItemLocations = searchResults.getLocations().filter(location => location.hasItem());
193193

194194
const searchLocations = new LocationCollection(filledItemLocations.filter(location => {
195+
const visitedRegion = searchResults.getVisitedRegion(location.getParentRegion());
196+
197+
// Can't get the item, no point running the additional checks.
198+
if (!location.itemRule(myItems, this.settings)) {
199+
return false;
200+
}
201+
202+
// If we can obtain the item, can we exit?
203+
const locationExit = visitedRegion.entryPoint
204+
? visitedRegion.entryPoint.getOpposite()
205+
: null;
195206

196-
return location.itemRule(myItems, this.settings);
207+
return !locationExit || locationExit.accessRule(new PrimeItemCollection([...myItems.toArray(), location.getItem()]), this.settings);
197208
}));
198209

199210
const foundItems = new PrimeItemCollection(searchLocations.getItems().toArray());

0 commit comments

Comments
 (0)