From 14cadbf80d1a049c92479ba649f9a5cfad9e2db4 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Mon, 12 Jul 2021 18:47:58 +0200 Subject: [PATCH] Filter events out of datapackage --- worlds/AutoWorld.py | 5 +++++ worlds/hk/Items.py | 2 +- worlds/hk/__init__.py | 2 +- worlds/minecraft/Items.py | 4 ++-- worlds/minecraft/Locations.py | 33 ++++++++++++++++++--------------- 5 files changed, 27 insertions(+), 19 deletions(-) diff --git a/worlds/AutoWorld.py b/worlds/AutoWorld.py index 7a5cba34..0e821dea 100644 --- a/worlds/AutoWorld.py +++ b/worlds/AutoWorld.py @@ -9,8 +9,13 @@ class AutoWorldRegister(type): def __new__(cls, name, bases, dct): dct["all_names"] = dct["item_names"] | dct["location_names"] | set(dct.get("item_name_groups", {})) + # filter out any events + dct["item_name_to_id"] = {name: id for name, id in dct["item_name_to_id"].items() if id} + dct["location_name_to_id"] = {name: id for name, id in dct["location_name_to_id"].items() if id} + # build reverse lookups dct["item_id_to_name"] = {code: name for name, code in dct["item_name_to_id"].items()} dct["location_id_to_name"] = {code: name for name, code in dct["location_name_to_id"].items()} + # construct class new_class = super().__new__(cls, name, bases, dct) if "game" in dct: AutoWorldRegister.world_types[dct["game"]] = new_class diff --git a/worlds/hk/Items.py b/worlds/hk/Items.py index 379b5e24..51a3605d 100644 --- a/worlds/hk/Items.py +++ b/worlds/hk/Items.py @@ -391,7 +391,7 @@ item_table = \ 'Whispering_Root-Waterways': HKItemData(advancement=True, id=16777410, type='Root'), 'World_Sense': HKItemData(advancement=False, id=16777220, type='Dreamer')} -lookup_id_to_name:Dict[int, str] = {data.id: item_name for item_name, data in item_table.items()} +lookup_id_to_name:Dict[int, str] = {data.id: item_name for item_name, data in item_table.items() if data.type != 'Event'} lookup_type_to_names:Dict[str, Set[str]] = {} for item, item_data in item_table.items(): lookup_type_to_names.setdefault(item_data.type, set()).add(item) \ No newline at end of file diff --git a/worlds/hk/__init__.py b/worlds/hk/__init__.py index af8b8aa4..57fe17bd 100644 --- a/worlds/hk/__init__.py +++ b/worlds/hk/__init__.py @@ -18,7 +18,7 @@ class HKWorld(World): item_names: Set[str] = frozenset(item_table) location_names: Set[str] = frozenset(lookup_name_to_id) - item_name_to_id = {name: data.id for name, data in item_table.items()} + item_name_to_id = {name: data.id for name, data in item_table.items() if data.type != "Event"} location_name_to_id = lookup_name_to_id def generate_basic(self): diff --git a/worlds/minecraft/Items.py b/worlds/minecraft/Items.py index a5ddc23a..881b8050 100644 --- a/worlds/minecraft/Items.py +++ b/worlds/minecraft/Items.py @@ -3,7 +3,7 @@ import typing class ItemData(typing.NamedTuple): - code: int + code: typing.Optional[int] progression: bool @@ -49,7 +49,7 @@ item_table = { "Single Arrow": ItemData(45034, False), "Bee Trap (Minecraft)": ItemData(45100, False), - "Victory": ItemData(0, True) + "Victory": ItemData(None, True) } # If not listed here then has frequency 1 diff --git a/worlds/minecraft/Locations.py b/worlds/minecraft/Locations.py index 4ca20092..03a1ed89 100644 --- a/worlds/minecraft/Locations.py +++ b/worlds/minecraft/Locations.py @@ -1,15 +1,19 @@ from BaseClasses import Location import typing + class AdvData(typing.NamedTuple): - id: int + id: typing.Optional[int] region: str -class MinecraftAdvancement(Location): + +class MinecraftAdvancement(Location): game: str = "Minecraft" - def __init__(self, player: int, name: str, address: int, parent): - super().__init__(player, name, address if address else None, parent) - self.event = True if address == 0 else False + + def __init__(self, player: int, name: str, address: typing.Optional[int], parent): + super().__init__(player, name, address, parent) + self.event = not address + advancement_table = { "Who is Cutting Onions?": AdvData(42000, 'Overworld'), @@ -49,7 +53,7 @@ advancement_table = { "War Pigs": AdvData(42034, 'Bastion Remnant'), "Take Aim": AdvData(42035, 'Overworld'), "Total Beelocation": AdvData(42036, 'Overworld'), - "Arbalistic": AdvData(42037, 'Overworld'), + "Arbalistic": AdvData(42037, 'Overworld'), "The End... Again...": AdvData(42038, 'The End'), "Acquire Hardware": AdvData(42039, 'Overworld'), "Not Quite \"Nine\" Lives": AdvData(42040, 'The Nether'), @@ -91,7 +95,7 @@ advancement_table = { "Cover Me in Debris": AdvData(42076, 'The Nether'), "The End?": AdvData(42077, 'The End'), "The Parrots and the Bats": AdvData(42078, 'Overworld'), - "A Complete Catalogue": AdvData(42079, 'Village'), + "A Complete Catalogue": AdvData(42079, 'Village'), "Getting Wood": AdvData(42080, 'Overworld'), "Time to Mine!": AdvData(42081, 'Overworld'), "Hot Topic": AdvData(42082, 'Overworld'), @@ -103,9 +107,9 @@ advancement_table = { "When Pigs Fly": AdvData(42088, 'Overworld'), "Overkill": AdvData(42089, 'Nether Fortress'), "Librarian": AdvData(42090, 'Overworld'), - "Overpowered": AdvData(42091, 'Overworld'), + "Overpowered": AdvData(42091, 'Overworld'), - "Ender Dragon": AdvData(0, 'The End') + "Ender Dragon": AdvData(None, 'The End') } exclusion_table = { @@ -119,9 +123,9 @@ exclusion_table = { "A Balanced Diet": "100 XP", "Uneasy Alliance": "100 XP", "Cover Me in Debris": "100 XP", - "A Complete Catalogue": "50 XP", + "A Complete Catalogue": "50 XP", "Overpowered": "50 XP" - }, + }, "insane": { "How Did We Get Here?": "500 XP", "Adventuring Time": "500 XP" @@ -129,15 +133,14 @@ exclusion_table = { "postgame": { "The Next Generation": "50 XP", "The End... Again...": "50 XP", - "You Need a Mint": "50 XP", + "You Need a Mint": "50 XP", "Monsters Hunted": "100 XP" } } - events_table = { "Ender Dragon": "Victory" } - -lookup_id_to_name: typing.Dict[int, str] = {loc_data.id: loc_name for loc_name, loc_data in advancement_table.items() if loc_data.id} +lookup_id_to_name: typing.Dict[int, str] = {loc_data.id: loc_name for loc_name, loc_data in advancement_table.items() if + loc_data.id}