feat(achievement): support obtain achievements

This commit is contained in:
MingxuanGame
2025-08-21 08:50:16 +00:00
parent 9fb0d0c198
commit 068697355f
15 changed files with 864 additions and 30 deletions

View File

@@ -0,0 +1,22 @@
from __future__ import annotations
import importlib
from app.log import logger
from app.models.achievement import MEDALS, Medals
from app.path import ACHIEVEMENTS_DIR
def load_achievements() -> Medals:
for module in ACHIEVEMENTS_DIR.iterdir():
if module.is_file() and module.suffix == ".py":
module_name = module.stem
module_achievements = importlib.import_module(
f"app.achievements.{module_name}"
)
medals = getattr(module_achievements, "MEDALS", {})
MEDALS.update(medals)
logger.success(
f"Successfully loaded {len(medals)} achievements from {module_name}.py"
)
return MEDALS