AutoWorld: add hint_blacklist, automatically generated all_names

MultiServer: revamp hint commands with AutoWorld
This commit is contained in:
Fabian Dill
2021-07-12 15:33:20 +02:00
parent ae32315bf7
commit 768ae584d3
4 changed files with 38 additions and 38 deletions

View File

@@ -1,12 +1,14 @@
from __future__ import annotations
from typing import Dict, Set, Tuple
from BaseClasses import MultiWorld, Item, CollectionState
class AutoWorldRegister(type):
world_types = {}
world_types:Dict[str, World] = {}
def __new__(cls, name, bases, dct):
dct["all_names"] = dct["item_names"] | dct["location_names"] | set(dct.get("item_name_groups", {}))
new_class = super().__new__(cls, name, bases, dct)
if "game" in dct:
AutoWorldRegister.world_types[dct["game"]] = new_class
@@ -35,6 +37,9 @@ class World(metaclass=AutoWorldRegister):
# maps item group names to sets of items. Example: "Weapons" -> {"Sword", "Bow"}
item_name_groups: Dict[str, Set[str]] = {}
location_names: Set[str] = frozenset() # set of all potential location names
all_names: Set[str] = frozenset() # gets automatically populated with all item, item group and location names
hint_blacklist: Set[str] = frozenset() # any names that should not be hintable
def __init__(self, world: MultiWorld, player: int):
self.world = world

View File

@@ -232,8 +232,6 @@ progression_mapping = {
lookup_id_to_name = {data[2]: name for name, data in item_table.items() if type(data[2]) == int}
hint_blacklist = {"Triforce"}
item_name_groups = {"Bows":
{"Bow", "Silver Arrows", "Silver Bow", "Progressive Bow (Alt)", "Progressive Bow"},
"Gloves":

View File

@@ -13,6 +13,7 @@ class ALTTPWorld(World):
item_name_groups = item_name_groups
item_names = frozenset(item_table)
location_names = frozenset(lookup_name_to_id)
hint_blacklist = {"Triforce"}
def collect(self, state: CollectionState, item: Item) -> bool:
if item.name.startswith('Progressive '):