blob: 8ab60ae52d64956e4cc65ced0d961bb1e02fc6ed (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
RULE = """from HydroRollCore import Rule, Result, Dice
class MyRule(Rule):
\"\"\"自设规则包\"\"\"
name = "MyRule"
priority: int = 0
def __init__(self) -> None:
\"\"\"初始化你的规则包\"\"\"
def check(self, dice: Dice) -> Result:
\"\"\"声明规则包检定方式\"\"\"
return Result("myevent.event1", True)
"""
EVENT = """from HydroRollCore import Event
__events__ = ["MyEvent"]
class MyEvent(Event):
name = "event1"
output = "检定成功!"
"""
DICE = """from HydroRollCore import Dice
import random
import re
class BaseDice(Dice):
\"\"\"多面骰\"\"\"
def __init__(self, roll_string: str = "") -> None:
self.roll_string = roll_string
self.parse()
def parse(self) -> "Dice":
self.dices = []
split = re.split(r"[dD]", self.roll_string)
if split[0]:
self.a = int(split[0])
else:
self.a = 1
if split[1]:
self.b = int(split[1])
else:
self.b = 100
self.db = f"{self.a}D{self.b}"
self.dices += [f"D{self.b}"] * self.a
return self
def roll(self) -> int:
self.results = []
for _ in range(self.a):
result = random.randint(1, self.b)
self.results.append(result)
self.outcome = sum(self.results)
return self.outcome
"""
|