Spaces:
Sleeping
Sleeping
File size: 557 Bytes
91394e0 120744c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
from __future__ import annotations
import importlib
import pathlib
from .base import Character
CHARACTERS: dict[str, Character] = {}
for file in pathlib.Path(__file__).parent.glob("*.py"):
if file.name in {"__init__.py", "base.py"}:
continue
module_name = f"{__name__}.{file.stem}"
module = importlib.import_module(module_name)
if hasattr(module, "get_character"):
c: Character = getattr(module, "get_character")()
CHARACTERS[file.stem] = c
def get_character(name: str) -> Character:
return CHARACTERS[name]
|