Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logic for Kak Granny Buy Blue Potion #2132

Merged
merged 6 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions ItemPool.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,9 +647,7 @@ def get_pool_core(world: World) -> tuple[list[str], dict[str, Item]]:
elif location.vanilla_item in trade_items:
if not world.settings.adult_trade_shuffle:
if location.vanilla_item == 'Pocket Egg' and world.settings.adult_trade_start:
potential_trade_items = world.settings.adult_trade_start
item = random.choice(potential_trade_items)
world.selected_adult_trade_item = item
item = world.selected_adult_trade_item
shuffle_item = True
else:
shuffle_item = False
Expand Down
7 changes: 0 additions & 7 deletions Plandomizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,13 +843,6 @@ def fill(self, worlds: list[World], location_pools: list[list[Location]], item_p
if self.locations:
locations = {loc: self.locations[loc] for loc in random.sample(sorted(self.locations), len(self.locations))}
used_items = []
# Override the adult trade item used to control trade quest flags during patching.
# This has to run before placing other items because the selected trade
# item impacts logic for buying a blue potion from Granny's Potion shop.
adult_trade_matcher = self.pattern_matcher("#AdultTrade")
plando_adult_trade = list(filter(lambda location_record_pair: adult_trade_matcher(location_record_pair[1].item), self.pattern_dict_items(locations)))
if plando_adult_trade and not world.settings.adult_trade_shuffle and world.settings.adult_trade_start:
world.selected_adult_trade_item = plando_adult_trade[0][1].item # ugly but functional, see the loop below for how this is indexed
record: LocationRecord
for (location_name, record) in self.pattern_dict_items(locations):
if record.item is None:
Expand Down
11 changes: 10 additions & 1 deletion World.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,16 @@ def __init__(self, world_id: int, settings: Settings, resolve_randomized_setting
self.disable_trade_revert: bool = self.shuffle_interior_entrances or settings.shuffle_overworld_entrances or settings.adult_trade_shuffle
self.skip_child_zelda: bool = 'Zeldas Letter' not in settings.shuffle_child_trade and \
'Zeldas Letter' in self.distribution.starting_items
self.selected_adult_trade_item: str = ''
self.selected_adult_trade_item: str = random.choice(settings.adult_trade_start) if settings.adult_trade_start else None
fenhl marked this conversation as resolved.
Show resolved Hide resolved
# Override the adult trade item used to control trade quest flags during patching if any are placed in plando.
# This has to run here because the rule parser caches world attributes and this attribute impacts logic for buying a blue potion from Granny's Potion shop.
locations = {}
if self.distribution.locations:
locations = {loc: self.distribution.locations[loc] for loc in random.sample(sorted(self.distribution.locations), len(self.distribution.locations))}
fenhl marked this conversation as resolved.
Show resolved Hide resolved
adult_trade_matcher = self.distribution.pattern_matcher("#AdultTrade")
plando_adult_trade = list(filter(lambda location_record_pair: adult_trade_matcher(location_record_pair[1].item), self.distribution.pattern_dict_items(locations)))
if plando_adult_trade and not settings.adult_trade_shuffle and settings.adult_trade_start:
self.selected_adult_trade_item = plando_adult_trade[0][1].item # ugly but functional, see the loop in Plandomizer.WorldDistribution.fill for how this is indexed
self.adult_trade_starting_inventory: str = ''

if (settings.open_forest == 'closed'
Expand Down