aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hydrorollcore/rule.py32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/hydrorollcore/rule.py b/src/hydrorollcore/rule.py
index a1b07cb9..7dd24836 100644
--- a/src/hydrorollcore/rule.py
+++ b/src/hydrorollcore/rule.py
@@ -13,6 +13,34 @@ class RuleLoadType(Enum):
CLASS = "class"
+class Result(metaclass=ABCMeta):
+ """规则检定结果基类"""
+
+ event: str
+
+
+class Dice(metaclass=ABCMeta):
+ """掷骰基类"""
+
+ roll_string: str
+ db: str
+ outcome: int
+
+ def __repr__(self) -> str:
+ return f'<HydroDice "{self.db.upper()}">'
+
+ def __str__(self) -> str:
+ return self.db.upper()
+
+ @abstractmethod
+ def parse(self) -> "Dice":
+ raise NotImplementedError
+
+ @abstractmethod
+ def roll(self) -> int:
+ raise NotImplementedError
+
+
class Rule(metaclass=ABCMeta):
"""规则基类"""
@@ -20,9 +48,9 @@ class Rule(metaclass=ABCMeta):
priority: int = 0
@abstractmethod
- def __init__(self):
+ def __init__(self) -> None:
raise NotImplementedError
@abstractmethod
- async def run(self):
+ def check(self) -> Result:
raise NotImplementedError