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'),
@ -49,7 +53,7 @@ advancement_table = {
"War Pigs": AdvData(42034, 'Bastion Remnant'), "War Pigs": AdvData(42034, 'Bastion Remnant'),
"Take Aim": AdvData(42035, 'Overworld'), "Take Aim": AdvData(42035, 'Overworld'),
"Total Beelocation": AdvData(42036, 'Overworld'), "Total Beelocation": AdvData(42036, 'Overworld'),
"Arbalistic": AdvData(42037, 'Overworld'), "Arbalistic": AdvData(42037, 'Overworld'),
"The End... Again...": AdvData(42038, 'The End'), "The End... Again...": AdvData(42038, 'The End'),
"Acquire Hardware": AdvData(42039, 'Overworld'), "Acquire Hardware": AdvData(42039, 'Overworld'),
"Not Quite \"Nine\" Lives": AdvData(42040, 'The Nether'), "Not Quite \"Nine\" Lives": AdvData(42040, 'The Nether'),
@ -91,7 +95,7 @@ advancement_table = {
"Cover Me in Debris": AdvData(42076, 'The Nether'), "Cover Me in Debris": AdvData(42076, 'The Nether'),
"The End?": AdvData(42077, 'The End'), "The End?": AdvData(42077, 'The End'),
"The Parrots and the Bats": AdvData(42078, 'Overworld'), "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'), "Getting Wood": AdvData(42080, 'Overworld'),
"Time to Mine!": AdvData(42081, 'Overworld'), "Time to Mine!": AdvData(42081, 'Overworld'),
"Hot Topic": AdvData(42082, 'Overworld'), "Hot Topic": AdvData(42082, 'Overworld'),
@ -103,9 +107,9 @@ advancement_table = {
"When Pigs Fly": AdvData(42088, 'Overworld'), "When Pigs Fly": AdvData(42088, 'Overworld'),
"Overkill": AdvData(42089, 'Nether Fortress'), "Overkill": AdvData(42089, 'Nether Fortress'),
"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 = {
@ -119,9 +123,9 @@ exclusion_table = {
"A Balanced Diet": "100 XP", "A Balanced Diet": "100 XP",
"Uneasy Alliance": "100 XP", "Uneasy Alliance": "100 XP",
"Cover Me in Debris": "100 XP", "Cover Me in Debris": "100 XP",
"A Complete Catalogue": "50 XP", "A Complete Catalogue": "50 XP",
"Overpowered": "50 XP" "Overpowered": "50 XP"
}, },
"insane": { "insane": {
"How Did We Get Here?": "500 XP", "How Did We Get Here?": "500 XP",
"Adventuring Time": "500 XP" "Adventuring Time": "500 XP"
@ -129,15 +133,14 @@ exclusion_table = {
"postgame": { "postgame": {
"The Next Generation": "50 XP", "The Next Generation": "50 XP",
"The End... Again...": "50 XP", "The End... Again...": "50 XP",
"You Need a Mint": "50 XP", "You Need a Mint": "50 XP",
"Monsters Hunted": "100 XP" "Monsters Hunted": "100 XP"
} }
} }
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}