aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/examples/COC7/Character.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/COC7/Character.py')
-rw-r--r--examples/COC7/Character.py48
1 files changed, 26 insertions, 22 deletions
diff --git a/examples/COC7/Character.py b/examples/COC7/Character.py
index d2a6b9f..b5f07c5 100644
--- a/examples/COC7/Character.py
+++ b/examples/COC7/Character.py
@@ -1,12 +1,11 @@
# MyRule
import math
-import dataclasses
+from typing import Union
from dataclasses import dataclass
-from typing import Literal, Optional, Union
-from pydantic import Field, BaseModel
-from hrc.rules import aliases, BaseRule
-from hrc.rules.BaseRule import CharacterCard
+
+from hrc.rule import aliases
+from hrc.rule.BaseRule import CharacterCard
@dataclass
@@ -14,28 +13,33 @@ class Attributes(CharacterCard.Attribute):
@property
@aliases(['luck', '运气'], ignore_case=True)
- def LUK(self) -> Union[str, int]: ...
+ def LUK(self) -> Union[str, int, None]: ...
@property
- def DB(self) -> Union[str, int]:
- sum = self.player_card.STR + self.player_card.SIZ
- if sum == 164:
- return math.ceil((sum-164)/80) + "D6"
- elif sum == 124:
- return "1D4"
+ @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
+ )
@property
@aliases(['年龄', 'age'], ignore_case=True)
- def AGE(self) -> Union[str, int]: ...
+ def AGE(self) -> Union[str, int, None]: ...
@property
@aliases(['HitPoints', '生命值', '生命'], ignore_case=True)
- def HP(self) -> Union[str, int]:
+ def HP(self) -> Union[str, int, None]:
return self.MAX_HP
@property
@aliases(['最大生命值', 'HitPointTotal', '总生命值'], ignore_case=True)
- def MAX_HP(self) -> Union[str, int]:
+ def MAX_HP(self) -> Union[str, int, None]:
if hasattr(self, 'CON') and hasattr(self, 'SIZ'):
return (self.CON + self.SIZ) // 10
else:
@@ -43,17 +47,17 @@ class Attributes(CharacterCard.Attribute):
@property
@aliases(['理智', 'Sanity', 'SanityPoint', '理智值', 'san值'], ignore_case=True)
- def SAN(self) -> Union[str, int]:
+ def SAN(self) -> Union[str, int, None]:
return self.POW
@property
@aliases(['最大理智值', 'MaximumSanity'], ignore_case=True)
- def MAX_SAN(self) -> Union[str, int]:
+ def MAX_SAN(self) -> Union[str, int, None]:
return 99 - self.player_card.CM
@property
@aliases(['魔法', '魔法值', 'MagicPoints'], ignore_case=True)
- def MP(self) -> Union[str, int]:
+ def MP(self) -> Union[str, int, None]:
if hasattr(self, 'POW'):
return math.floor(self.POW / 5)
else:
@@ -89,9 +93,9 @@ class Attributes(CharacterCard.Attribute):
@aliases(['移动速度'], ignore_case=True)
def MOV(self) -> Union[str, int, None]:
mov = 8
- siz = self.SIZ
- str_val = self.STR
- dex = self.DEX
+ siz = self.player_card.SIZ
+ str_val = self.player_card.STR
+ dex = self.player_card.DEX
age = self.AGE
if age >= 40:
@@ -105,7 +109,7 @@ class Attributes(CharacterCard.Attribute):
return mov
@property
- @aliases(['兴趣技能点', 'PersonalInterests'], ignore_case=Ture)
+ @aliases(['兴趣技能点', 'PersonalInterests'], ignore_case=True)
def PI(self) -> Union[str, int, None]:
return self.player_card.INT*2