1
0
This commit is contained in:
2025-10-26 11:33:08 +08:00
parent bd145ee5a3
commit be7daa8fc7
13 changed files with 95 additions and 57 deletions

View File

@@ -1,2 +1,18 @@
# base.py
class BasePuzzle:
pass
"""谜题基类"""
def refresh(self):
"""刷新谜题, 子类必须实现"""
raise NotImplementedError("谜题对象没有实现 refresh 方法")
def __str__(self):
"""字符串表示, 子类应该实现"""
return f"谜题: {type(self).__name__}"
@classmethod
def register(cls, name: str = None): # type: ignore
"""谜题注册装饰器"""
from registry import registry
puzzle_name = name or cls.__name__
return registry.register(puzzle_name, cls)