From 0515acc8feb513df4c0f0a0ccce191a76bbd0b82 Mon Sep 17 00:00:00 2001 From: zig-for Date: Thu, 20 Apr 2023 00:12:53 -0700 Subject: [PATCH] LADX: no pre fill (#1673) * no pre fill * redo trade logic --- worlds/ladx/Items.py | 50 ++++++++++++++++++++--------------------- worlds/ladx/__init__.py | 28 ++++++----------------- 2 files changed, 31 insertions(+), 47 deletions(-) diff --git a/worlds/ladx/Items.py b/worlds/ladx/Items.py index b8be03d6..e36a589c 100644 --- a/worlds/ladx/Items.py +++ b/worlds/ladx/Items.py @@ -8,8 +8,7 @@ class ItemData(typing.NamedTuple): item_name: str ladxr_id: str classification: ItemClassification - mark_only_first_progression: bool = False - created_for_players = set() + @property def item_id(self): return CHEST_ITEMS[self.ladxr_id] @@ -33,6 +32,12 @@ class DungeonItemData(ItemData): s = self.ladxr_id[:-1] return DungeonItemType.__dict__[s] +class TradeItemData(ItemData): + vanilla_location = None + def __new__(cls, item_name, ladxr_id, classification, vanilla_location): + self = super(ItemData, cls).__new__(cls, (item_name, ladxr_id, classification)) + self.vanilla_location = vanilla_location + return self class LinksAwakeningItem(Item): game: str = Common.LINKS_AWAKENING @@ -40,14 +45,7 @@ class LinksAwakeningItem(Item): classification = item_data.classification if callable(classification): classification = classification(world, player) - # this doesn't work lol - MARK_FIRST_ITEM = False - if MARK_FIRST_ITEM: - if item_data.mark_only_first_progression: - if player in item_data.created_for_players: - classification = ItemClassification.filler - else: - item_data.created_for_players.add(player) + super().__init__(item_data.item_name, classification, Common.BASE_ID + item_data.item_id, player) self.item_data = item_data @@ -184,8 +182,8 @@ links_awakening_items = [ ItemData(ItemName.OCARINA, "OCARINA", ItemClassification.progression), ItemData(ItemName.FEATHER, "FEATHER", ItemClassification.progression), ItemData(ItemName.SHOVEL, "SHOVEL", ItemClassification.progression), - ItemData(ItemName.MAGIC_POWDER, "MAGIC_POWDER", ItemClassification.progression, True), - ItemData(ItemName.BOMB, "BOMB", ItemClassification.progression, True), + ItemData(ItemName.MAGIC_POWDER, "MAGIC_POWDER", ItemClassification.progression), + ItemData(ItemName.BOMB, "BOMB", ItemClassification.progression), ItemData(ItemName.SWORD, "SWORD", ItemClassification.progression), ItemData(ItemName.FLIPPERS, "FLIPPERS", ItemClassification.progression), ItemData(ItemName.MAGNIFYING_LENS, "MAGNIFYING_LENS", ItemClassification.progression), @@ -279,20 +277,20 @@ links_awakening_items = [ DungeonItemData(ItemName.INSTRUMENT6, "INSTRUMENT6", ItemClassification.progression), DungeonItemData(ItemName.INSTRUMENT7, "INSTRUMENT7", ItemClassification.progression), DungeonItemData(ItemName.INSTRUMENT8, "INSTRUMENT8", ItemClassification.progression), - ItemData(ItemName.TRADING_ITEM_YOSHI_DOLL, "TRADING_ITEM_YOSHI_DOLL", trade_item_prog), - ItemData(ItemName.TRADING_ITEM_RIBBON, "TRADING_ITEM_RIBBON", trade_item_prog), - ItemData(ItemName.TRADING_ITEM_DOG_FOOD, "TRADING_ITEM_DOG_FOOD", trade_item_prog), - ItemData(ItemName.TRADING_ITEM_BANANAS, "TRADING_ITEM_BANANAS", trade_item_prog), - ItemData(ItemName.TRADING_ITEM_STICK, "TRADING_ITEM_STICK", trade_item_prog), - ItemData(ItemName.TRADING_ITEM_HONEYCOMB, "TRADING_ITEM_HONEYCOMB", trade_item_prog), - ItemData(ItemName.TRADING_ITEM_PINEAPPLE, "TRADING_ITEM_PINEAPPLE", trade_item_prog), - ItemData(ItemName.TRADING_ITEM_HIBISCUS, "TRADING_ITEM_HIBISCUS", trade_item_prog), - ItemData(ItemName.TRADING_ITEM_LETTER, "TRADING_ITEM_LETTER", trade_item_prog), - ItemData(ItemName.TRADING_ITEM_BROOM, "TRADING_ITEM_BROOM", trade_item_prog), - ItemData(ItemName.TRADING_ITEM_FISHING_HOOK, "TRADING_ITEM_FISHING_HOOK", trade_item_prog), - ItemData(ItemName.TRADING_ITEM_NECKLACE, "TRADING_ITEM_NECKLACE", trade_item_prog), - ItemData(ItemName.TRADING_ITEM_SCALE, "TRADING_ITEM_SCALE", trade_item_prog), - ItemData(ItemName.TRADING_ITEM_MAGNIFYING_GLASS, "TRADING_ITEM_MAGNIFYING_GLASS", trade_item_prog) + TradeItemData(ItemName.TRADING_ITEM_YOSHI_DOLL, "TRADING_ITEM_YOSHI_DOLL", trade_item_prog, "Trendy Game (Mabe Village)"), + TradeItemData(ItemName.TRADING_ITEM_RIBBON, "TRADING_ITEM_RIBBON", trade_item_prog, "Papahl's Wife (Mabe Village)"), + TradeItemData(ItemName.TRADING_ITEM_DOG_FOOD, "TRADING_ITEM_DOG_FOOD", trade_item_prog, "YipYip (Mabe Village)"), + TradeItemData(ItemName.TRADING_ITEM_BANANAS, "TRADING_ITEM_BANANAS", trade_item_prog, "Banana Sale (Toronbo Shores)"), + TradeItemData(ItemName.TRADING_ITEM_STICK, "TRADING_ITEM_STICK", trade_item_prog, "Kiki (Ukuku Prairie)"), + TradeItemData(ItemName.TRADING_ITEM_HONEYCOMB, "TRADING_ITEM_HONEYCOMB", trade_item_prog, "Honeycomb (Ukuku Prairie)"), + TradeItemData(ItemName.TRADING_ITEM_PINEAPPLE, "TRADING_ITEM_PINEAPPLE", trade_item_prog, "Bear Cook (Animal Village)"), + TradeItemData(ItemName.TRADING_ITEM_HIBISCUS, "TRADING_ITEM_HIBISCUS", trade_item_prog, "Papahl (Tal Tal Heights)"), + TradeItemData(ItemName.TRADING_ITEM_LETTER, "TRADING_ITEM_LETTER", trade_item_prog, "Goat (Animal Village)"), + TradeItemData(ItemName.TRADING_ITEM_BROOM, "TRADING_ITEM_BROOM", trade_item_prog, "MrWrite (Goponga Swamp)"), + TradeItemData(ItemName.TRADING_ITEM_FISHING_HOOK, "TRADING_ITEM_FISHING_HOOK", trade_item_prog, "Grandma (Animal Village)"), + TradeItemData(ItemName.TRADING_ITEM_NECKLACE, "TRADING_ITEM_NECKLACE", trade_item_prog, "Fisher (Martha's Bay)"), + TradeItemData(ItemName.TRADING_ITEM_SCALE, "TRADING_ITEM_SCALE", trade_item_prog, "Mermaid (Martha's Bay)"), + TradeItemData(ItemName.TRADING_ITEM_MAGNIFYING_GLASS, "TRADING_ITEM_MAGNIFYING_GLASS", trade_item_prog, "Mermaid Statue (Martha's Bay)") ] ladxr_item_to_la_item_name = { diff --git a/worlds/ladx/__init__.py b/worlds/ladx/__init__.py index d64b950e..ddb73f6b 100644 --- a/worlds/ladx/__init__.py +++ b/worlds/ladx/__init__.py @@ -9,12 +9,11 @@ from Fill import fill_restrictive from worlds.AutoWorld import WebWorld, World from .Common import * -from .Items import (DungeonItemData, DungeonItemType, LinksAwakeningItem, +from .Items import (DungeonItemData, DungeonItemType, LinksAwakeningItem, TradeItemData, ladxr_item_to_la_item_name, links_awakening_items, links_awakening_items_by_name) from .LADXR import generator from .LADXR.itempool import ItemPool as LADXRItemPool -from .LADXR.locations.tradeSequence import TradeSequenceItem from .LADXR.logic import Logic as LAXDRLogic from .LADXR.main import get_parser from .LADXR.settings import Settings as LADXRSettings @@ -23,7 +22,8 @@ from .LADXR.locations.instrument import Instrument from .LADXR.locations.constants import CHEST_ITEMS from .Locations import (LinksAwakeningLocation, LinksAwakeningRegion, create_regions_from_ladxr, get_locations_to_id) -from .Options import links_awakening_options +from .Options import links_awakening_options, DungeonItemShuffle + from .Rom import LADXDeltaPatch DEVELOPER_MODE = False @@ -140,12 +140,10 @@ class LinksAwakeningWorld(World): def create_items(self) -> None: exclude = [item.name for item in self.multiworld.precollected_items[self.player]] - self.trade_items = [] - dungeon_item_types = { } - from .Options import DungeonItemShuffle + self.prefill_original_dungeon = [ [], [], [], [], [], [], [], [], [] ] self.prefill_own_dungeons = [] # For any and different world, set item rule instead @@ -183,8 +181,9 @@ class LinksAwakeningWorld(World): else: item = self.create_item(item_name) - if not self.multiworld.tradequest[self.player] and ladx_item_name.startswith("TRADING_"): - self.trade_items.append(item) + if not self.multiworld.tradequest[self.player] and isinstance(item.item_data, TradeItemData): + location = self.multiworld.get_location(item.item_data.vanilla_location, self.player) + location.place_locked_item(item) continue if isinstance(item.item_data, DungeonItemData): if item.item_data.dungeon_item_type == DungeonItemType.INSTRUMENT: @@ -218,7 +217,6 @@ class LinksAwakeningWorld(World): else: self.multiworld.itempool.append(item) - def pre_fill(self): self.multi_key = self.generate_multi_key() dungeon_locations = [] @@ -261,18 +259,6 @@ class LinksAwakeningWorld(World): # Properly fill locations within dungeon location.dungeon = r.dungeon_index - # Tell the filler that if we're placing a dungeon item, restrict it to the dungeon the item associates with - # This will need changed once keysanity is implemented - #orig_rule = location.item_rule - #location.item_rule = lambda item, orig_rule=orig_rule: \ - # (not isinstance(item, DungeonItemData) or item.dungeon_index == location.dungeon) and orig_rule(item) - - for location in r.locations: - # If tradequests are disabled, place trade items directly in their proper location - if not self.multiworld.tradequest[self.player] and isinstance(location, LinksAwakeningLocation) and isinstance(location.ladxr_item, TradeSequenceItem): - item = next(i for i in self.trade_items if i.item_data.ladxr_id == location.ladxr_item.default_item) - location.place_locked_item(item) - for dungeon_index in range(0, 9): locs = dungeon_locations_by_dungeon[dungeon_index] locs = [loc for loc in locs if not loc.item]