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
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
18 changes: 8 additions & 10 deletions World.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,14 @@ 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 = random.choice(settings.adult_trade_start) if settings.adult_trade_start else None
# 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))}
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
if not settings.adult_trade_shuffle and settings.adult_trade_start:
fenhl marked this conversation as resolved.
Show resolved Hide resolved
self.selected_adult_trade_item: str = random.choice(settings.adult_trade_start)
# 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.
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(self.distribution.locations)))
if plando_adult_trade:
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
Loading