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 all commits
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
5 changes: 0 additions & 5 deletions Plandomizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,11 +892,6 @@ def fill(self, worlds: list[World], location_pools: list[list[Location]], item_p
if record.item == '#Junk' and location.type == 'Song' and world.settings.shuffle_song_items == 'song' and not any(name in song_list and r.count for name, r in world.settings.starting_items.items()):
record.item = '#JunkSong'

adult_trade_matcher = self.pattern_matcher("#AdultTrade")
if adult_trade_matcher(record.item) and not world.settings.adult_trade_shuffle and world.settings.adult_trade_start:
# Override the adult trade item used to control trade quest flags during patching
world.selected_adult_trade_item = record.item

ignore_pools = None
is_invert = self.pattern_matcher(record.item)('!')
if is_invert and location.type != 'Song' and world.settings.shuffle_song_items == 'song':
Expand Down
10 changes: 9 additions & 1 deletion World.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,15 @@ 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 = None
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 = 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
11 changes: 5 additions & 6 deletions data/World/Overworld.json
Original file line number Diff line number Diff line change
Expand Up @@ -1789,12 +1789,11 @@
"locations": {
"Kak Granny Trade Odd Mushroom": "'Odd Potion Access'",
# Granny will not sell her item without turning in odd mushroom
# If the adult trade item(s) in the world are all after odd mushroom,
# allow any of the later sequence items to satisfy logic. The patcher
# sets the flag needed for her to sell stuff if odd mushroom can't be obtained.
"Kak Granny Buy Blue Potion": "Progressive_Wallet and is_adult and
(Odd_Mushroom or ((Odd_Potion or Poachers_Saw or Broken_Sword or
Prescription or Eyeball_Frog or Eyedrops or Claim_Check) and not adult_trade_shuffle))"
"Kak Granny Buy Blue Potion": "Progressive_Wallet and is_adult and ('Odd Potion Access' or
((selected_adult_trade_item == 'Odd Potion' or selected_adult_trade_item == 'Poachers Saw' or
selected_adult_trade_item == 'Broken Sword' or selected_adult_trade_item == 'Prescription' or
selected_adult_trade_item == 'Eyeball Frog' or selected_adult_trade_item == 'Eyedrops' or
selected_adult_trade_item == 'Claim Check') and not adult_trade_shuffle))"
},
"exits": {
"Kak Backyard": "True"
Expand Down