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):
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

View File

@ -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)

View File

@ -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):

View File

@ -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

View File

@ -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}