From a0ebfdc2cf5f37c40caedcd1dfdcef9660b08f69 Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Thu, 27 Jun 2024 21:14:04 +0800 Subject: feat(BaseRule): add Character.py --- docs/_static/.$Structures.svg.dtmp | 4 -- docs/_static/Structures.svg | 2 +- examples/COC7/Character.py | 127 +++++++++++++++++++++++++++++++++++++ examples/COC7/Wiki.py | 12 ++++ examples/COC7/__init__.py | 24 +++++++ hrc/rules/BaseRule/JudgeRule.py | 13 ---- hrc/rules/BaseRule/Wiki.py | 0 hrc/rules/__init__.py | 3 +- hrc/rules/config.py | 4 ++ pdm.lock | 105 +++++++++++++++++++++++++++++- pyproject.toml | 1 + tests/test_BaseRule.py | 45 ++----------- 12 files changed, 279 insertions(+), 61 deletions(-) delete mode 100644 docs/_static/.$Structures.svg.dtmp create mode 100644 examples/COC7/Character.py create mode 100644 examples/COC7/Wiki.py create mode 100644 examples/COC7/__init__.py delete mode 100644 hrc/rules/BaseRule/JudgeRule.py create mode 100644 hrc/rules/BaseRule/Wiki.py create mode 100644 hrc/rules/config.py diff --git a/docs/_static/.$Structures.svg.dtmp b/docs/_static/.$Structures.svg.dtmp deleted file mode 100644 index 26247d9..0000000 --- a/docs/_static/.$Structures.svg.dtmp +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/docs/_static/Structures.svg b/docs/_static/Structures.svg index 674f55e..b42566b 100644 --- a/docs/_static/Structures.svg +++ b/docs/_static/Structures.svg @@ -1,4 +1,4 @@ -
Orgchart
Orgchart
Tessa Miller
CFO
Email
Tessa Miller...
Edward Morrison
Brand Manager
Email
Edward Morrison...
Evan Valet
HR Director
Email
Evan Valet...
Alison Donovan
System Admin
Email
Alison Donovan...
Text is not SVG - cannot display
\ No newline at end of file +
Orgchart
Orgchart
Tessa Miller
CFO
Email
Tessa Miller...
Edward Morrison
Brand Manager
Email
Edward Morrison...
Evan Valet
HR Director
Email
Evan Valet...
Alison Donovan
System Admin
Email
Alison Donovan...
Text is not SVG - cannot display
\ No newline at end of file diff --git a/examples/COC7/Character.py b/examples/COC7/Character.py new file mode 100644 index 0000000..d2a6b9f --- /dev/null +++ b/examples/COC7/Character.py @@ -0,0 +1,127 @@ +# MyRule +import math +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 + + +@dataclass +class Attributes(CharacterCard.Attribute): + + @property + @aliases(['luck', '运气'], ignore_case=True) + def LUK(self) -> Union[str, int]: ... + + @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" + + @property + @aliases(['年龄', 'age'], ignore_case=True) + def AGE(self) -> Union[str, int]: ... + + @property + @aliases(['HitPoints', '生命值', '生命'], ignore_case=True) + def HP(self) -> Union[str, int]: + return self.MAX_HP + + @property + @aliases(['最大生命值', 'HitPointTotal', '总生命值'], ignore_case=True) + def MAX_HP(self) -> Union[str, int]: + 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) + def SAN(self) -> Union[str, int]: + return self.POW + + @property + @aliases(['最大理智值', 'MaximumSanity'], ignore_case=True) + def MAX_SAN(self) -> Union[str, int]: + return 99 - self.player_card.CM + + @property + @aliases(['魔法', '魔法值', 'MagicPoints'], ignore_case=True) + def MP(self) -> Union[str, int]: + 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]: + 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(['体格', '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 + ) + + @property + @aliases(['移动速度'], ignore_case=True) + def MOV(self) -> Union[str, int, None]: + mov = 8 + siz = self.SIZ + str_val = self.STR + dex = self.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 + + @property + @aliases(['兴趣技能点', 'PersonalInterests'], ignore_case=Ture) + def PI(self) -> Union[str, int, None]: + return self.player_card.INT*2 + + @property + @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 + + @property + @aliases(['锁匠', '开锁', '撬锁', 'Locksmith'], ignore_case=True) + def LOCKSMITH(self) -> Union[str, int, None]: + return 1 + + @property + @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 new file mode 100644 index 0000000..060fb9d --- /dev/null +++ b/examples/COC7/Wiki.py @@ -0,0 +1,12 @@ +# MyRule +import math +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 diff --git a/examples/COC7/__init__.py b/examples/COC7/__init__.py new file mode 100644 index 0000000..f3d781f --- /dev/null +++ b/examples/COC7/__init__.py @@ -0,0 +1,24 @@ +import math + +from hrc import Core, player_card + +core = Core() + + +@core.event_post_processor_hook +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)) + + +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', "?")) diff --git a/hrc/rules/BaseRule/JudgeRule.py b/hrc/rules/BaseRule/JudgeRule.py deleted file mode 100644 index 20d28a2..0000000 --- a/hrc/rules/BaseRule/JudgeRule.py +++ /dev/null @@ -1,13 +0,0 @@ -import dataclasses -from dataclasses import dataclass -from typing import Literal, Optional, Union - -@dataclass -class Custom(object): - ... - -class Attribute(Custom): - ... - -class Skill(Custom): - ... diff --git a/hrc/rules/BaseRule/Wiki.py b/hrc/rules/BaseRule/Wiki.py new file mode 100644 index 0000000..e69de29 diff --git a/hrc/rules/__init__.py b/hrc/rules/__init__.py index ccd3dbc..a32b693 100644 --- a/hrc/rules/__init__.py +++ b/hrc/rules/__init__.py @@ -8,4 +8,5 @@ from ..typing import RulesT class Rules(ABC, Generic[RulesT]): ... - \ No newline at end of file + + diff --git a/hrc/rules/config.py b/hrc/rules/config.py new file mode 100644 index 0000000..2926a03 --- /dev/null +++ b/hrc/rules/config.py @@ -0,0 +1,4 @@ +from pydantic import ConfigDict, BaseModel + +class ConfigModel(BaseModel): + ... \ No newline at end of file diff --git a/pdm.lock b/pdm.lock index 3c231ec..0315732 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default", "lint", "dev", "docs"] strategy = ["cross_platform"] lock_version = "4.4.1" -content_hash = "sha256:6a397399cbb573c77556f406ad9fcb7d091c37929af55bc146f6e7c952ae88dd" +content_hash = "sha256:01b1c497f1340087f8c5b728e930e69903dce579c47f26951fbe859693efabee" [[package]] name = "alabaster" @@ -17,6 +17,16 @@ files = [ {file = "alabaster-0.7.16.tar.gz", hash = "sha256:75a8b99c28a5dad50dd7f8ccdd447a121ddb3892da9e53d1ca5cca3106d58d65"}, ] +[[package]] +name = "annotated-types" +version = "0.7.0" +requires_python = ">=3.8" +summary = "Reusable constraint types to use with typing.Annotated" +files = [ + {file = "annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53"}, + {file = "annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89"}, +] + [[package]] name = "anyio" version = "4.3.0" @@ -732,6 +742,99 @@ files = [ {file = "pycparser-2.22.tar.gz", hash = "sha256:491c8be9c040f5390f5bf44a5b07752bd07f56edf992381b05c701439eec10f6"}, ] +[[package]] +name = "pydantic" +version = "2.7.4" +requires_python = ">=3.8" +summary = "Data validation using Python type hints" +dependencies = [ + "annotated-types>=0.4.0", + "pydantic-core==2.18.4", + "typing-extensions>=4.6.1", +] +files = [ + {file = "pydantic-2.7.4-py3-none-any.whl", hash = "sha256:ee8538d41ccb9c0a9ad3e0e5f07bf15ed8015b481ced539a1759d8cc89ae90d0"}, + {file = "pydantic-2.7.4.tar.gz", hash = "sha256:0c84efd9548d545f63ac0060c1e4d39bb9b14db8b3c0652338aecc07b5adec52"}, +] + +[[package]] +name = "pydantic-core" +version = "2.18.4" +requires_python = ">=3.8" +summary = "Core functionality for Pydantic validation and serialization" +dependencies = [ + "typing-extensions!=4.7.0,>=4.6.0", +] +files = [ + {file = "pydantic_core-2.18.4-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:f76d0ad001edd426b92233d45c746fd08f467d56100fd8f30e9ace4b005266e4"}, + {file = "pydantic_core-2.18.4-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:59ff3e89f4eaf14050c8022011862df275b552caef8082e37b542b066ce1ff26"}, + {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a55b5b16c839df1070bc113c1f7f94a0af4433fcfa1b41799ce7606e5c79ce0a"}, + {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:4d0dcc59664fcb8974b356fe0a18a672d6d7cf9f54746c05f43275fc48636851"}, + {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8951eee36c57cd128f779e641e21eb40bc5073eb28b2d23f33eb0ef14ffb3f5d"}, + {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4701b19f7e3a06ea655513f7938de6f108123bf7c86bbebb1196eb9bd35cf724"}, + {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e00a3f196329e08e43d99b79b286d60ce46bed10f2280d25a1718399457e06be"}, + {file = "pydantic_core-2.18.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:97736815b9cc893b2b7f663628e63f436018b75f44854c8027040e05230eeddb"}, + {file = "pydantic_core-2.18.4-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:6891a2ae0e8692679c07728819b6e2b822fb30ca7445f67bbf6509b25a96332c"}, + {file = "pydantic_core-2.18.4-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:bc4ff9805858bd54d1a20efff925ccd89c9d2e7cf4986144b30802bf78091c3e"}, + {file = "pydantic_core-2.18.4-cp310-none-win32.whl", hash = "sha256:1b4de2e51bbcb61fdebd0ab86ef28062704f62c82bbf4addc4e37fa4b00b7cbc"}, + {file = "pydantic_core-2.18.4-cp310-none-win_amd64.whl", hash = "sha256:6a750aec7bf431517a9fd78cb93c97b9b0c496090fee84a47a0d23668976b4b0"}, + {file = "pydantic_core-2.18.4-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:942ba11e7dfb66dc70f9ae66b33452f51ac7bb90676da39a7345e99ffb55402d"}, + {file = "pydantic_core-2.18.4-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:b2ebef0e0b4454320274f5e83a41844c63438fdc874ea40a8b5b4ecb7693f1c4"}, + {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a642295cd0c8df1b86fc3dced1d067874c353a188dc8e0f744626d49e9aa51c4"}, + {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5f09baa656c904807e832cf9cce799c6460c450c4ad80803517032da0cd062e2"}, + {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:98906207f29bc2c459ff64fa007afd10a8c8ac080f7e4d5beff4c97086a3dabd"}, + {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:19894b95aacfa98e7cb093cd7881a0c76f55731efad31073db4521e2b6ff5b7d"}, + {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0fbbdc827fe5e42e4d196c746b890b3d72876bdbf160b0eafe9f0334525119c8"}, + {file = "pydantic_core-2.18.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:f85d05aa0918283cf29a30b547b4df2fbb56b45b135f9e35b6807cb28bc47951"}, + {file = "pydantic_core-2.18.4-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:e85637bc8fe81ddb73fda9e56bab24560bdddfa98aa64f87aaa4e4b6730c23d2"}, + {file = "pydantic_core-2.18.4-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:2f5966897e5461f818e136b8451d0551a2e77259eb0f73a837027b47dc95dab9"}, + {file = "pydantic_core-2.18.4-cp311-none-win32.whl", hash = "sha256:44c7486a4228413c317952e9d89598bcdfb06399735e49e0f8df643e1ccd0558"}, + {file = "pydantic_core-2.18.4-cp311-none-win_amd64.whl", hash = "sha256:8a7164fe2005d03c64fd3b85649891cd4953a8de53107940bf272500ba8a788b"}, + {file = "pydantic_core-2.18.4-cp311-none-win_arm64.whl", hash = "sha256:4e99bc050fe65c450344421017f98298a97cefc18c53bb2f7b3531eb39bc7805"}, + {file = "pydantic_core-2.18.4-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:6f5c4d41b2771c730ea1c34e458e781b18cc668d194958e0112455fff4e402b2"}, + {file = "pydantic_core-2.18.4-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2fdf2156aa3d017fddf8aea5adfba9f777db1d6022d392b682d2a8329e087cef"}, + {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4748321b5078216070b151d5271ef3e7cc905ab170bbfd27d5c83ee3ec436695"}, + {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:847a35c4d58721c5dc3dba599878ebbdfd96784f3fb8bb2c356e123bdcd73f34"}, + {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3c40d4eaad41f78e3bbda31b89edc46a3f3dc6e171bf0ecf097ff7a0ffff7cb1"}, + {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:21a5e440dbe315ab9825fcd459b8814bb92b27c974cbc23c3e8baa2b76890077"}, + {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:01dd777215e2aa86dfd664daed5957704b769e726626393438f9c87690ce78c3"}, + {file = "pydantic_core-2.18.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:4b06beb3b3f1479d32befd1f3079cc47b34fa2da62457cdf6c963393340b56e9"}, + {file = "pydantic_core-2.18.4-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:564d7922e4b13a16b98772441879fcdcbe82ff50daa622d681dd682175ea918c"}, + {file = "pydantic_core-2.18.4-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:0eb2a4f660fcd8e2b1c90ad566db2b98d7f3f4717c64fe0a83e0adb39766d5b8"}, + {file = "pydantic_core-2.18.4-cp312-none-win32.whl", hash = "sha256:8b8bab4c97248095ae0c4455b5a1cd1cdd96e4e4769306ab19dda135ea4cdb07"}, + {file = "pydantic_core-2.18.4-cp312-none-win_amd64.whl", hash = "sha256:14601cdb733d741b8958224030e2bfe21a4a881fb3dd6fbb21f071cabd48fa0a"}, + {file = "pydantic_core-2.18.4-cp312-none-win_arm64.whl", hash = "sha256:c1322d7dd74713dcc157a2b7898a564ab091ca6c58302d5c7b4c07296e3fd00f"}, + {file = "pydantic_core-2.18.4-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:44a688331d4a4e2129140a8118479443bd6f1905231138971372fcde37e43528"}, + {file = "pydantic_core-2.18.4-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:a2fdd81edd64342c85ac7cf2753ccae0b79bf2dfa063785503cb85a7d3593223"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:86110d7e1907ab36691f80b33eb2da87d780f4739ae773e5fc83fb272f88825f"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:46387e38bd641b3ee5ce247563b60c5ca098da9c56c75c157a05eaa0933ed154"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:123c3cec203e3f5ac7b000bd82235f1a3eced8665b63d18be751f115588fea30"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:dc1803ac5c32ec324c5261c7209e8f8ce88e83254c4e1aebdc8b0a39f9ddb443"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:53db086f9f6ab2b4061958d9c276d1dbe3690e8dd727d6abf2321d6cce37fa94"}, + {file = "pydantic_core-2.18.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:abc267fa9837245cc28ea6929f19fa335f3dc330a35d2e45509b6566dc18be23"}, + {file = "pydantic_core-2.18.4-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:a0d829524aaefdebccb869eed855e2d04c21d2d7479b6cada7ace5448416597b"}, + {file = "pydantic_core-2.18.4-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:509daade3b8649f80d4e5ff21aa5673e4ebe58590b25fe42fac5f0f52c6f034a"}, + {file = "pydantic_core-2.18.4-cp39-none-win32.whl", hash = "sha256:ca26a1e73c48cfc54c4a76ff78df3727b9d9f4ccc8dbee4ae3f73306a591676d"}, + {file = "pydantic_core-2.18.4-cp39-none-win_amd64.whl", hash = "sha256:c67598100338d5d985db1b3d21f3619ef392e185e71b8d52bceacc4a7771ea7e"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:574d92eac874f7f4db0ca653514d823a0d22e2354359d0759e3f6a406db5d55d"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:1f4d26ceb5eb9eed4af91bebeae4b06c3fb28966ca3a8fb765208cf6b51102ab"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:77450e6d20016ec41f43ca4a6c63e9fdde03f0ae3fe90e7c27bdbeaece8b1ed4"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d323a01da91851a4f17bf592faf46149c9169d68430b3146dcba2bb5e5719abc"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:43d447dd2ae072a0065389092a231283f62d960030ecd27565672bd40746c507"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:578e24f761f3b425834f297b9935e1ce2e30f51400964ce4801002435a1b41ef"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:81b5efb2f126454586d0f40c4d834010979cb80785173d1586df845a632e4e6d"}, + {file = "pydantic_core-2.18.4-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:ab86ce7c8f9bea87b9d12c7f0af71102acbf5ecbc66c17796cff45dae54ef9a5"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:90afc12421df2b1b4dcc975f814e21bc1754640d502a2fbcc6d41e77af5ec312"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:51991a89639a912c17bef4b45c87bd83593aee0437d8102556af4885811d59f5"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:293afe532740370aba8c060882f7d26cfd00c94cae32fd2e212a3a6e3b7bc15e"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b48ece5bde2e768197a2d0f6e925f9d7e3e826f0ad2271120f8144a9db18d5c8"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:eae237477a873ab46e8dd748e515c72c0c804fb380fbe6c85533c7de51f23a8f"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl", hash = "sha256:834b5230b5dfc0c1ec37b2fda433b271cbbc0e507560b5d1588e2cc1148cf1ce"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl", hash = "sha256:e858ac0a25074ba4bce653f9b5d0a85b7456eaddadc0ce82d3878c22489fa4ee"}, + {file = "pydantic_core-2.18.4-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:2fd41f6eff4c20778d717af1cc50eca52f5afe7805ee530a4fbd0bae284f16e9"}, + {file = "pydantic_core-2.18.4.tar.gz", hash = "sha256:ec3beeada09ff865c344ff3bc2f427f5e6c26401cc6113d77e372c3fdac73864"}, +] + [[package]] name = "pygments" version = "2.17.2" diff --git a/pyproject.toml b/pyproject.toml index f053b75..df3b0c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,6 +9,7 @@ description = "Core of HydroRoll SDK." authors = [{ name = "简律纯", email = "leader@hydroroll.team" }] dependencies = [ "pdfquery>=0.4.3", + "pydantic>=2.7.4", ] requires-python = ">=3.9" readme = "README.rst" diff --git a/tests/test_BaseRule.py b/tests/test_BaseRule.py index da5ac93..3d70a80 100644 --- a/tests/test_BaseRule.py +++ b/tests/test_BaseRule.py @@ -24,8 +24,6 @@ __rule_book__ = "BASIC ROLEPLAYING" # 不同的大类(举例) # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -# - # 规则包剖析 @@ -42,46 +40,11 @@ __rule_book__ = "BASIC ROLEPLAYING" # 战役 # 模组 -# 判定规则 -# - 属性|判定 规则 -# - 技能判定规则 -# - 自定义类判定规则 - -# 人物卡 -# - 属性列表* -# - 技能列表* +# 人物卡 - CharacterCard +# - 属性: 列表、判定 +# - 技能: 列表、判定 # - 人物塑造 # - 姓名、年龄、种族、阵营 - +# - 自定义判定列表 # ============================================== - -# MyRule -import hrc -from hrc.rules import BaseRule, Rules -from hrc.rules.BaseRule import CharacterCard, JudgeRule - - -class JudgeAttr(JudgeRule.Attribute): - """属性判定规则""" - - -class JudgeCustom(JudgeRule.Custom): - """自定义判定规则""" - - -class ChaAttr(CharacterCard.Attribute): - """人物卡属性列表""" - - -class ChaSkill(CharacterCard.Skill): - """人物卡技能列表""" - - -class ThePool(Rules[JudgeAttr, JudgeCustom]): - """规则包[池]""" - - __config__ = 'ThePool' - - - \ No newline at end of file -- cgit v1.2.3-70-g09d2