LADX: no pre fill (#1673)

* no pre fill
* redo trade logic
This commit is contained in:
zig-for 2023-04-20 00:12:53 -07:00 committed by GitHub
parent bf5c1cbbbf
commit 0515acc8fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 47 deletions

View File

@ -8,8 +8,7 @@ class ItemData(typing.NamedTuple):
item_name: str item_name: str
ladxr_id: str ladxr_id: str
classification: ItemClassification classification: ItemClassification
mark_only_first_progression: bool = False
created_for_players = set()
@property @property
def item_id(self): def item_id(self):
return CHEST_ITEMS[self.ladxr_id] return CHEST_ITEMS[self.ladxr_id]
@ -33,6 +32,12 @@ class DungeonItemData(ItemData):
s = self.ladxr_id[:-1] s = self.ladxr_id[:-1]
return DungeonItemType.__dict__[s] 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): class LinksAwakeningItem(Item):
game: str = Common.LINKS_AWAKENING game: str = Common.LINKS_AWAKENING
@ -40,14 +45,7 @@ class LinksAwakeningItem(Item):
classification = item_data.classification classification = item_data.classification
if callable(classification): if callable(classification):
classification = classification(world, player) 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) super().__init__(item_data.item_name, classification, Common.BASE_ID + item_data.item_id, player)
self.item_data = item_data self.item_data = item_data
@ -184,8 +182,8 @@ links_awakening_items = [
ItemData(ItemName.OCARINA, "OCARINA", ItemClassification.progression), ItemData(ItemName.OCARINA, "OCARINA", ItemClassification.progression),
ItemData(ItemName.FEATHER, "FEATHER", ItemClassification.progression), ItemData(ItemName.FEATHER, "FEATHER", ItemClassification.progression),
ItemData(ItemName.SHOVEL, "SHOVEL", ItemClassification.progression), ItemData(ItemName.SHOVEL, "SHOVEL", ItemClassification.progression),
ItemData(ItemName.MAGIC_POWDER, "MAGIC_POWDER", ItemClassification.progression, True), ItemData(ItemName.MAGIC_POWDER, "MAGIC_POWDER", ItemClassification.progression),
ItemData(ItemName.BOMB, "BOMB", ItemClassification.progression, True), ItemData(ItemName.BOMB, "BOMB", ItemClassification.progression),
ItemData(ItemName.SWORD, "SWORD", ItemClassification.progression), ItemData(ItemName.SWORD, "SWORD", ItemClassification.progression),
ItemData(ItemName.FLIPPERS, "FLIPPERS", ItemClassification.progression), ItemData(ItemName.FLIPPERS, "FLIPPERS", ItemClassification.progression),
ItemData(ItemName.MAGNIFYING_LENS, "MAGNIFYING_LENS", 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.INSTRUMENT6, "INSTRUMENT6", ItemClassification.progression),
DungeonItemData(ItemName.INSTRUMENT7, "INSTRUMENT7", ItemClassification.progression), DungeonItemData(ItemName.INSTRUMENT7, "INSTRUMENT7", ItemClassification.progression),
DungeonItemData(ItemName.INSTRUMENT8, "INSTRUMENT8", ItemClassification.progression), DungeonItemData(ItemName.INSTRUMENT8, "INSTRUMENT8", ItemClassification.progression),
ItemData(ItemName.TRADING_ITEM_YOSHI_DOLL, "TRADING_ITEM_YOSHI_DOLL", trade_item_prog), TradeItemData(ItemName.TRADING_ITEM_YOSHI_DOLL, "TRADING_ITEM_YOSHI_DOLL", trade_item_prog, "Trendy Game (Mabe Village)"),
ItemData(ItemName.TRADING_ITEM_RIBBON, "TRADING_ITEM_RIBBON", trade_item_prog), TradeItemData(ItemName.TRADING_ITEM_RIBBON, "TRADING_ITEM_RIBBON", trade_item_prog, "Papahl's Wife (Mabe Village)"),
ItemData(ItemName.TRADING_ITEM_DOG_FOOD, "TRADING_ITEM_DOG_FOOD", trade_item_prog), TradeItemData(ItemName.TRADING_ITEM_DOG_FOOD, "TRADING_ITEM_DOG_FOOD", trade_item_prog, "YipYip (Mabe Village)"),
ItemData(ItemName.TRADING_ITEM_BANANAS, "TRADING_ITEM_BANANAS", trade_item_prog), TradeItemData(ItemName.TRADING_ITEM_BANANAS, "TRADING_ITEM_BANANAS", trade_item_prog, "Banana Sale (Toronbo Shores)"),
ItemData(ItemName.TRADING_ITEM_STICK, "TRADING_ITEM_STICK", trade_item_prog), TradeItemData(ItemName.TRADING_ITEM_STICK, "TRADING_ITEM_STICK", trade_item_prog, "Kiki (Ukuku Prairie)"),
ItemData(ItemName.TRADING_ITEM_HONEYCOMB, "TRADING_ITEM_HONEYCOMB", trade_item_prog), TradeItemData(ItemName.TRADING_ITEM_HONEYCOMB, "TRADING_ITEM_HONEYCOMB", trade_item_prog, "Honeycomb (Ukuku Prairie)"),
ItemData(ItemName.TRADING_ITEM_PINEAPPLE, "TRADING_ITEM_PINEAPPLE", trade_item_prog), TradeItemData(ItemName.TRADING_ITEM_PINEAPPLE, "TRADING_ITEM_PINEAPPLE", trade_item_prog, "Bear Cook (Animal Village)"),
ItemData(ItemName.TRADING_ITEM_HIBISCUS, "TRADING_ITEM_HIBISCUS", trade_item_prog), TradeItemData(ItemName.TRADING_ITEM_HIBISCUS, "TRADING_ITEM_HIBISCUS", trade_item_prog, "Papahl (Tal Tal Heights)"),
ItemData(ItemName.TRADING_ITEM_LETTER, "TRADING_ITEM_LETTER", trade_item_prog), TradeItemData(ItemName.TRADING_ITEM_LETTER, "TRADING_ITEM_LETTER", trade_item_prog, "Goat (Animal Village)"),
ItemData(ItemName.TRADING_ITEM_BROOM, "TRADING_ITEM_BROOM", trade_item_prog), TradeItemData(ItemName.TRADING_ITEM_BROOM, "TRADING_ITEM_BROOM", trade_item_prog, "MrWrite (Goponga Swamp)"),
ItemData(ItemName.TRADING_ITEM_FISHING_HOOK, "TRADING_ITEM_FISHING_HOOK", trade_item_prog), TradeItemData(ItemName.TRADING_ITEM_FISHING_HOOK, "TRADING_ITEM_FISHING_HOOK", trade_item_prog, "Grandma (Animal Village)"),
ItemData(ItemName.TRADING_ITEM_NECKLACE, "TRADING_ITEM_NECKLACE", trade_item_prog), TradeItemData(ItemName.TRADING_ITEM_NECKLACE, "TRADING_ITEM_NECKLACE", trade_item_prog, "Fisher (Martha's Bay)"),
ItemData(ItemName.TRADING_ITEM_SCALE, "TRADING_ITEM_SCALE", trade_item_prog), TradeItemData(ItemName.TRADING_ITEM_SCALE, "TRADING_ITEM_SCALE", trade_item_prog, "Mermaid (Martha's Bay)"),
ItemData(ItemName.TRADING_ITEM_MAGNIFYING_GLASS, "TRADING_ITEM_MAGNIFYING_GLASS", trade_item_prog) TradeItemData(ItemName.TRADING_ITEM_MAGNIFYING_GLASS, "TRADING_ITEM_MAGNIFYING_GLASS", trade_item_prog, "Mermaid Statue (Martha's Bay)")
] ]
ladxr_item_to_la_item_name = { ladxr_item_to_la_item_name = {

View File

@ -9,12 +9,11 @@ from Fill import fill_restrictive
from worlds.AutoWorld import WebWorld, World from worlds.AutoWorld import WebWorld, World
from .Common import * 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, ladxr_item_to_la_item_name, links_awakening_items,
links_awakening_items_by_name) links_awakening_items_by_name)
from .LADXR import generator from .LADXR import generator
from .LADXR.itempool import ItemPool as LADXRItemPool from .LADXR.itempool import ItemPool as LADXRItemPool
from .LADXR.locations.tradeSequence import TradeSequenceItem
from .LADXR.logic import Logic as LAXDRLogic from .LADXR.logic import Logic as LAXDRLogic
from .LADXR.main import get_parser from .LADXR.main import get_parser
from .LADXR.settings import Settings as LADXRSettings 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 .LADXR.locations.constants import CHEST_ITEMS
from .Locations import (LinksAwakeningLocation, LinksAwakeningRegion, from .Locations import (LinksAwakeningLocation, LinksAwakeningRegion,
create_regions_from_ladxr, get_locations_to_id) 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 from .Rom import LADXDeltaPatch
DEVELOPER_MODE = False DEVELOPER_MODE = False
@ -140,12 +140,10 @@ class LinksAwakeningWorld(World):
def create_items(self) -> None: def create_items(self) -> None:
exclude = [item.name for item in self.multiworld.precollected_items[self.player]] exclude = [item.name for item in self.multiworld.precollected_items[self.player]]
self.trade_items = []
dungeon_item_types = { dungeon_item_types = {
} }
from .Options import DungeonItemShuffle
self.prefill_original_dungeon = [ [], [], [], [], [], [], [], [], [] ] self.prefill_original_dungeon = [ [], [], [], [], [], [], [], [], [] ]
self.prefill_own_dungeons = [] self.prefill_own_dungeons = []
# For any and different world, set item rule instead # For any and different world, set item rule instead
@ -183,8 +181,9 @@ class LinksAwakeningWorld(World):
else: else:
item = self.create_item(item_name) item = self.create_item(item_name)
if not self.multiworld.tradequest[self.player] and ladx_item_name.startswith("TRADING_"): if not self.multiworld.tradequest[self.player] and isinstance(item.item_data, TradeItemData):
self.trade_items.append(item) location = self.multiworld.get_location(item.item_data.vanilla_location, self.player)
location.place_locked_item(item)
continue continue
if isinstance(item.item_data, DungeonItemData): if isinstance(item.item_data, DungeonItemData):
if item.item_data.dungeon_item_type == DungeonItemType.INSTRUMENT: if item.item_data.dungeon_item_type == DungeonItemType.INSTRUMENT:
@ -218,7 +217,6 @@ class LinksAwakeningWorld(World):
else: else:
self.multiworld.itempool.append(item) self.multiworld.itempool.append(item)
def pre_fill(self):
self.multi_key = self.generate_multi_key() self.multi_key = self.generate_multi_key()
dungeon_locations = [] dungeon_locations = []
@ -261,18 +259,6 @@ class LinksAwakeningWorld(World):
# Properly fill locations within dungeon # Properly fill locations within dungeon
location.dungeon = r.dungeon_index 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): for dungeon_index in range(0, 9):
locs = dungeon_locations_by_dungeon[dungeon_index] locs = dungeon_locations_by_dungeon[dungeon_index]
locs = [loc for loc in locs if not loc.item] locs = [loc for loc in locs if not loc.item]