aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/examples/rules/COC/Character.py
blob: bb30661fef183ceecbfeec6edc8a8af6f0fb9416 (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# MyRule
import math

from typing import Union
from dataclasses import dataclass

from hrc.rule import Rule
from hrc.rule.BaseRule import CharacterCard

aliases = Rule.aliases

@dataclass
class Attributes(CharacterCard.Attribute):

    @aliases(["luck", "运气"], ignore_case=True)
    def LUK(self) -> Union[str, int, None]: ...

    @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
        )

    @aliases(["年龄", "age"], ignore_case=True)
    def AGE(self) -> Union[str, int, None]: ...

    @aliases(["HitPoints", "生命值", "生命"], ignore_case=True)
    def HP(self) -> Union[str, int, None]:
        return self.MAX_HP

    @aliases(["最大生命值", "HitPointTotal", "总生命值"], ignore_case=True)
    def MAX_HP(self) -> Union[str, int, None]:
        if hasattr(self, "CON") and hasattr(self, "SIZ"):
            return (self.CON() + self.SIZ()) // 10
        else:
            return None

    @aliases(["理智", "Sanity", "SanityPoint", "理智值", "san值"], ignore_case=True)
    def SAN(self) -> Union[str, int, None]:
        return self.POW()

    @aliases(["最大理智值", "MaximumSanity"], ignore_case=True)
    def MAX_SAN(self) -> Union[str, int, None]:
        return 99 - self.player_card.CM()

    @aliases(["魔法", "魔法值", "MagicPoints"], ignore_case=True)
    def MP(self) -> Union[str, int, None]:
        if hasattr(self, "POW"):
            return math.floor(self.POW() / 5)
        else:
            return 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
        )

    @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
        )

    @aliases(["移动速度"], ignore_case=True)
    def MOV(self) -> Union[str, int, None]:
        mov = 8
        siz = self.player_card.SIZ()
        str_val = self.player_card.STR()
        dex = self.player_card.DEX()
        age = self.AGE()

        if age >= 40:
            mov -= math.floor(age / 10 - 3)

        if str_val > siz and dex > siz:
            mov += 1
        elif siz > str_val and siz > dex:
            mov -= 1

        return mov

    @aliases(["兴趣技能点", "PersonalInterests"], ignore_case=True)
    def PI(self) -> Union[str, int, None]:
        return self.player_card.INT() * 2

    @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)
        return None

    @aliases(["锁匠", "开锁", "撬锁", "Locksmith"], ignore_case=True)
    def LOCKSMITH(self) -> Union[str, int, None]:
        return 1

    @aliases(["动物驯养", "驯兽", "AnimalHandling"], ignore_case=True)
    def ANIMAL_HANDLING(self) -> Union[str, int, None]:
        return 1