nonebot-plugin-werewolf 1.0.7__tar.gz → 1.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. nonebot_plugin_werewolf-1.0.7/README.md → nonebot_plugin_werewolf-1.1.1/PKG-INFO +45 -6
  2. nonebot_plugin_werewolf-1.0.7/PKG-INFO → nonebot_plugin_werewolf-1.1.1/README.md +31 -19
  3. {nonebot_plugin_werewolf-1.0.7 → nonebot_plugin_werewolf-1.1.1}/nonebot_plugin_werewolf/__init__.py +1 -1
  4. nonebot_plugin_werewolf-1.1.1/nonebot_plugin_werewolf/config.py +85 -0
  5. nonebot_plugin_werewolf-1.1.1/nonebot_plugin_werewolf/constant.py +97 -0
  6. nonebot_plugin_werewolf-1.1.1/nonebot_plugin_werewolf/exception.py +19 -0
  7. {nonebot_plugin_werewolf-1.0.7 → nonebot_plugin_werewolf-1.1.1}/nonebot_plugin_werewolf/game.py +113 -86
  8. {nonebot_plugin_werewolf-1.0.7 → nonebot_plugin_werewolf-1.1.1}/nonebot_plugin_werewolf/matchers.py +3 -8
  9. {nonebot_plugin_werewolf-1.0.7 → nonebot_plugin_werewolf-1.1.1}/nonebot_plugin_werewolf/ob11_ext.py +1 -1
  10. {nonebot_plugin_werewolf-1.0.7 → nonebot_plugin_werewolf-1.1.1}/nonebot_plugin_werewolf/player.py +76 -58
  11. {nonebot_plugin_werewolf-1.0.7 → nonebot_plugin_werewolf-1.1.1}/nonebot_plugin_werewolf/player_set.py +9 -3
  12. {nonebot_plugin_werewolf-1.0.7 → nonebot_plugin_werewolf-1.1.1}/nonebot_plugin_werewolf/utils.py +20 -16
  13. nonebot_plugin_werewolf-1.1.1/nonebot_plugin_werewolf.egg-info/PKG-INFO +285 -0
  14. nonebot_plugin_werewolf-1.1.1/nonebot_plugin_werewolf.egg-info/SOURCES.txt +18 -0
  15. nonebot_plugin_werewolf-1.1.1/nonebot_plugin_werewolf.egg-info/dependency_links.txt +1 -0
  16. nonebot_plugin_werewolf-1.1.1/nonebot_plugin_werewolf.egg-info/requires.txt +4 -0
  17. nonebot_plugin_werewolf-1.1.1/nonebot_plugin_werewolf.egg-info/top_level.txt +1 -0
  18. nonebot_plugin_werewolf-1.1.1/pyproject.toml +105 -0
  19. nonebot_plugin_werewolf-1.1.1/setup.cfg +4 -0
  20. nonebot_plugin_werewolf-1.0.7/nonebot_plugin_werewolf/config.py +0 -18
  21. nonebot_plugin_werewolf-1.0.7/nonebot_plugin_werewolf/constant.py +0 -124
  22. nonebot_plugin_werewolf-1.0.7/pyproject.toml +0 -111
  23. {nonebot_plugin_werewolf-1.0.7 → nonebot_plugin_werewolf-1.1.1}/LICENSE +0 -0
@@ -1,3 +1,17 @@
1
+ Metadata-Version: 2.1
2
+ Name: nonebot-plugin-werewolf
3
+ Version: 1.1.1
4
+ Summary: 适用于 Nonebot2 的狼人杀插件
5
+ Author-email: wyf7685 <wyf7685@163.com>
6
+ License: MIT
7
+ Requires-Python: >=3.11
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: nonebot2>=2.3.3
11
+ Requires-Dist: nonebot-plugin-alconna>=0.52.1
12
+ Requires-Dist: nonebot-plugin-userinfo>=0.2.6
13
+ Requires-Dist: nonebot-plugin-waiter>=0.7.1
14
+
1
15
  <div align="center">
2
16
  <a href="https://v2.nonebot.dev/store">
3
17
  <img src="https://github.com/wyf7685/wyf7685/blob/main/assets/NoneBotPlugin.svg" width="300" alt="logo">
