Filter events out of datapackage

This commit is contained in:
Fabian Dill 2021-07-12 18:47:58 +02:00
parent 741ab3e45c
commit 14cadbf80d
5 changed files with 27 additions and 19 deletions

View File

@ -9,8 +9,13 @@ class AutoWorldRegister(type):
def __new__(cls, name, bases, dct): def __new__(cls, name, bases, dct):
dct["all_names"] = dct["item_names"] | dct["location_names"] | set(dct.get("item_name_groups", {})) 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["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()} 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) new_class = super().__new__(cls, name, bases, dct)
if "game" in dct: if "game" in dct:
AutoWorldRegister.world_types[dct["game"]] = new_class AutoWorldRegister.world_types[dct["game"]] = new_class

View File

@ -391,7 +391,7 @@ item_table = \
'Whispering_Root-Waterways': HKItemData(advancement=True, id=16777410, type='Root'), 'Whispering_Root-Waterways': HKItemData(advancement=True, id=16777410, type='Root'),
'World_Sense': HKItemData(advancement=False, id=16777220, type='Dreamer')} '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]] = {} lookup_type_to_names:Dict[str, Set[str]] = {}
for item, item_data in item_table.items(): for item, item_data in item_table.items():
lookup_type_to_names.setdefault(item_data.type, set()).add(item) lookup_type_to_names.setdefault(item_data.type, set()).add(item)

View File

@ -18,7 +18,7 @@ class HKWorld(World):
item_names: Set[str] = frozenset(item_table) item_names: Set[str] = frozenset(item_table)
location_names: Set[str] = frozenset(lookup_name_to_id) 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 location_name_to_id = lookup_name_to_id
def generate_basic(self): def generate_basic(self):

View File

@ -3,7 +3,7 @@ import typing
class ItemData(typing.NamedTuple): class ItemData(typing.NamedTuple):
code: int code: typing.Optional[int]
progression: bool progression: bool
@ -49,7 +49,7 @@ item_table = {
"Single Arrow": ItemData(45034, False), "Single Arrow": ItemData(45034, False),
"Bee Trap (Minecraft)": ItemData(45100, False), "Bee Trap (Minecraft)": ItemData(45100, False),
"Victory": ItemData(0, True) "Victory": ItemData(None, True)
} }
# If not listed here then has frequency 1 # If not listed here then has frequency 1

View File

@ -1,15 +1,19 @@
from BaseClasses import Location from BaseClasses import Location
import typing import typing
class AdvData(typing.NamedTuple): class AdvData(typing.NamedTuple):
id: int id: typing.Optional[int]
region: str region: str
class MinecraftAdvancement(Location): class MinecraftAdvancement(Location):
game: str = "Minecraft" game: str = "Minecraft"
def __init__(self, player: int, name: str, address: int, parent):
super().__init__(player, name, address if address else None, parent) def __init__(self, player: int, name: str, address: typing.Optional[int], parent):
self.event = True if address == 0 else False super().__init__(player, name, address, parent)
self.event = not address
advancement_table = { advancement_table = {
"Who is Cutting Onions?": AdvData(42000, 'Overworld'), "Who is Cutting Onions?": AdvData(42000, 'Overworld'),
@ -105,7 +109,7 @@ advancement_table = {
"Librarian": AdvData(42090, 'Overworld'), "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 = { exclusion_table = {
@ -134,10 +138,9 @@ exclusion_table = {
} }
} }
events_table = { events_table = {
"Ender Dragon": "Victory" "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
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} loc_data.id}