nonebot-plugin-werewolf 1.0.6__tar.gz → 1.1.0__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.
- {nonebot_plugin_werewolf-1.0.6 → nonebot_plugin_werewolf-1.1.0}/PKG-INFO +80 -17
- {nonebot_plugin_werewolf-1.0.6 → nonebot_plugin_werewolf-1.1.0}/README.md +75 -12
- {nonebot_plugin_werewolf-1.0.6 → nonebot_plugin_werewolf-1.1.0}/nonebot_plugin_werewolf/__init__.py +1 -1
- nonebot_plugin_werewolf-1.1.0/nonebot_plugin_werewolf/config.py +86 -0
- {nonebot_plugin_werewolf-1.0.6 → nonebot_plugin_werewolf-1.1.0}/nonebot_plugin_werewolf/constant.py +35 -26
- nonebot_plugin_werewolf-1.1.0/nonebot_plugin_werewolf/exception.py +19 -0
- {nonebot_plugin_werewolf-1.0.6 → nonebot_plugin_werewolf-1.1.0}/nonebot_plugin_werewolf/game.py +117 -68
- {nonebot_plugin_werewolf-1.0.6 → nonebot_plugin_werewolf-1.1.0}/nonebot_plugin_werewolf/matchers.py +6 -8
- {nonebot_plugin_werewolf-1.0.6 → nonebot_plugin_werewolf-1.1.0}/nonebot_plugin_werewolf/ob11_ext.py +1 -1
- {nonebot_plugin_werewolf-1.0.6 → nonebot_plugin_werewolf-1.1.0}/nonebot_plugin_werewolf/player.py +97 -71
- {nonebot_plugin_werewolf-1.0.6 → nonebot_plugin_werewolf-1.1.0}/nonebot_plugin_werewolf/player_set.py +17 -9
- {nonebot_plugin_werewolf-1.0.6 → nonebot_plugin_werewolf-1.1.0}/nonebot_plugin_werewolf/utils.py +34 -24
- nonebot_plugin_werewolf-1.1.0/nonebot_plugin_werewolf.egg-info/PKG-INFO +271 -0
- nonebot_plugin_werewolf-1.1.0/nonebot_plugin_werewolf.egg-info/SOURCES.txt +18 -0
- nonebot_plugin_werewolf-1.1.0/nonebot_plugin_werewolf.egg-info/dependency_links.txt +1 -0
- nonebot_plugin_werewolf-1.1.0/nonebot_plugin_werewolf.egg-info/requires.txt +4 -0
- nonebot_plugin_werewolf-1.1.0/nonebot_plugin_werewolf.egg-info/top_level.txt +1 -0
- nonebot_plugin_werewolf-1.1.0/pyproject.toml +105 -0
- nonebot_plugin_werewolf-1.1.0/setup.cfg +4 -0
- nonebot_plugin_werewolf-1.0.6/nonebot_plugin_werewolf/config.py +0 -14
- nonebot_plugin_werewolf-1.0.6/pyproject.toml +0 -99
- {nonebot_plugin_werewolf-1.0.6 → nonebot_plugin_werewolf-1.1.0}/LICENSE +0 -0
@@ -1,16 +1,16 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: nonebot-plugin-werewolf
|
3
|
-
Version: 1.0
|
4
|
-
Summary:
|
5
|
-
Author-
|
3
|
+
Version: 1.1.0
|
4
|
+
Summary: 适用于 Nonebot2 的狼人杀插件
|
5
|
+
Author-email: wyf7685 <wyf7685@163.com>
|
6
6
|
License: MIT
|
7
7
|
Requires-Python: >=3.10
|
8
|
+
Description-Content-Type: text/markdown
|
9
|
+
License-File: LICENSE
|
8
10
|
Requires-Dist: nonebot2>=2.3.3
|
9
11
|
Requires-Dist: nonebot-plugin-alconna>=0.52.1
|
10
12
|
Requires-Dist: nonebot-plugin-userinfo>=0.2.6
|
11
13
|
Requires-Dist: nonebot-plugin-waiter>=0.7.1
|
12
|
-
Requires-Dist: StrEnum>=0.4.15
|
13
|
-
Description-Content-Type: text/markdown
|
14
14
|
|
15
15
|
<div align="center">
|
16
16
|
<a href="https://v2.nonebot.dev/store">
|
@@ -28,12 +28,15 @@ _✨ 简单的狼人杀插件 ✨_
|
|
28
28
|
[](https://pypi.python.org/pypi/nonebot-plugin-werewolf)
|
29
29
|
[](https://www.python.org/)
|
30
30
|
|
31
|
-
[](https://github.com/astral-sh/uv)
|
32
32
|
[](https://pycqa.github.io/isort/)
|
33
33
|
[](https://github.com/psf/black)
|
34
34
|
[](https://github.com/Microsoft/pyright)
|
35
35
|
[](https://github.com/astral-sh/ruff)
|
36
36
|
|
37
|
+
[](https://registry.nonebot.dev/plugin/nonebot-plugin-werewolf:nonebot_plugin_werewolf)
|
38
|
+
[](https://registry.nonebot.dev/plugin/nonebot-plugin-werewolf:nonebot_plugin_werewolf)
|
39
|
+
|
37
40
|
</div>
|
38
41
|
|
39
42
|
## 📖 介绍
|
@@ -87,12 +90,17 @@ _✨ 简单的狼人杀插件 ✨_
|
|
87
90
|
|
88
91
|
## ⚙️ 配置
|
89
92
|
|
90
|
-
在 nonebot2
|
93
|
+
在 nonebot2 项目的 `.env` 文件中添加如下配置
|
94
|
+
|
95
|
+
| 配置项 | 必填 | 默认值 | 说明 |
|
96
|
+
| :-----------------------------: | :--: | :----: | :-----------------------------------------------------------: |
|
97
|
+
| `werewolf__enable_poke` | 否 | `True` | 是否使用戳一戳简化操作流程<br/>仅在 `OneBot V11` 适配器下生效 |
|
98
|
+
| `werewolf__role_preset` | 否 | - | 覆写插件内置的职业预设 |
|
99
|
+
| `werewolf__werewolf_priority` | 否 | - | 自定义狼人职业优先级 |
|
100
|
+
| `werewolf__priesthood_proirity` | 否 | - | 自定义神职职业优先级 |
|
101
|
+
| `werewolf__joker_probability` | 否 | `0.0` | 小丑职业替换平民的概率, 范围`[0,1]` |
|
91
102
|
|
92
|
-
|
93
|
-
| :-------------------------: | :--: | :----: | :-----------------------------------------------------------: |
|
94
|
-
| `werewolf__enable_poke` | 否 | `True` | 是否使用戳一戳简化操作流程<br/>仅在 `OneBot V11` 适配器下生效 |
|
95
|
-
| `werewolf__override_preset` | 否 | - | 覆写插件内置的职业预设 |
|
103
|
+
`werewolf__role_preset`, `werewolf__werewolf_priority`, `werewolf__priesthood_proirity` 的配置格式请参考 [`游戏内容`](#游戏内容) 部分
|
96
104
|
|
97
105
|
## 🎉 使用
|
98
106
|
|
@@ -150,15 +158,15 @@ _其他交互参考游戏内提示_
|
|
150
158
|
| 11 | 3 | 5 | 3 |
|
151
159
|
| 12 | 4 | 5 | 3 |
|
152
160
|
|
153
|
-
职业预设可以通过配置项 `
|
161
|
+
职业预设可以通过配置项 `werewolf__role_preset` 修改
|
154
162
|
|
155
163
|
<details>
|
156
164
|
<summary>示例</summary>
|
157
165
|
|
158
|
-
配置项 `
|
166
|
+
配置项 `werewolf__role_preset`
|
159
167
|
|
160
168
|
```env
|
161
|
-
|
169
|
+
werewolf__role_preset='
|
162
170
|
[
|
163
171
|
[6, 1, 3, 2],
|
164
172
|
[7, 2, 3, 2]
|
@@ -171,16 +179,70 @@ werewolf__override_preset='
|
|
171
179
|
</details>
|
172
180
|
<br/>
|
173
181
|
|
174
|
-
|
182
|
+
对于`狼人`和`神职`的职业分配,默认有如下优先级:
|
175
183
|
|
176
184
|
- `狼人`: `狼人`, `狼人`, `狼王`, `狼人`
|
177
|
-
- `神职`: `预言家`,
|
185
|
+
- `神职`: `女巫`, `预言家`, `猎人`, `守卫`, `白痴`
|
186
|
+
|
187
|
+
职业分配优先级可以通过配置项 `werewolf__werewolf_priority` 和 `werewolf__priesthood_proirity` 修改
|
188
|
+
|
189
|
+
<details>
|
190
|
+
<summary>示例</summary>
|
191
|
+
|
192
|
+
#### 配置项 `werewolf__werewolf_priority`
|
193
|
+
|
194
|
+
```env
|
195
|
+
werewolf__werewolf_priority=[1, 2, 1, 1]
|
196
|
+
```
|
197
|
+
|
198
|
+
上述配置中,`[1, 2, 1, 1]` 表示狼人的职业优先级为 `狼人`, `狼王`, `狼人`, `狼人`
|
199
|
+
|
200
|
+
#### 配置项 `werewolf__priesthood_proirity`
|
201
|
+
|
202
|
+
```env
|
203
|
+
werewolf__priesthood_proirity=[11, 12, 13, 14, 15]
|
204
|
+
```
|
205
|
+
|
206
|
+
上述配置中,`[11, 12, 13, 14, 15]` 表示神职的职业优先级为 `预言家`, `女巫`, `猎人`, `守卫`, `白痴`
|
207
|
+
|
208
|
+
#### 职业与数字的对应关系
|
209
|
+
|
210
|
+
上述配置示例中有大量~~意义不明的~~数字, 其对应的是 [`这里`](./nonebot_plugin_werewolf/constant.py) 的枚举类 `Role` 的值
|
211
|
+
|
212
|
+
以下列出目前的枚举值供参考
|
213
|
+
|
214
|
+
| 职业 | 枚举值 |
|
215
|
+
| -------- | ------ |
|
216
|
+
| `狼人` | `1` |
|
217
|
+
| `狼王` | `2` |
|
218
|
+
| `预言家` | `11` |
|
219
|
+
| `女巫` | `12` |
|
220
|
+
| `猎人` | `13` |
|
221
|
+
| `守卫` | `14` |
|
222
|
+
| `白痴` | `15` |
|
223
|
+
| `平民` | `0` |
|
224
|
+
|
225
|
+
</details>
|
178
226
|
|
179
227
|
## 📝 更新日志
|
180
228
|
|
181
229
|
<details>
|
182
230
|
<summary>更新日志</summary>
|
183
231
|
|
232
|
+
<!-- CHANGELOG -->
|
233
|
+
|
234
|
+
- 2024.09.09 v1.1.0
|
235
|
+
|
236
|
+
- 新增职业 `小丑`
|
237
|
+
- 修复守卫无法保护自己的 bug
|
238
|
+
- 添加部分特殊职业的说明
|
239
|
+
- 添加游戏过程中的日志输出
|
240
|
+
|
241
|
+
- 2024.09.04 v1.0.7
|
242
|
+
|
243
|
+
- 优先使用群名片作为玩家名
|
244
|
+
- 支持通过配置项修改职业分配优先级
|
245
|
+
|
184
246
|
- 2024.09.03 v1.0.6
|
185
247
|
|
186
248
|
- 修复预言家查验狼王返回好人的 bug
|
@@ -192,7 +254,7 @@ werewolf__override_preset='
|
|
192
254
|
|
193
255
|
- 2024.08.31 v1.0.1
|
194
256
|
|
195
|
-
-
|
257
|
+
- 支持通过配置项修改职业预设
|
196
258
|
|
197
259
|
- 2024.08.31 v1.0.0
|
198
260
|
|
@@ -206,3 +268,4 @@ werewolf__override_preset='
|
|
206
268
|
- [`nonebot/plugin-alconna`](https://github.com/nonebot/plugin-alconna): 跨平台的消息处理接口
|
207
269
|
- [`noneplugin/nonebot-plugin-userinfo`](https://github.com/noneplugin/nonebot-plugin-userinfo): 用户信息获取
|
208
270
|
- [`RF-Tar-Railt/nonebot-plugin-waiter`](https://github.com/RF-Tar-Railt/nonebot-plugin-waiter): 灵活获取用户输入
|
271
|
+
- `热心群友`: 协助测试插件
|
@@ -14,12 +14,15 @@ _✨ 简单的狼人杀插件 ✨_
|
|
14
14
|
[](https://pypi.python.org/pypi/nonebot-plugin-werewolf)
|
15
15
|
[](https://www.python.org/)
|
16
16
|
|
17
|
-
[](https://github.com/astral-sh/uv)
|
18
18
|
[](https://pycqa.github.io/isort/)
|
19
19
|
[](https://github.com/psf/black)
|
20
20
|
[](https://github.com/Microsoft/pyright)
|
21
21
|
[](https://github.com/astral-sh/ruff)
|
22
22
|
|
23
|
+
[](https://registry.nonebot.dev/plugin/nonebot-plugin-werewolf:nonebot_plugin_werewolf)
|
24
|
+
[](https://registry.nonebot.dev/plugin/nonebot-plugin-werewolf:nonebot_plugin_werewolf)
|
25
|
+
|
23
26
|
</div>
|
24
27
|
|
25
28
|
## 📖 介绍
|
@@ -73,12 +76,17 @@ _✨ 简单的狼人杀插件 ✨_
|
|
73
76
|
|
74
77
|
## ⚙️ 配置
|
75
78
|
|
76
|
-
在 nonebot2
|
79
|
+
在 nonebot2 项目的 `.env` 文件中添加如下配置
|
80
|
+
|
81
|
+
| 配置项 | 必填 | 默认值 | 说明 |
|
82
|
+
| :-----------------------------: | :--: | :----: | :-----------------------------------------------------------: |
|
83
|
+
| `werewolf__enable_poke` | 否 | `True` | 是否使用戳一戳简化操作流程<br/>仅在 `OneBot V11` 适配器下生效 |
|
84
|
+
| `werewolf__role_preset` | 否 | - | 覆写插件内置的职业预设 |
|
85
|
+
| `werewolf__werewolf_priority` | 否 | - | 自定义狼人职业优先级 |
|
86
|
+
| `werewolf__priesthood_proirity` | 否 | - | 自定义神职职业优先级 |
|
87
|
+
| `werewolf__joker_probability` | 否 | `0.0` | 小丑职业替换平民的概率, 范围`[0,1]` |
|
77
88
|
|
78
|
-
|
79
|
-
| :-------------------------: | :--: | :----: | :-----------------------------------------------------------: |
|
80
|
-
| `werewolf__enable_poke` | 否 | `True` | 是否使用戳一戳简化操作流程<br/>仅在 `OneBot V11` 适配器下生效 |
|
81
|
-
| `werewolf__override_preset` | 否 | - | 覆写插件内置的职业预设 |
|
89
|
+
`werewolf__role_preset`, `werewolf__werewolf_priority`, `werewolf__priesthood_proirity` 的配置格式请参考 [`游戏内容`](#游戏内容) 部分
|
82
90
|
|
83
91
|
## 🎉 使用
|
84
92
|
|
@@ -136,15 +144,15 @@ _其他交互参考游戏内提示_
|
|
136
144
|
| 11 | 3 | 5 | 3 |
|
137
145
|
| 12 | 4 | 5 | 3 |
|
138
146
|
|
139
|
-
职业预设可以通过配置项 `
|
147
|
+
职业预设可以通过配置项 `werewolf__role_preset` 修改
|
140
148
|
|
141
149
|
<details>
|
142
150
|
<summary>示例</summary>
|
143
151
|
|
144
|
-
配置项 `
|
152
|
+
配置项 `werewolf__role_preset`
|
145
153
|
|
146
154
|
```env
|
147
|
-
|
155
|
+
werewolf__role_preset='
|
148
156
|
[
|
149
157
|
[6, 1, 3, 2],
|
150
158
|
[7, 2, 3, 2]
|
@@ -157,16 +165,70 @@ werewolf__override_preset='
|
|
157
165
|
</details>
|
158
166
|
<br/>
|
159
167
|
|
160
|
-
|
168
|
+
对于`狼人`和`神职`的职业分配,默认有如下优先级:
|
161
169
|
|
162
170
|
- `狼人`: `狼人`, `狼人`, `狼王`, `狼人`
|
163
|
-
- `神职`: `预言家`,
|
171
|
+
- `神职`: `女巫`, `预言家`, `猎人`, `守卫`, `白痴`
|
172
|
+
|
173
|
+
职业分配优先级可以通过配置项 `werewolf__werewolf_priority` 和 `werewolf__priesthood_proirity` 修改
|
174
|
+
|
175
|
+
<details>
|
176
|
+
<summary>示例</summary>
|
177
|
+
|
178
|
+
#### 配置项 `werewolf__werewolf_priority`
|
179
|
+
|
180
|
+
```env
|
181
|
+
werewolf__werewolf_priority=[1, 2, 1, 1]
|
182
|
+
```
|
183
|
+
|
184
|
+
上述配置中,`[1, 2, 1, 1]` 表示狼人的职业优先级为 `狼人`, `狼王`, `狼人`, `狼人`
|
185
|
+
|
186
|
+
#### 配置项 `werewolf__priesthood_proirity`
|
187
|
+
|
188
|
+
```env
|
189
|
+
werewolf__priesthood_proirity=[11, 12, 13, 14, 15]
|
190
|
+
```
|
191
|
+
|
192
|
+
上述配置中,`[11, 12, 13, 14, 15]` 表示神职的职业优先级为 `预言家`, `女巫`, `猎人`, `守卫`, `白痴`
|
193
|
+
|
194
|
+
#### 职业与数字的对应关系
|
195
|
+
|
196
|
+
上述配置示例中有大量~~意义不明的~~数字, 其对应的是 [`这里`](./nonebot_plugin_werewolf/constant.py) 的枚举类 `Role` 的值
|
197
|
+
|
198
|
+
以下列出目前的枚举值供参考
|
199
|
+
|
200
|
+
| 职业 | 枚举值 |
|
201
|
+
| -------- | ------ |
|
202
|
+
| `狼人` | `1` |
|
203
|
+
| `狼王` | `2` |
|
204
|
+
| `预言家` | `11` |
|
205
|
+
| `女巫` | `12` |
|
206
|
+
| `猎人` | `13` |
|
207
|
+
| `守卫` | `14` |
|
208
|
+
| `白痴` | `15` |
|
209
|
+
| `平民` | `0` |
|
210
|
+
|
211
|
+
</details>
|
164
212
|
|
165
213
|
## 📝 更新日志
|
166
214
|
|
167
215
|
<details>
|
168
216
|
<summary>更新日志</summary>
|
169
217
|
|
218
|
+
<!-- CHANGELOG -->
|
219
|
+
|
220
|
+
- 2024.09.09 v1.1.0
|
221
|
+
|
222
|
+
- 新增职业 `小丑`
|
223
|
+
- 修复守卫无法保护自己的 bug
|
224
|
+
- 添加部分特殊职业的说明
|
225
|
+
- 添加游戏过程中的日志输出
|
226
|
+
|
227
|
+
- 2024.09.04 v1.0.7
|
228
|
+
|
229
|
+
- 优先使用群名片作为玩家名
|
230
|
+
- 支持通过配置项修改职业分配优先级
|
231
|
+
|
170
232
|
- 2024.09.03 v1.0.6
|
171
233
|
|
172
234
|
- 修复预言家查验狼王返回好人的 bug
|
@@ -178,7 +240,7 @@ werewolf__override_preset='
|
|
178
240
|
|
179
241
|
- 2024.08.31 v1.0.1
|
180
242
|
|
181
|
-
-
|
243
|
+
- 支持通过配置项修改职业预设
|
182
244
|
|
183
245
|
- 2024.08.31 v1.0.0
|
184
246
|
|
@@ -192,3 +254,4 @@ werewolf__override_preset='
|
|
192
254
|
- [`nonebot/plugin-alconna`](https://github.com/nonebot/plugin-alconna): 跨平台的消息处理接口
|
193
255
|
- [`noneplugin/nonebot-plugin-userinfo`](https://github.com/noneplugin/nonebot-plugin-userinfo): 用户信息获取
|
194
256
|
- [`RF-Tar-Railt/nonebot-plugin-waiter`](https://github.com/RF-Tar-Railt/nonebot-plugin-waiter): 灵活获取用户输入
|
257
|
+
- `热心群友`: 协助测试插件
|
@@ -0,0 +1,86 @@
|
|
1
|
+
from typing import Literal, overload
|
2
|
+
|
3
|
+
from nonebot import get_plugin_config, logger
|
4
|
+
from nonebot.compat import PYDANTIC_V2
|
5
|
+
from pydantic import BaseModel, Field
|
6
|
+
from typing_extensions import Self
|
7
|
+
|
8
|
+
from .constant import (
|
9
|
+
Role,
|
10
|
+
default_priesthood_proirity,
|
11
|
+
default_role_preset,
|
12
|
+
default_werewolf_priority,
|
13
|
+
)
|
14
|
+
|
15
|
+
if PYDANTIC_V2:
|
16
|
+
from pydantic import model_validator as model_validator
|
17
|
+
else:
|
18
|
+
from pydantic import root_validator
|
19
|
+
|
20
|
+
@overload
|
21
|
+
def model_validator(*, mode: Literal["before"]): ... # noqa: ANN201
|
22
|
+
|
23
|
+
@overload
|
24
|
+
def model_validator(*, mode: Literal["after"]): ... # noqa: ANN201
|
25
|
+
|
26
|
+
def model_validator(*, mode: Literal["before", "after"]):
|
27
|
+
return root_validator(
|
28
|
+
pre=mode == "before", # pyright: ignore[reportArgumentType]
|
29
|
+
allow_reuse=True,
|
30
|
+
)
|
31
|
+
|
32
|
+
|
33
|
+
class PluginConfig(BaseModel):
|
34
|
+
enable_poke: bool = Field(default=True)
|
35
|
+
role_preset: list[tuple[int, int, int, int]] | dict[int, tuple[int, int, int]] = (
|
36
|
+
Field(default_factory=default_role_preset.copy)
|
37
|
+
)
|
38
|
+
werewolf_priority: list[Role] = Field(
|
39
|
+
default_factory=default_werewolf_priority.copy
|
40
|
+
)
|
41
|
+
priesthood_proirity: list[Role] = Field(
|
42
|
+
default_factory=default_priesthood_proirity.copy
|
43
|
+
)
|
44
|
+
joker_probability: float = Field(default=0.0, ge=0.0, le=1.0)
|
45
|
+
|
46
|
+
@model_validator(mode="after")
|
47
|
+
def _validate(self) -> Self:
|
48
|
+
if isinstance(self.role_preset, list):
|
49
|
+
for preset in self.role_preset:
|
50
|
+
if preset[0] != sum(preset[1:]):
|
51
|
+
raise RuntimeError(
|
52
|
+
"配置项 `role_preset` 错误: "
|
53
|
+
f"预设总人数为 {preset[0]}, 实际总人数为 {sum(preset[1:])} "
|
54
|
+
f"({', '.join(map(str, preset[1:]))})"
|
55
|
+
)
|
56
|
+
self.role_preset = default_role_preset | {
|
57
|
+
i[0]: i[1:] for i in self.role_preset
|
58
|
+
}
|
59
|
+
logger.debug(f"覆写配置 role_preset: {self.role_preset}")
|
60
|
+
|
61
|
+
min_length = max(i[0] for i in self.role_preset.values())
|
62
|
+
if len(self.werewolf_priority) < min_length:
|
63
|
+
raise RuntimeError(
|
64
|
+
f"配置项 `werewolf_priority` 错误: 应至少为 {min_length} 项"
|
65
|
+
)
|
66
|
+
|
67
|
+
min_length = max(i[1] for i in self.role_preset.values())
|
68
|
+
if len(self.priesthood_proirity) < min_length:
|
69
|
+
raise RuntimeError(
|
70
|
+
f"配置项 `priesthood_proirity` 错误: 应至少为 {min_length} 项"
|
71
|
+
)
|
72
|
+
|
73
|
+
return self
|
74
|
+
|
75
|
+
def get_role_preset(self) -> dict[int, tuple[int, int, int]]:
|
76
|
+
if isinstance(self.role_preset, list):
|
77
|
+
self.role_preset = {i[0]: i[1:] for i in self.role_preset}
|
78
|
+
return self.role_preset
|
79
|
+
|
80
|
+
|
81
|
+
class Config(BaseModel):
|
82
|
+
werewolf: PluginConfig = PluginConfig()
|
83
|
+
|
84
|
+
|
85
|
+
config = get_plugin_config(Config).werewolf
|
86
|
+
logger.debug(f"加载插件配置: {config}")
|
{nonebot_plugin_werewolf-1.0.6 → nonebot_plugin_werewolf-1.1.0}/nonebot_plugin_werewolf/constant.py
RENAMED
@@ -4,46 +4,47 @@ from dataclasses import dataclass
|
|
4
4
|
from enum import Enum, auto
|
5
5
|
from typing import TYPE_CHECKING
|
6
6
|
|
7
|
-
from strenum import StrEnum
|
8
|
-
|
9
|
-
from .config import config
|
10
|
-
|
11
7
|
if TYPE_CHECKING:
|
12
8
|
from .player import Player
|
13
9
|
|
14
10
|
|
15
|
-
class Role(
|
11
|
+
class Role(Enum):
|
16
12
|
# 狼人
|
17
|
-
Werewolf =
|
18
|
-
WolfKing =
|
13
|
+
Werewolf = 1
|
14
|
+
WolfKing = 2
|
19
15
|
|
20
16
|
# 神职
|
21
|
-
Prophet =
|
22
|
-
Witch =
|
23
|
-
Hunter =
|
24
|
-
Guard =
|
25
|
-
Idiot =
|
17
|
+
Prophet = 11
|
18
|
+
Witch = 12
|
19
|
+
Hunter = 13
|
20
|
+
Guard = 14
|
21
|
+
Idiot = 15
|
22
|
+
|
23
|
+
# 其他
|
24
|
+
Joker = 51
|
26
25
|
|
27
26
|
# 平民
|
28
|
-
Civilian =
|
27
|
+
Civilian = 0
|
29
28
|
|
30
29
|
|
31
|
-
class RoleGroup(
|
30
|
+
class RoleGroup(Enum):
|
32
31
|
Werewolf = auto()
|
33
32
|
GoodGuy = auto()
|
33
|
+
Others = auto()
|
34
34
|
|
35
35
|
|
36
36
|
class KillReason(Enum):
|
37
|
-
|
37
|
+
Werewolf = auto()
|
38
38
|
Poison = auto()
|
39
39
|
Shoot = auto()
|
40
40
|
Vote = auto()
|
41
41
|
|
42
42
|
|
43
43
|
class GameStatus(Enum):
|
44
|
-
|
45
|
-
|
44
|
+
GoodGuy = auto()
|
45
|
+
Werewolf = auto()
|
46
46
|
Unset = auto()
|
47
|
+
Joker = auto()
|
47
48
|
|
48
49
|
|
49
50
|
@dataclass
|
@@ -55,7 +56,7 @@ class GameState:
|
|
55
56
|
potion: tuple[Player | None, tuple[bool, bool]] = (None, (False, False))
|
56
57
|
|
57
58
|
|
58
|
-
role_name_conv: dict[Role, str] = {
|
59
|
+
role_name_conv: dict[Role | RoleGroup, str] = {
|
59
60
|
Role.Werewolf: "狼人",
|
60
61
|
Role.WolfKing: "狼王",
|
61
62
|
Role.Prophet: "预言家",
|
@@ -63,16 +64,14 @@ role_name_conv: dict[Role, str] = {
|
|
63
64
|
Role.Hunter: "猎人",
|
64
65
|
Role.Guard: "守卫",
|
65
66
|
Role.Idiot: "白痴",
|
67
|
+
Role.Joker: "小丑",
|
66
68
|
Role.Civilian: "平民",
|
67
|
-
}
|
68
|
-
|
69
|
-
|
70
|
-
role_group_name_conv: dict[RoleGroup, str] = {
|
71
69
|
RoleGroup.Werewolf: "狼人",
|
72
70
|
RoleGroup.GoodGuy: "好人",
|
71
|
+
RoleGroup.Others: "其他",
|
73
72
|
}
|
74
73
|
|
75
|
-
|
74
|
+
default_role_preset: dict[int, tuple[int, int, int]] = {
|
76
75
|
# 总人数: (狼, 神, 民)
|
77
76
|
6: (1, 2, 3),
|
78
77
|
7: (2, 2, 3),
|
@@ -83,6 +82,16 @@ player_preset: dict[int, tuple[int, int, int]] = {
|
|
83
82
|
12: (4, 5, 3),
|
84
83
|
}
|
85
84
|
|
86
|
-
|
87
|
-
|
88
|
-
|
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
|