aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/examples/rules/COC7/__init__.py
diff options
context:
space:
mode:
author简律纯 <i@jyunko.cn>2024-07-06 09:14:35 +0800
committer简律纯 <i@jyunko.cn>2024-07-06 09:14:35 +0800
commit9558df091151d58aa7433c79ac3b8e050674c6fc (patch)
treebfec4b888660354235cc4ff37c193d4182fe667c /examples/rules/COC7/__init__.py
parent0ed10486f719c23ab7e0e84d2e119a7fa5f70475 (diff)
downloadHydroRollCore-9558df091151d58aa7433c79ac3b8e050674c6fc.tar.gz
HydroRollCore-9558df091151d58aa7433c79ac3b8e050674c6fc.zip
chore: move COC7 folder into rules folder
Diffstat (limited to 'examples/rules/COC7/__init__.py')
-rw-r--r--examples/rules/COC7/__init__.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/examples/rules/COC7/__init__.py b/examples/rules/COC7/__init__.py
new file mode 100644
index 0000000..25acdaa
--- /dev/null
+++ b/examples/rules/COC7/__init__.py
@@ -0,0 +1,48 @@
+import math
+
+from hrc.core import Core
+from hrc.rule import Rule, BaseRule # noqa: F401
+from hrc.dependencies import Depends
+
+from .Character import Attributes
+from .Wiki import Wiki
+
+core = Core()
+
+
+class COC7(Rule):
+
+ attr: Attributes = Depends() # 必须实现一个继承自 Character.Attribute 的子类
+ wiki: Wiki = Depends() # 可选实现一个 Wiki 类
+
+ @core.event_postprocessor_hook
+ async def auto_card(self):
+ if self.session and self.session.gid and self.ac:
+ if hasattr(self.pc.trans, "生命") or hasattr(self.pc.trans, "理智"):
+ self.event.call_back(
+ "set_group_card", self.pc.gid, f"card#{self.pc.uid}", await self.overview_card()
+ )
+
+ async def overview_card(self):
+ max_hp = math.floor((self.pc.get("CON", 0) + self.pc.get("SIZ", 0) / 10))
+ max_san = math.floor(99 - self.pc.get("CM", 0))
+ mp = self.pc.get("MP", 0)
+ mp_show = (
+ " mp" + str(mp) + "/" + str(math.floor(self.pc.get("POW", 0) / 5))
+ if mp and mp != math.floor(self.pc.get("POW", 0) / 5)
+ else ""
+ )
+ return (
+ self.pc.get("__Name", "")
+ + " hp"
+ + str(self.pc.get("HP", max_hp))
+ + "/"
+ + str(max_hp)
+ + " san"
+ + str(self.pc.get("SAN", "?"))
+ + "/"
+ + str(max_san)
+ + mp_show
+ + " DEX"
+ + str(self.pc.get("DEX", "?"))
+ ) \ No newline at end of file