add persona conditions

This commit is contained in:
bridge
2025-10-04 17:13:35 +08:00
parent de225bd3da
commit f109abbb08
6 changed files with 89 additions and 53 deletions

View File

@@ -15,6 +15,21 @@ class Alignment(Enum):
def get_info(self) -> str:
return alignment_strs[self] + ": " + alignment_infos[self]
def __hash__(self) -> int:
return hash(self.value)
def __eq__(self, other) -> bool:
"""
允许与同类或字符串比较:
- Alignment: 恒等比较
- str: 同时支持英文值value与中文显示__str__
"""
if isinstance(other, Alignment):
return self is other
if isinstance(other, str):
return other == self.value or other == str(self)
return False
alignment_strs = {
Alignment.RIGHTEOUS: "",