aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/examples
diff options
context:
space:
mode:
author简律纯 <i@jyunko.cn>2024-06-28 18:25:40 +0800
committer简律纯 <i@jyunko.cn>2024-06-28 18:25:40 +0800
commit6dfe2f4a87362a27fe2e97a154daac2f11883284 (patch)
treebd4f28514482042735182d86d2c89dec8d655674 /examples
parent1b0d67664557e6f0b4a421e1183cee1b0dbca2d3 (diff)
downloadHydroRollCore-6dfe2f4a87362a27fe2e97a154daac2f11883284.tar.gz
HydroRollCore-6dfe2f4a87362a27fe2e97a154daac2f11883284.zip
style: ruff format code
Diffstat (limited to 'examples')
-rw-r--r--examples/COC7/Character.py94
-rw-r--r--examples/COC7/Wiki.py7
-rw-r--r--examples/COC7/__init__.py37
-rw-r--r--examples/brp_character.py4
4 files changed, 83 insertions, 59 deletions
diff --git a/examples/COC7/Character.py b/examples/COC7/Character.py
index b5f07c5..70b934b 100644
--- a/examples/COC7/Character.py
+++ b/examples/COC7/Character.py
@@ -10,87 +10,101 @@ from hrc.rule.BaseRule import CharacterCard
@dataclass
class Attributes(CharacterCard.Attribute):
-
@property
- @aliases(['luck', '运气'], ignore_case=True)
+ @aliases(["luck", "运气"], ignore_case=True)
def LUK(self) -> Union[str, int, None]: ...
@property
- @aliases(['伤害加值', 'DamageBonus'], ignore_case=True)
+ @aliases(["伤害加值", "DamageBonus"], ignore_case=True)
def DB(self) -> Union[str, int, None]:
sum = self.STR + self.SIZ
return (
- str(math.ceil((sum - 164) / 80)) + "D6" if sum > 164 else
- "1D4" if sum > 124 else
- "0" if sum > 84 else
- "-1" if sum > 64 else
- "-2" if sum > 0 else
- None
+ str(math.ceil((sum - 164) / 80)) + "D6"
+ if sum > 164
+ else "1D4"
+ if sum > 124
+ else "0"
+ if sum > 84
+ else "-1"
+ if sum > 64
+ else "-2"
+ if sum > 0
+ else None
)
@property
- @aliases(['年龄', 'age'], ignore_case=True)
+ @aliases(["年龄", "age"], ignore_case=True)
def AGE(self) -> Union[str, int, None]: ...
@property
- @aliases(['HitPoints', '生命值', '生命'], ignore_case=True)
+ @aliases(["HitPoints", "生命值", "生命"], ignore_case=True)
def HP(self) -> Union[str, int, None]:
return self.MAX_HP
@property
- @aliases(['最大生命值', 'HitPointTotal', '总生命值'], ignore_case=True)
+ @aliases(["最大生命值", "HitPointTotal", "总生命值"], ignore_case=True)
def MAX_HP(self) -> Union[str, int, None]:
- if hasattr(self, 'CON') and hasattr(self, 'SIZ'):
+ if hasattr(self, "CON") and hasattr(self, "SIZ"):
return (self.CON + self.SIZ) // 10
else:
return None
@property
- @aliases(['理智', 'Sanity', 'SanityPoint', '理智值', 'san值'], ignore_case=True)
+ @aliases(["理智", "Sanity", "SanityPoint", "理智值", "san值"], ignore_case=True)
def SAN(self) -> Union[str, int, None]:
return self.POW
@property
- @aliases(['最大理智值', 'MaximumSanity'], ignore_case=True)
+ @aliases(["最大理智值", "MaximumSanity"], ignore_case=True)
def MAX_SAN(self) -> Union[str, int, None]:
return 99 - self.player_card.CM
@property
- @aliases(['魔法', '魔法值', 'MagicPoints'], ignore_case=True)
+ @aliases(["魔法", "魔法值", "MagicPoints"], ignore_case=True)
def MP(self) -> Union[str, int, None]:
- if hasattr(self, 'POW'):
+ if hasattr(self, "POW"):
return math.floor(self.POW / 5)
else:
return None
@property
- @aliases(['伤害加值', 'DamageBonus'], ignore_case=True)
- def DB(self) -> Union[int, str, None]:
+ @aliases(["伤害加值", "DamageBonus"], ignore_case=True)
+ def DB(self) -> Union[int, str, None]: # noqa: F811
sum = self.STR + self.SIZ
return (
- str(math.ceil((sum - 164) / 80)) + "D6" if sum > 164 else
- "1D4" if sum > 124 else
- "0" if sum > 84 else
- "-1" if sum > 64 else
- "-2" if sum > 0 else
- None
+ str(math.ceil((sum - 164) / 80)) + "D6"
+ if sum > 164
+ else "1D4"
+ if sum > 124
+ else "0"
+ if sum > 84
+ else "-1"
+ if sum > 64
+ else "-2"
+ if sum > 0
+ else None
)
@property
- @aliases(['体格', 'build'], ignore_case=True)
+ @aliases(["体格", "build"], ignore_case=True)
def BUILD(self) -> Union[str, int, None]:
sum = self.STR + self.SIZ
return (
- math.ceil((sum - 84) / 80) if sum > 164 else
- 1 if sum > 124 else
- 0 if sum > 84 else
- -1 if sum > 64 else
- -2 if sum > 0 else
- None
+ math.ceil((sum - 84) / 80)
+ if sum > 164
+ else 1
+ if sum > 124
+ else 0
+ if sum > 84
+ else -1
+ if sum > 64
+ else -2
+ if sum > 0
+ else None
)
@property
- @aliases(['移动速度'], ignore_case=True)
+ @aliases(["移动速度"], ignore_case=True)
def MOV(self) -> Union[str, int, None]:
mov = 8
siz = self.player_card.SIZ
@@ -109,23 +123,23 @@ class Attributes(CharacterCard.Attribute):
return mov
@property
- @aliases(['兴趣技能点', 'PersonalInterests'], ignore_case=True)
+ @aliases(["兴趣技能点", "PersonalInterests"], ignore_case=True)
def PI(self) -> Union[str, int, None]:
- return self.player_card.INT*2
+ return self.player_card.INT * 2
@property
- @aliases(['闪避', 'Dodge'], ignore_case=True)
+ @aliases(["闪避", "Dodge"], ignore_case=True)
def DODGE(self) -> Union[str, int, None]:
- if hasattr(self.player_card, 'DEX'):
- return math.floor(self.player_card.DEX/2)
+ if hasattr(self.player_card, "DEX"):
+ return math.floor(self.player_card.DEX / 2)
return None
@property
- @aliases(['锁匠', '开锁', '撬锁', 'Locksmith'], ignore_case=True)
+ @aliases(["锁匠", "开锁", "撬锁", "Locksmith"], ignore_case=True)
def LOCKSMITH(self) -> Union[str, int, None]:
return 1
@property
- @aliases(['动物驯养', '驯兽', 'AnimalHandling'], ignore_case=True)
+ @aliases(["动物驯养", "驯兽", "AnimalHandling"], ignore_case=True)
def ANIMAL_HANDLING(self) -> Union[str, int, None]:
return 1
diff --git a/examples/COC7/Wiki.py b/examples/COC7/Wiki.py
index 2c786e7..62b66ab 100644
--- a/examples/COC7/Wiki.py
+++ b/examples/COC7/Wiki.py
@@ -1,9 +1,2 @@
# MyRule
-import math
-import dataclasses
-from dataclasses import dataclass
-from typing import Literal, Optional, Union
-from pydantic import Field, BaseModel
-from hrc.rule import aliases, BaseRule
-from hrc.rule.BaseRule import CharacterCard \ No newline at end of file
diff --git a/examples/COC7/__init__.py b/examples/COC7/__init__.py
index ecd2091..01efe57 100644
--- a/examples/COC7/__init__.py
+++ b/examples/COC7/__init__.py
@@ -6,19 +6,36 @@ core = Core()
@core.event_post_processor_hook
-async def auto_card(_event='T_Event'):
+async def auto_card(_event="T_Event"):
g = core.session
pc = player_card
if g and core.session.gid and g.ac:
- if hasattr(pc.trans, '生命') or hasattr(pc.trans, '理智'):
- core.session.call("set_group_card", pc.gid, f"card#{pc.uid}", await overview_card(pc.char))
+ if hasattr(pc.trans, "生命") or hasattr(pc.trans, "理智"):
+ core.session.call(
+ "set_group_card", pc.gid, f"card#{pc.uid}", await overview_card(pc.char)
+ )
async def overview_card(pc: player_card):
- max_hp = math.floor((pc.get('CON', 0) + pc.get('SIZ', 0) / 10))
- max_san = math.floor(99 - pc.get('CM', 0))
- mp = pc.get('MP', 0)
- mp_show = " mp" + str(mp) + "/" + str(
- math.floor(pc.get('POW', 0) / 5)
- ) if mp and mp != math.floor(pc.get('POW', 0) / 5) else ""
- return pc.get('__Name', "") + " hp" + str(pc.get('HP', max_hp)) + "/" + str(max_hp) + " san" + str(pc.get('SAN', "?")) + "/" + str(max_san) + mp_show + " DEX" + str(pc.get('DEX', "?"))
+ max_hp = math.floor((pc.get("CON", 0) + pc.get("SIZ", 0) / 10))
+ max_san = math.floor(99 - pc.get("CM", 0))
+ mp = pc.get("MP", 0)
+ mp_show = (
+ " mp" + str(mp) + "/" + str(math.floor(pc.get("POW", 0) / 5))
+ if mp and mp != math.floor(pc.get("POW", 0) / 5)
+ else ""
+ )
+ return (
+ pc.get("__Name", "")
+ + " hp"
+ + str(pc.get("HP", max_hp))
+ + "/"
+ + str(max_hp)
+ + " san"
+ + str(pc.get("SAN", "?"))
+ + "/"
+ + str(max_san)
+ + mp_show
+ + " DEX"
+ + str(pc.get("DEX", "?"))
+ )
diff --git a/examples/brp_character.py b/examples/brp_character.py
index 9b52aa3..cc3bfcd 100644
--- a/examples/brp_character.py
+++ b/examples/brp_character.py
@@ -1,6 +1,6 @@
import inspect
-from hydro_roll_core.development import Character
-from typing import Literal, List, Tuple, Union, Dict, Generic, Optional, TYPE_CHECKING
+from hrc.development import Character
+from typing import Literal, Union, Optional
class Identity: