diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/COC7/Character.py | 48 | ||||
| -rw-r--r-- | examples/COC7/Wiki.py | 7 | ||||
| -rw-r--r-- | examples/COC7/__init__.py | 12 |
3 files changed, 34 insertions, 33 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 diff --git a/examples/COC7/Wiki.py b/examples/COC7/Wiki.py index 060fb9d..2c786e7 100644 --- a/examples/COC7/Wiki.py +++ b/examples/COC7/Wiki.py @@ -5,8 +5,5 @@ import dataclasses 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 - -class Query(Wiki): -
\ No newline at end of file +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 f3d781f..ecd2091 100644 --- a/examples/COC7/__init__.py +++ b/examples/COC7/__init__.py @@ -15,10 +15,10 @@ async def auto_card(_event='T_Event'): 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 "" + 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', "?")) |
