From a2477b28057251c4685dbf0b56359dee7b595bfa Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Fri, 21 Jun 2024 04:47:16 +0800 Subject: refactor(filetree): rename package's namespace as `hrc` --- hrc/LibCore.py | Bin 0 -> 437248 bytes hrc/LibCore.pyi | 5 ++ hrc/__init__.py | 2 + hrc/cli.py | 46 +++++++++++++++++++ hrc/config.py | 0 hrc/const.py | 0 hrc/core.py | 1 + hrc/dependencies.py | 0 hrc/development/__init__.py | 3 ++ hrc/development/character.py | 2 + hrc/document/__init__.py | 0 hrc/exceptions.py | 0 hrc/feature/__init__.py | 0 hrc/log.py | 0 hrc/performance/__init__.py | 0 hrc/py.typed | 0 hrc/rule_package.py | 0 hrc/rules/BaseRule/JudgeRule.py | 13 ++++++ hrc/rules/BaseRule/__init__.py | 46 +++++++++++++++++++ hrc/rules/__init__.py | 1 + hrc/typing.py | 0 hrc/utils.py | 0 hydro_roll_core/__init__.py | 1 - hydro_roll_core/cli.py | 46 ------------------- hydro_roll_core/config.py | 0 hydro_roll_core/const.py | 0 hydro_roll_core/core.py | 1 - hydro_roll_core/dependencies.py | 0 hydro_roll_core/development/__init__.py | 3 -- hydro_roll_core/development/character.py | 2 - hydro_roll_core/document/__init__.py | 0 hydro_roll_core/exceptions.py | 0 hydro_roll_core/feature/__init__.py | 0 hydro_roll_core/libcore.pyi | 5 -- hydro_roll_core/log.py | 0 hydro_roll_core/performance/__init__.py | 0 hydro_roll_core/py.typed | 0 hydro_roll_core/rule_package.py | 0 hydro_roll_core/rules/BaseRule/JudgeRule.py | 18 -------- hydro_roll_core/rules/BaseRule/__init__.py | 46 ------------------- hydro_roll_core/rules/__init__.py | 0 hydro_roll_core/typing.py | 0 hydro_roll_core/utils.py | 0 pyproject.toml | 6 +-- src/lib.rs | 2 +- tests/test_BaseRule.py | 69 ++++++++++++++++++++++++++++ tests/test_corelib.py | 7 +-- 47 files changed, 194 insertions(+), 131 deletions(-) create mode 100644 hrc/LibCore.py create mode 100644 hrc/LibCore.pyi create mode 100644 hrc/__init__.py create mode 100644 hrc/cli.py create mode 100644 hrc/config.py create mode 100644 hrc/const.py create mode 100644 hrc/core.py create mode 100644 hrc/dependencies.py create mode 100644 hrc/development/__init__.py create mode 100644 hrc/development/character.py create mode 100644 hrc/document/__init__.py create mode 100644 hrc/exceptions.py create mode 100644 hrc/feature/__init__.py create mode 100644 hrc/log.py create mode 100644 hrc/performance/__init__.py create mode 100644 hrc/py.typed create mode 100644 hrc/rule_package.py create mode 100644 hrc/rules/BaseRule/JudgeRule.py create mode 100644 hrc/rules/BaseRule/__init__.py create mode 100644 hrc/rules/__init__.py create mode 100644 hrc/typing.py create mode 100644 hrc/utils.py delete mode 100644 hydro_roll_core/__init__.py delete mode 100644 hydro_roll_core/cli.py delete mode 100644 hydro_roll_core/config.py delete mode 100644 hydro_roll_core/const.py delete mode 100644 hydro_roll_core/core.py delete mode 100644 hydro_roll_core/dependencies.py delete mode 100644 hydro_roll_core/development/__init__.py delete mode 100644 hydro_roll_core/development/character.py delete mode 100644 hydro_roll_core/document/__init__.py delete mode 100644 hydro_roll_core/exceptions.py delete mode 100644 hydro_roll_core/feature/__init__.py delete mode 100644 hydro_roll_core/libcore.pyi delete mode 100644 hydro_roll_core/log.py delete mode 100644 hydro_roll_core/performance/__init__.py delete mode 100644 hydro_roll_core/py.typed delete mode 100644 hydro_roll_core/rule_package.py delete mode 100644 hydro_roll_core/rules/BaseRule/JudgeRule.py delete mode 100644 hydro_roll_core/rules/BaseRule/__init__.py delete mode 100644 hydro_roll_core/rules/__init__.py delete mode 100644 hydro_roll_core/typing.py delete mode 100644 hydro_roll_core/utils.py create mode 100644 tests/test_BaseRule.py diff --git a/hrc/LibCore.py b/hrc/LibCore.py new file mode 100644 index 0000000..d85d03a Binary files /dev/null and b/hrc/LibCore.py differ diff --git a/hrc/LibCore.pyi b/hrc/LibCore.pyi new file mode 100644 index 0000000..aa88747 --- /dev/null +++ b/hrc/LibCore.pyi @@ -0,0 +1,5 @@ +class LibCore(object): + """Core library for hydro roll""" + + def __init__(self, name: str = ""): ... + def process_rule_pack(self, rule_pack: str) -> str: ... diff --git a/hrc/__init__.py b/hrc/__init__.py new file mode 100644 index 0000000..6c6b22c --- /dev/null +++ b/hrc/__init__.py @@ -0,0 +1,2 @@ +from .LibCore import * +from . import rules diff --git a/hrc/cli.py b/hrc/cli.py new file mode 100644 index 0000000..55758bc --- /dev/null +++ b/hrc/cli.py @@ -0,0 +1,46 @@ +import argparse + + +class Cli(object): + parser = argparse.ArgumentParser(description="水系核心终端") + + def __init__(self): + self.parser.add_argument( + "-i", + "--install", + dest="command", + help="安装规则包", + action="store_const", + const="install_package", + ) + self.parser.add_argument( + "-T", + "--template", + dest="command", + help="选择模板快速创建规则包实例", + action="store_const", + const="build_template", + ) + self.parser.add_argument( + "-S", + "--search", + dest="command", + help="在指定镜像源查找规则包", + action="store_const", + const="search_package", + ) + self.parser.add_argument( + "-c", + "--config", + dest="command", + help="配置管理", + action="store_const", + const="config", + ) + self.args = self.parser.parse_args() + + def get_args(self): + return self.args + + def get_help(self): + return self.parser.format_help() diff --git a/hrc/config.py b/hrc/config.py new file mode 100644 index 0000000..e69de29 diff --git a/hrc/const.py b/hrc/const.py new file mode 100644 index 0000000..e69de29 diff --git a/hrc/core.py b/hrc/core.py new file mode 100644 index 0000000..020ccb9 --- /dev/null +++ b/hrc/core.py @@ -0,0 +1 @@ +class Core: ... diff --git a/hrc/dependencies.py b/hrc/dependencies.py new file mode 100644 index 0000000..e69de29 diff --git a/hrc/development/__init__.py b/hrc/development/__init__.py new file mode 100644 index 0000000..b3e76b3 --- /dev/null +++ b/hrc/development/__init__.py @@ -0,0 +1,3 @@ +from .character import Character + +__all__ = ["Character"] diff --git a/hrc/development/character.py b/hrc/development/character.py new file mode 100644 index 0000000..c883e45 --- /dev/null +++ b/hrc/development/character.py @@ -0,0 +1,2 @@ +class Character: + class Attribute: ... diff --git a/hrc/document/__init__.py b/hrc/document/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/hrc/exceptions.py b/hrc/exceptions.py new file mode 100644 index 0000000..e69de29 diff --git a/hrc/feature/__init__.py b/hrc/feature/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/hrc/log.py b/hrc/log.py new file mode 100644 index 0000000..e69de29 diff --git a/hrc/performance/__init__.py b/hrc/performance/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/hrc/py.typed b/hrc/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/hrc/rule_package.py b/hrc/rule_package.py new file mode 100644 index 0000000..e69de29 diff --git a/hrc/rules/BaseRule/JudgeRule.py b/hrc/rules/BaseRule/JudgeRule.py new file mode 100644 index 0000000..20d28a2 --- /dev/null +++ b/hrc/rules/BaseRule/JudgeRule.py @@ -0,0 +1,13 @@ +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/__init__.py b/hrc/rules/BaseRule/__init__.py new file mode 100644 index 0000000..4d3bc9d --- /dev/null +++ b/hrc/rules/BaseRule/__init__.py @@ -0,0 +1,46 @@ +import dataclasses +from dataclasses import dataclass +from typing import Literal, Optional, Union + +from . import JudgeRule + +@dataclass +class CharacterCard(object): + """Docstring for CharacterCard.""" + property: type + + class Information(object): + age: Optional[Union[int, str]] + race: Optional[str] + gender: Optional[str] + group: Optional[str] + + +@dataclass +class CustomRule(object): + """Docstring for CustomRule.""" + property: type + + +@dataclass +class ExpansionRule(object): + """Docstring for ExpansionRule.""" + property: type + + +@dataclass +class Wiki(object): + """Docstring for Wiki.""" + property: type + + +@dataclass +class Query(object): + """Docstring for Query.""" + property: type + + +@dataclass +class Duration(object): + """Docstring for Duration.""" + property: type diff --git a/hrc/rules/__init__.py b/hrc/rules/__init__.py new file mode 100644 index 0000000..be96d47 --- /dev/null +++ b/hrc/rules/__init__.py @@ -0,0 +1 @@ +from . import BaseRule \ No newline at end of file diff --git a/hrc/typing.py b/hrc/typing.py new file mode 100644 index 0000000..e69de29 diff --git a/hrc/utils.py b/hrc/utils.py new file mode 100644 index 0000000..e69de29 diff --git a/hydro_roll_core/__init__.py b/hydro_roll_core/__init__.py deleted file mode 100644 index 1bd4ab1..0000000 --- a/hydro_roll_core/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .libcore import * diff --git a/hydro_roll_core/cli.py b/hydro_roll_core/cli.py deleted file mode 100644 index 55758bc..0000000 --- a/hydro_roll_core/cli.py +++ /dev/null @@ -1,46 +0,0 @@ -import argparse - - -class Cli(object): - parser = argparse.ArgumentParser(description="水系核心终端") - - def __init__(self): - self.parser.add_argument( - "-i", - "--install", - dest="command", - help="安装规则包", - action="store_const", - const="install_package", - ) - self.parser.add_argument( - "-T", - "--template", - dest="command", - help="选择模板快速创建规则包实例", - action="store_const", - const="build_template", - ) - self.parser.add_argument( - "-S", - "--search", - dest="command", - help="在指定镜像源查找规则包", - action="store_const", - const="search_package", - ) - self.parser.add_argument( - "-c", - "--config", - dest="command", - help="配置管理", - action="store_const", - const="config", - ) - self.args = self.parser.parse_args() - - def get_args(self): - return self.args - - def get_help(self): - return self.parser.format_help() diff --git a/hydro_roll_core/config.py b/hydro_roll_core/config.py deleted file mode 100644 index e69de29..0000000 diff --git a/hydro_roll_core/const.py b/hydro_roll_core/const.py deleted file mode 100644 index e69de29..0000000 diff --git a/hydro_roll_core/core.py b/hydro_roll_core/core.py deleted file mode 100644 index 020ccb9..0000000 --- a/hydro_roll_core/core.py +++ /dev/null @@ -1 +0,0 @@ -class Core: ... diff --git a/hydro_roll_core/dependencies.py b/hydro_roll_core/dependencies.py deleted file mode 100644 index e69de29..0000000 diff --git a/hydro_roll_core/development/__init__.py b/hydro_roll_core/development/__init__.py deleted file mode 100644 index b3e76b3..0000000 --- a/hydro_roll_core/development/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .character import Character - -__all__ = ["Character"] diff --git a/hydro_roll_core/development/character.py b/hydro_roll_core/development/character.py deleted file mode 100644 index c883e45..0000000 --- a/hydro_roll_core/development/character.py +++ /dev/null @@ -1,2 +0,0 @@ -class Character: - class Attribute: ... diff --git a/hydro_roll_core/document/__init__.py b/hydro_roll_core/document/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/hydro_roll_core/exceptions.py b/hydro_roll_core/exceptions.py deleted file mode 100644 index e69de29..0000000 diff --git a/hydro_roll_core/feature/__init__.py b/hydro_roll_core/feature/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/hydro_roll_core/libcore.pyi b/hydro_roll_core/libcore.pyi deleted file mode 100644 index 09cfc3d..0000000 --- a/hydro_roll_core/libcore.pyi +++ /dev/null @@ -1,5 +0,0 @@ -class libcore(object): - """Core library for hydro roll""" - - def __init__(self, name: str = ""): ... - def process_rule_pack(self, rule_pack: str) -> str: ... diff --git a/hydro_roll_core/log.py b/hydro_roll_core/log.py deleted file mode 100644 index e69de29..0000000 diff --git a/hydro_roll_core/performance/__init__.py b/hydro_roll_core/performance/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/hydro_roll_core/py.typed b/hydro_roll_core/py.typed deleted file mode 100644 index e69de29..0000000 diff --git a/hydro_roll_core/rule_package.py b/hydro_roll_core/rule_package.py deleted file mode 100644 index e69de29..0000000 diff --git a/hydro_roll_core/rules/BaseRule/JudgeRule.py b/hydro_roll_core/rules/BaseRule/JudgeRule.py deleted file mode 100644 index 20e1989..0000000 --- a/hydro_roll_core/rules/BaseRule/JudgeRule.py +++ /dev/null @@ -1,18 +0,0 @@ -import dataclasses -from dataclasses import dataclass -from typing import Literal, Optional, Union -from typing_extensions import override - -@dataclass -class JudgeRule(object): - """判定规则""" - property: type - -class Custom(JudgeRule): - ... - -class Attribute(Custom): - ... - -class Skill(Custom): - ... diff --git a/hydro_roll_core/rules/BaseRule/__init__.py b/hydro_roll_core/rules/BaseRule/__init__.py deleted file mode 100644 index 5730aa8..0000000 --- a/hydro_roll_core/rules/BaseRule/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -import dataclasses -from dataclasses import dataclass -from typing import Literal, Optional, Union -from typing_extensions import override - - -@dataclass -class CharacterCard(object): - """Docstring for CharacterCard.""" - property: type - - class Information(object): - age: Optional[Union[int, str]] - race: Optional[str] - gender: Optional[str] - group: Optional[str] - - -@dataclass -class CustomRule(object): - """Docstring for CustomRule.""" - property: type - - -@dataclass -class ExpansionRule(object): - """Docstring for ExpansionRule.""" - property: type - - -@dataclass -class Wiki(object): - """Docstring for Wiki.""" - property: type - - -@dataclass -class Query(object): - """Docstring for Query.""" - property: type - - -@dataclass -class Duration(object): - """Docstring for Duration.""" - property: type diff --git a/hydro_roll_core/rules/__init__.py b/hydro_roll_core/rules/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/hydro_roll_core/typing.py b/hydro_roll_core/typing.py deleted file mode 100644 index e69de29..0000000 diff --git a/hydro_roll_core/utils.py b/hydro_roll_core/utils.py deleted file mode 100644 index e69de29..0000000 diff --git a/pyproject.toml b/pyproject.toml index 1bc6d03..f053b75 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,8 +20,8 @@ repository = "https://github.com/HydroRoll-Team/HydroRollCore" documentation = "https://core.hydroroll.team/" [project.scripts] -hrc = "hydro_roll_core.cli:Cli" -hydrorollcore = "hydro_roll_core.cli:Cli" +hrc = "hrc.cli:Cli" +hydrorollcore = "hrc.cli:Cli" [tool.ruff] # Exclude a variety of commonly ignored directories. @@ -87,7 +87,7 @@ skip-magic-trailing-comma = false line-ending = "auto" [tool.maturin] -module-name = "hydro_roll_core.libcore" +module-name = "hrc.LibCore" [tool.pdm.dev-dependencies] docs = [ diff --git a/src/lib.rs b/src/lib.rs index 9d2c8e9..1c11a3d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -9,7 +9,7 @@ fn process_rule_pack(rule_pack: &str) -> PyResult { /// A Python module implemented in Rust. #[pymodule] -#[pyo3(name = "libcore")] +#[pyo3(name = "LibCore")] fn libcore(_py: Python, m: &PyModule) -> PyResult<()> { m.add_function(wrap_pyfunction!(process_rule_pack, m)?)?; Ok(()) diff --git a/tests/test_BaseRule.py b/tests/test_BaseRule.py new file mode 100644 index 0000000..f450c28 --- /dev/null +++ b/tests/test_BaseRule.py @@ -0,0 +1,69 @@ +__rule_book__ = "BASIC ROLEPLAYING" + +# General Rule Pack Standard(GRPSv1) + +# 规则书剖析 + +# 共有的大类 +# ============================ +# judge role - 判定规则 +# - 事件判定规则 +# character card - 人物卡(属性) +# playing time* - * + + +# 可选的大类 +# ---------------------------- +# settings - 背景设定 +# custom rule - 自定义规则 +# - 特殊胜利手段(意外死亡、看月亮看死的等) +# expansion rule - 拓展规则 +# - coc 中的伤害价值、调整 +# - 装备中的盾牌 +# - 药水、符文等各种各样时尚小垃圾 + +# 不同的大类(举例) +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +# + + +# 规则包剖析 + +# 根据细类区分 + +# 词条 - Wiki +# 查询条目 - Query +# 规定算法 - Algorithm + +# 游戏时长 - Duration +# 战斗轮、追逐轮、行动轮 +# 回合 +# 幕间 +# 战役 +# 模组 + +# 判定规则 +# - 属性|判定 规则 +# - 技能判定规则 +# - 自定义类判定规则 + +# 人物卡 +# - 属性列表* +# - 技能列表* +# - 人物塑造 +# - 姓名、年龄、种族、阵营 + + +# ============================================== + +# MyRule +from hrc.rules.BaseRule import JudgeRule + +class JudgeAttr(JudgeRule.Attribute): + """来自判定规则 - 属性判定 + + 属性判定规则(模式)""" + + +class JudgeCustom(JudgeRule.Custom): + ... diff --git a/tests/test_corelib.py b/tests/test_corelib.py index 38c2ef9..64b11ce 100644 --- a/tests/test_corelib.py +++ b/tests/test_corelib.py @@ -1,15 +1,12 @@ -from hydro_roll_core import libcore +from hrc import LibCore -cb = libcore +cb = LibCore def main(): rule_pack = "example_rule_pack" result = cb.process_rule_pack(rule_pack) print(result) - print(cb.name) - cb.name = "a" - print(cb.name) if __name__ == "__main__": -- cgit v1.2.3-70-g09d2