@@ -12,13 +26,21 @@ _✨ 简单的狼人杀插件 ✨_
12
26
 
13
27
  [![license](https://img.shields.io/github/license/wyf7685/nonebot-plugin-werewolf.svg)](./LICENSE)
14
28
  [![pypi](https://img.shields.io/pypi/v/nonebot-plugin-werewolf?logo=python&logoColor=edb641)](https://pypi.python.org/pypi/nonebot-plugin-werewolf)
15
- [![python](https://img.shields.io/badge/python-3.10+-blue?logo=python&logoColor=edb641)](https://www.python.org/)
16
-
17
- [![pdm-managed](https://img.shields.io/endpoint?url=https%3A%2F%2Fcdn.jsdelivr.net%2Fgh%2Fpdm-project%2F.github%2Fbadge.json)](https://pdm-project.org)
29
+ [![python](https://img.shields.io/badge/python-3.11+-blue?logo=python&logoColor=edb641)](https://www.python.org/)
30
+ [![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
31
+ [![ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
18
32
  [![isort](https://img.shields.io/badge/%20imports-isort-%231674b1)](https://pycqa.github.io/isort/)
19
33
  [![black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
20
34
  [![pyright](https://img.shields.io/badge/types-pyright-797952.svg?logo=python&logoColor=edb641)](https://github.com/Microsoft/pyright)
21
- [![ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
35
+
36
+ [![commits](https://img.shields.io/github/commit-activity/w/wyf7685/nonebot-plugin-werewolf)](https://github.com/wyf7685/nonebot-plugin-werewolf/commits)
37
+ [![wakatime](https://wakatime.com/badge/user/b097681b-c224-44ec-8e04-e1cf71744655/project/70a7f68d-5625-4989-9476-be6877408332.svg)](https://wakatime.com/badge/user/b097681b-c224-44ec-8e04-e1cf71744655/project/70a7f68d-5625-4989-9476-be6877408332)
38
+ [![pre-commit](https://results.pre-commit.ci/badge/github/wyf7685/nonebot-plugin-werewolf/master.svg)](https://results.pre-commit.ci/latest/github/wyf7685/nonebot-plugin-werewolf/master)
39
+ [![pyright](https://github.com/wyf7685/nonebot-plugin-werewolf/actions/workflows/pyright.yml/badge.svg?branch=master&event=push)](https://github.com/wyf7685/nonebot-plugin-werewolf/actions/workflows/pyright.yml)
40
+ [![publish](https://github.com/wyf7685/nonebot-plugin-werewolf/actions/workflows/pypi-publish.yml/badge.svg)](https://github.com/wyf7685/nonebot-plugin-werewolf/actions/workflows/pypi-publish.yml)
41
+
42
+ [![NoneBot Registry](https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin%2Fnonebot-plugin-werewolf)](https://registry.nonebot.dev/plugin/nonebot-plugin-werewolf:nonebot_plugin_werewolf)
43
+ [![Supported Adapters](https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin-adapters%2Fnonebot-plugin-werewolf)](https://registry.nonebot.dev/plugin/nonebot-plugin-werewolf:nonebot_plugin_werewolf)
22
44
 
23
45
  </div>
24
46
 
@@ -28,6 +50,10 @@ _✨ 简单的狼人杀插件 ✨_
28
50
 
29
51
  ## 💿 安装
30
52
 
53
+ > [!note]
54
+ >
55
+ > 请确保 NoneBot2 使用的 Python 解释器版本 >=3.11
56
+
31
57
  <details open>
32
58
  <summary>使用 nb-cli 安装</summary>
33
59
  在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
@@ -73,7 +99,7 @@ _✨ 简单的狼人杀插件 ✨_
73
99
 
74
100
  ## ⚙️ 配置
75
101
 
76
- 在 nonebot2 项目的`.env`文件中添加下表中的必填配置
102
+ 在 nonebot2 项目的 `.env` 文件中添加如下配置
77
103
 
78
104
  | 配置项 | 必填 | 默认值 | 说明 |
79
105
  | :-----------------------------: | :--: | :----: | :-----------------------------------------------------------: |
@@ -81,6 +107,7 @@ _✨ 简单的狼人杀插件 ✨_
81
107
  | `werewolf__role_preset` | 否 | - | 覆写插件内置的职业预设 |
82
108
  | `werewolf__werewolf_priority` | 否 | - | 自定义狼人职业优先级 |
83
109
  | `werewolf__priesthood_proirity` | 否 | - | 自定义神职职业优先级 |
110
+ | `werewolf__joker_probability` | 否 | `0.0` | 小丑职业替换平民的概率, 范围`[0,1]` |
84
111
 
85
112
  `werewolf__role_preset`, `werewolf__werewolf_priority`, `werewolf__priesthood_proirity` 的配置格式请参考 [`游戏内容`](#游戏内容) 部分
86
113
 
@@ -179,7 +206,7 @@ werewolf__werewolf_priority=[1, 2, 1, 1]
179
206
 
180
207
  上述配置中,`[1, 2, 1, 1]` 表示狼人的职业优先级为 `狼人`, `狼王`, `狼人`, `狼人`
181
208
 
182
- #### 配置项 `werewolf__werewolf_priority`
209
+ #### 配置项 `werewolf__priesthood_proirity`
183
210
 
184
211
  ```env
185
212
  werewolf__priesthood_proirity=[11, 12, 13, 14, 15]
@@ -213,6 +240,18 @@ werewolf__priesthood_proirity=[11, 12, 13, 14, 15]
213
240
 
214
241
  <!-- CHANGELOG -->
215
242
 
243
+ - 2024.09.11 v1.1.1
244
+
245
+ - 修改 Python 需求为 `>=3.11`
246
+ - 优化交互结果处理 ~~_可以在一局游戏中加入多个女巫了_~~
247
+
248
+ - 2024.09.09 v1.1.0
249
+
250
+ - 新增职业 `小丑`
251
+ - 修复守卫无法保护自己的 bug
252
+ - 添加部分特殊职业的说明
253
+ - 添加游戏过程中的日志输出
254
+
216
255
  - 2024.09.04 v1.0.7
217
256
 
218
257
  - 优先使用群名片作为玩家名
@@ -1,16 +1,3 @@
1
- Metadata-Version: 2.1
2
- Name: nonebot-plugin-werewolf
3
- Version: 1.0.7
4
- Summary: Default template for PDM package
5
- Author-Email: wyf7685 <wyf7685@163.com>
6
- License: MIT
7
- Requires-Python: >=3.10
8
- Requires-Dist: nonebot2>=2.3.3
9
- Requires-Dist: nonebot-plugin-alconna>=0.52.1
10
- Requires-Dist: nonebot-plugin-userinfo>=0.2.6
11
- Requires-Dist: nonebot-plugin-waiter>=0.7.1
12
- Description-Content-Type: text/markdown
13
-
14
1
  <div align="center">
15
2
  <a href="https://v2.nonebot.dev/store">
16
3
  <img src="https://github.com/wyf7685/wyf7685/blob/main/assets/NoneBotPlugin.svg" width="300" alt="logo">
@@ -25,13 +12,21 @@ _✨ 简单的狼人杀插件 ✨_
25
12
 
26
13
  [![license](https://img.shields.io/github/license/wyf7685/nonebot-plugin-werewolf.svg)](./LICENSE)
27
14
  [![pypi](https://img.shields.io/pypi/v/nonebot-plugin-werewolf?logo=python&logoColor=edb641)](https://pypi.python.org/pypi/nonebot-plugin-werewolf)
28
- [![python](https://img.shields.io/badge/python-3.10+-blue?logo=python&logoColor=edb641)](https://www.python.org/)
29
-
30
- [![pdm-managed](https://img.shields.io/endpoint?url=https%3A%2F%2Fcdn.jsdelivr.net%2Fgh%2Fpdm-project%2F.github%2Fbadge.json)](https://pdm-project.org)
15
+ [![python](https://img.shields.io/badge/python-3.11+-blue?logo=python&logoColor=edb641)](https://www.python.org/)
16
+ [![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
17
+ [![ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
31
18
  [![isort](https://img.shields.io/badge/%20imports-isort-%231674b1)](https://pycqa.github.io/isort/)
32
19
  [![black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
33
20
  [![pyright](https://img.shields.io/badge/types-pyright-797952.svg?logo=python&logoColor=edb641)](https://github.com/Microsoft/pyright)
34
- [![ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
21
+
22
+ [![commits](https://img.shields.io/github/commit-activity/w/wyf7685/nonebot-plugin-werewolf)](https://github.com/wyf7685/nonebot-plugin-werewolf/commits)
23
+ [![wakatime](https://wakatime.com/badge/user/b097681b-c224-44ec-8e04-e1cf71744655/project/70a7f68d-5625-4989-9476-be6877408332.svg)](https://wakatime.com/badge/user/b097681b-c224-44ec-8e04-e1cf71744655/project/70a7f68d-5625-4989-9476-be6877408332)
24
+ [![pre-commit](https://results.pre-commit.ci/badge/github/wyf7685/nonebot-plugin-werewolf/master.svg)](https://results.pre-commit.ci/latest/github/wyf7685/nonebot-plugin-werewolf/master)
25
+ [![pyright](https://github.com/wyf7685/nonebot-plugin-werewolf/actions/workflows/pyright.yml/badge.svg?branch=master&event=push)](https://github.com/wyf7685/nonebot-plugin-werewolf/actions/workflows/pyright.yml)
26
+ [![publish](https://github.com/wyf7685/nonebot-plugin-werewolf/actions/workflows/pypi-publish.yml/badge.svg)](https://github.com/wyf7685/nonebot-plugin-werewolf/actions/workflows/pypi-publish.yml)
27
+
28
+ [![NoneBot Registry](https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin%2Fnonebot-plugin-werewolf)](https://registry.nonebot.dev/plugin/nonebot-plugin-werewolf:nonebot_plugin_werewolf)
29
+ [![Supported Adapters](https://img.shields.io/endpoint?url=https%3A%2F%2Fnbbdg.lgc2333.top%2Fplugin-adapters%2Fnonebot-plugin-werewolf)](https://registry.nonebot.dev/plugin/nonebot-plugin-werewolf:nonebot_plugin_werewolf)
35
30
 
36
31
  </div>
37
32
 
@@ -41,6 +36,10 @@ _✨ 简单的狼人杀插件 ✨_
41
36
 
42
37
  ## 💿 安装
43
38
 
39
+ > [!note]
40
+ >
41
+ > 请确保 NoneBot2 使用的 Python 解释器版本 >=3.11
42
+
44
43
  <details open>
45
44
  <summary>使用 nb-cli 安装</summary>
46
45
  在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
@@ -86,7 +85,7 @@ _✨ 简单的狼人杀插件 ✨_
86
85
 
87
86
  ## ⚙️ 配置
88
87
 
89
- 在 nonebot2 项目的`.env`文件中添加下表中的必填配置
88
+ 在 nonebot2 项目的 `.env` 文件中添加如下配置
90
89
 
91
90
  | 配置项 | 必填 | 默认值 | 说明 |
92
91
  | :-----------------------------: | :--: | :----: | :-----------------------------------------------------------: |
@@ -94,6 +93,7 @@ _✨ 简单的狼人杀插件 ✨_
94
93
  | `werewolf__role_preset` | 否 | - | 覆写插件内置的职业预设 |
95
94
  | `werewolf__werewolf_priority` | 否 | - | 自定义狼人职业优先级 |
96
95
  | `werewolf__priesthood_proirity` | 否 | - | 自定义神职职业优先级 |
96
+ | `werewolf__joker_probability` | 否 | `0.0` | 小丑职业替换平民的概率, 范围`[0,1]` |
97
97
 
98
98
  `werewolf__role_preset`, `werewolf__werewolf_priority`, `werewolf__priesthood_proirity` 的配置格式请参考 [`游戏内容`](#游戏内容) 部分
99
99
 
@@ -192,7 +192,7 @@ werewolf__werewolf_priority=[1, 2, 1, 1]
192
192
 
193
193
  上述配置中,`[1, 2, 1, 1]` 表示狼人的职业优先级为 `狼人`, `狼王`, `狼人`, `狼人`
194
194
 
195
- #### 配置项 `werewolf__werewolf_priority`
195
+ #### 配置项 `werewolf__priesthood_proirity`
196
196
 
197
197
  ```env
198
198
  werewolf__priesthood_proirity=[11, 12, 13, 14, 15]
@@ -226,6 +226,18 @@ werewolf__priesthood_proirity=[11, 12, 13, 14, 15]
226
226
 
227
227
  <!-- CHANGELOG -->
228
228
 
229
+ - 2024.09.11 v1.1.1
230
+
231
+ - 修改 Python 需求为 `>=3.11`
232
+ - 优化交互结果处理 ~~_可以在一局游戏中加入多个女巫了_~~
233
+
234
+ - 2024.09.09 v1.1.0
235
+
236
+ - 新增职业 `小丑`
237
+ - 修复守卫无法保护自己的 bug
238
+ - 添加部分特殊职业的说明
239
+ - 添加游戏过程中的日志输出
240
+
229
241
  - 2024.09.04 v1.0.7
230
242
 
231
243
  - 优先使用群名片作为玩家名
@@ -8,7 +8,7 @@ require("nonebot_plugin_waiter")
8
8
  from . import matchers as matchers
9
9
  from .config import Config
10
10
 
11
- __version__ = "1.0.7"
11
+ __version__ = "1.1.1"
12
12
  __plugin_meta__ = PluginMetadata(
13
13
  name="狼人杀",
14
14
  description="适用于 Nonebot2 的狼人杀插件",
@@ -0,0 +1,85 @@
1
+ from typing import Literal, Self, overload
2
+
3
+ from nonebot import get_plugin_config, logger
4
+ from nonebot.compat import PYDANTIC_V2
5
+ from pydantic import BaseModel, Field
6
+
7
+ from .constant import (
8
+ Role,
9
+ default_priesthood_proirity,
10
+ default_role_preset,
11
+ default_werewolf_priority,
12
+ )
13
+
14
+ if PYDANTIC_V2:
15
+ from pydantic import model_validator as model_validator
16
+ else:
17
+ from pydantic import root_validator
18
+
19
+ @overload
20
+ def model_validator(*, mode: Literal["before"]): ... # noqa: ANN201
21
+
22
+ @overload
23
+ def model_validator(*, mode: Literal["after"]): ... # noqa: ANN201
24
+
25
+ def model_validator(*, mode: Literal["before", "after"]):
26
+ return root_validator(
27
+ pre=mode == "before", # pyright: ignore[reportArgumentType]
28
+ allow_reuse=True,
29
+ )
30
+
31
+
32
+ class PluginConfig(BaseModel):
33
+ enable_poke: bool = Field(default=True)
34
+ role_preset: list[tuple[int, int, int, int]] | dict[int, tuple[int, int, int]] = (
35
+ Field(default_factory=default_role_preset.copy)
36
+ )
37
+ werewolf_priority: list[Role] = Field(
38
+ default_factory=default_werewolf_priority.copy
39
+ )
40
+ priesthood_proirity: list[Role] = Field(
41
+ default_factory=default_priesthood_proirity.copy
42
+ )
43
+ joker_probability: float = Field(default=0.0, ge=0.0, le=1.0)
44
+
45
+ @model_validator(mode="after")
46
+ def _validate(self) -> Self:
47
+ if isinstance(self.role_preset, list):
48
+ for preset in self.role_preset:
49
+ if preset[0] != sum(preset[1:]):
50
+ raise RuntimeError(
51
+ "配置项 `role_preset` 错误: "
52
+ f"预设总人数为 {preset[0]}, 实际总人数为 {sum(preset[1:])} "
53
+ f"({', '.join(map(str, preset[1:]))})"
54
+ )
55
+ self.role_preset = default_role_preset | {
56
+ i[0]: i[1:] for i in self.role_preset
57
+ }
58
+ logger.debug(f"覆写配置 role_preset: {self.role_preset}")
59
+
60
+ min_length = max(i[0] for i in self.role_preset.values())
61
+ if len(self.werewolf_priority) < min_length:
62
+ raise RuntimeError(
63
+ f"配置项 `werewolf_priority` 错误: 应至少为 {min_length} 项"
64
+ )
65
+
66
+ min_length = max(i[1] for i in self.role_preset.values())
67
+ if len(self.priesthood_proirity) < min_length:
68
+ raise RuntimeError(
69
+ f"配置项 `priesthood_proirity` 错误: 应至少为 {min_length} 项"
70
+ )
71
+
72
+ return self
73
+
74
+ def get_role_preset(self) -> dict[int, tuple[int, int, int]]:
75
+ if isinstance(self.role_preset, list):
76
+ self.role_preset = {i[0]: i[1:] for i in self.role_preset}
77
+ return self.role_preset
78
+
79
+
80
+ class Config(BaseModel):
81
+ werewolf: PluginConfig = PluginConfig()
82
+
83
+
84
+ config = get_plugin_config(Config).werewolf
85
+ logger.debug(f"加载插件配置: {config}")
@@ -0,0 +1,97 @@
1
+ from __future__ import annotations
2
+
3
+ import dataclasses
4
+ from enum import Enum, auto
5
+ from typing import TYPE_CHECKING
6
+
7
+ if TYPE_CHECKING:
8
+ from .player import Player
9
+
10
+
11
+ class Role(Enum):
12
+ # 狼人
13
+ Werewolf = 1
14
+ WolfKing = 2
15
+
16
+ # 神职
17
+ Prophet = 11
18
+ Witch = 12
19
+ Hunter = 13
20
+ Guard = 14
21
+ Idiot = 15
22
+
23
+ # 其他
24
+ Joker = 51
25
+
26
+ # 平民
27
+ Civilian = 0
28
+
29
+
30
+ class RoleGroup(Enum):
31
+ Werewolf = auto()
32
+ GoodGuy = auto()
33
+ Others = auto()
34
+
35
+
36
+ class KillReason(Enum):
37
+ Werewolf = auto()
38
+ Poison = auto()
39
+ Shoot = auto()
40
+ Vote = auto()
41
+
42
+
43
+ class GameStatus(Enum):
44
+ GoodGuy = auto()
45
+ Werewolf = auto()
46
+ Joker = auto()
47
+
48
+
49
+ @dataclasses.dataclass
50
+ class GameState:
51
+ day: int
52
+ killed: Player | None = None
53
+ shoot: tuple[Player, Player] | tuple[None, None] = (None, None)
54
+ antidote: set[Player] = dataclasses.field(default_factory=set)
55
+ poison: set[tuple[Player, Player]] = dataclasses.field(default_factory=set)
56
+ protected: set[Player] = dataclasses.field(default_factory=set)
57
+
58
+
59
+ role_name_conv: dict[Role | RoleGroup, str] = {
60
+ Role.Werewolf: "狼人",
61
+ Role.WolfKing: "狼王",
62
+ Role.Prophet: "预言家",
63
+ Role.Witch: "女巫",
64
+ Role.Hunter: "猎人",
65
+ Role.Guard: "守卫",
66
+ Role.Idiot: "白痴",
67
+ Role.Joker: "小丑",
68
+ Role.Civilian: "平民",
69
+ RoleGroup.Werewolf: "狼人",
70
+ RoleGroup.GoodGuy: "好人",
71
+ RoleGroup.Others: "其他",
72
+ }
73
+
74
+ default_role_preset: dict[int, tuple[int, int, int]] = {
75
+ # 总人数: (狼, 神, 民)
76
+ 6: (1, 2, 3),
77
+ 7: (2, 2, 3),
78
+ 8: (2, 3, 3),
79
+ 9: (2, 4, 3),
80
+ 10: (3, 4, 3),
81
+ 11: (3, 5, 3),
82
+ 12: (4, 5, 3),
83
+ }
84
+
85
+ default_werewolf_priority: list[Role] = [
86
+ Role.Werewolf,
87
+ Role.Werewolf,
88
+ Role.WolfKing,
89
+ Role.Werewolf,
90
+ ]
91
+ default_priesthood_proirity: list[Role] = [
92
+ Role.Witch,
93
+ Role.Prophet,
94
+ Role.Hunter,
95
+ Role.Guard,
96
+ Role.Idiot,
97
+ ]
@@ -0,0 +1,19 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ if TYPE_CHECKING:
6
+ from .constant import GameStatus
7
+
8
+
9
+ class Error(Exception):
10
+ """插件错误类型基类"""
11
+
12
+
13
+ class GameFinishedError(Error):
14
+ """游戏结束时抛出,无视游戏进程进入结算"""
15
+
16
+ status: GameStatus
17
+
18
+ def __init__(self, status: GameStatus) -> None:
19
+ self.status = status