nonebot-plugin-werewolf 1.1.5__tar.gz → 1.1.7__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 (42) hide show
  1. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/PKG-INFO +71 -67
  2. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/README.md +69 -66
  3. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/__init__.py +2 -1
  4. nonebot_plugin_werewolf-1.1.7/nonebot_plugin_werewolf/config.py +45 -0
  5. nonebot_plugin_werewolf-1.1.7/nonebot_plugin_werewolf/constant.py +74 -0
  6. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/exception.py +1 -1
  7. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/game.py +217 -226
  8. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/matchers/__init__.py +2 -0
  9. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/matchers/depends.py +17 -5
  10. nonebot_plugin_werewolf-1.1.7/nonebot_plugin_werewolf/matchers/edit_preset.py +263 -0
  11. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/matchers/message_in_game.py +8 -3
  12. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/matchers/start_game.py +140 -48
  13. nonebot_plugin_werewolf-1.1.7/nonebot_plugin_werewolf/matchers/superuser_ops.py +24 -0
  14. nonebot_plugin_werewolf-1.1.7/nonebot_plugin_werewolf/models.py +73 -0
  15. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/player_set.py +1 -1
  16. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/players/can_shoot.py +4 -3
  17. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/players/civilian.py +1 -1
  18. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/players/guard.py +2 -1
  19. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/players/hunter.py +1 -1
  20. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/players/idiot.py +1 -1
  21. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/players/joker.py +6 -2
  22. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/players/player.py +18 -25
  23. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/players/prophet.py +2 -1
  24. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/players/werewolf.py +25 -26
  25. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/players/witch.py +2 -1
  26. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/players/wolfking.py +1 -1
  27. nonebot_plugin_werewolf-1.1.7/nonebot_plugin_werewolf/utils.py +150 -0
  28. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf.egg-info/PKG-INFO +71 -67
  29. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf.egg-info/SOURCES.txt +3 -0
  30. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf.egg-info/requires.txt +1 -0
  31. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/pyproject.toml +5 -3
  32. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/config.py +0 -82
  33. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/constant.py +0 -134
  34. nonebot_plugin_werewolf-1.1.5/nonebot_plugin_werewolf/utils.py +0 -86
  35. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/LICENSE +0 -0
  36. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/matchers/poke/__init__.py +0 -0
  37. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/matchers/poke/chronocat_poke.py +0 -0
  38. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/matchers/poke/ob11_poke.py +0 -0
  39. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf/players/__init__.py +0 -0
  40. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf.egg-info/dependency_links.txt +0 -0
  41. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/nonebot_plugin_werewolf.egg-info/top_level.txt +0 -0
  42. {nonebot_plugin_werewolf-1.1.5 → nonebot_plugin_werewolf-1.1.7}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nonebot-plugin-werewolf
3
- Version: 1.1.5
3
+ Version: 1.1.7
4
4
  Summary: 适用于 Nonebot2 的狼人杀插件
5
5
  Author-email: wyf7685 <wyf7685@163.com>
6
6
  License: MIT
@@ -12,6 +12,7 @@ Description-Content-Type: text/markdown
12
12
  License-File: LICENSE
13
13
  Requires-Dist: nonebot2>=2.3.3
14
14
  Requires-Dist: nonebot-plugin-alconna>=0.52.1
15
+ Requires-Dist: nonebot-plugin-localstore>=0.7.1
15
16
  Requires-Dist: nonebot-plugin-uninfo>=0.4.0
16
17
  Requires-Dist: nonebot-plugin-waiter>=0.7.1
17
18
  Requires-Dist: anyio>=4.6.0
@@ -44,6 +45,7 @@ _✨ 简单的狼人杀插件 ✨_
44
45
  [![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)
45
46
 
46
47
  <!-- https://github.com/lgc2333/nonebot-registry-badge -->
48
+
47
49
  [![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)
48
50
  [![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)
49
51
 
@@ -56,7 +58,7 @@ _✨ 简单的狼人杀插件 ✨_
56
58
  ## 💿 安装
57
59
 
58
60
  > [!note]
59
- >
61
+ >
60
62
  > 请确保 NoneBot2 使用的 Python 解释器版本 >=3.10
61
63
 
62
64
  <details open>
@@ -104,17 +106,16 @@ _✨ 简单的狼人杀插件 ✨_
104
106
 
105
107
  ## ⚙️ 配置
106
108
 
107
- 在 nonebot2 项目的 `.env` 文件中添加如下配置
109
+ 在 nonebot2 项目的 `.env` 文件中添加如下配置:
110
+
111
+ | 配置项 | 必填 | 默认值 | 说明 |
112
+ | :-----------------------: | :---: | :-----: | :------------------------: |
113
+ | `werewolf__enable_poke` | 否 | `True` | 是否使用戳一戳简化操作流程 |
114
+ | `werewolf__enable_button` | 否 | `False` | 是否在交互中添加按钮 |
108
115
 
109
- | 配置项 | 必填 | 默认值 | 说明 |
110
- | :-----------------------------: | :--: | :----: | :-----------------------------------------------------------: |
111
- | `werewolf__enable_poke` | 否 | `True` | 是否使用戳一戳简化操作流程<br/>仅在 `OneBot V11` 适配器下生效 |
112
- | `werewolf__role_preset` | 否 | - | 覆写插件内置的职业预设 |
113
- | `werewolf__werewolf_priority` | 否 | - | 自定义狼人职业优先级 |
114
- | `werewolf__priesthood_proirity` | 否 | - | 自定义神职职业优先级 |
115
- | `werewolf__joker_probability` | 否 | `0.0` | 小丑职业替换平民的概率, 范围`[0,1]` |
116
+ `werewolf__enable_poke` 仅在 `OneBot V11` 适配器 / `Satori/chronocat` 下生效
116
117
 
117
- `werewolf__role_preset`, `werewolf__werewolf_priority`, `werewolf__priesthood_proirity` 的配置格式请参考 [`游戏内容`](#游戏内容) 部分
118
+ `werewolf__enable_button` 仅在 `Telegram` 适配器下通过测试,不保证在其他适配器的可用性。如有疑问欢迎提出。
118
119
 
119
120
  ## 🎉 使用
120
121
 
@@ -133,24 +134,31 @@ _✨ 简单的狼人杀插件 ✨_
133
134
 
134
135
  而对于野生机器人,现有协议端通常不支持或不建议使用临时私聊消息。
135
136
 
136
- 在使用本插件前,应当确保机器人可以正常向玩家发送私聊消息。
137
+ 在使用本插件前,应当确保机器人可以正常向玩家发送私聊消息。~~即保证机器人与玩家为好友关系~~
137
138
 
138
139
  </details>
139
140
 
140
141
  ### 指令表
141
142
 
142
- | 指令 | 权限 | 需要@ | 范围 | 说明 |
143
- | :-----------------: | :--------: | :---: | :--: | :---------------------------------: |
144
- | `werewolf`/`狼人杀` | 群员 | 是 | 群聊 | 发起游戏 (进入准备阶段) |
145
- | `开始游戏` | 游戏发起者 | | 群聊 | _[准备阶段]_ 游戏发起者开始游戏 |
146
- | `结束游戏` | 游戏发起者 | | 群聊 | _[准备阶段]_ 游戏发起者结束游戏 |
147
- | `当前玩家` | 群员 | | 群聊 | _[准备阶段]_ 列出参与游戏的玩家列表 |
148
- | `加入游戏` | 群员 | | 群聊 | _[准备阶段]_ 玩家加入游戏 |
149
- | `退出游戏` | 群员 | | 群聊 | _[准备阶段]_ 玩家退出游戏 |
143
+ | 指令 | 权限 | 需要@ | 范围 | 说明 |
144
+ | :-----------------: | :-----------------: | :---: | :---: | :---------------------------------------: |
145
+ | `werewolf`/`狼人杀` | 群员 | 是 | 群聊 | 发起游戏 (进入准备阶段) |
146
+ | `开始游戏` | 游戏发起者 | | 群聊 | _[准备阶段]_ 游戏发起者开始游戏 |
147
+ | `结束游戏` | 游戏发起者/超级用户 | | 群聊 | _[准备阶段]_ 游戏发起者/超级用户 结束游戏 |
148
+ | `当前玩家` | 群员 | | 群聊 | _[准备阶段]_ 列出参与游戏的玩家列表 |
149
+ | `加入游戏` | 群员 | | 群聊 | _[准备阶段]_ 玩家加入游戏 |
150
+ | `退出游戏` | 群员 | | 群聊 | _[准备阶段]_ 玩家退出游戏 |
151
+ | `中止游戏` | 超级用户 | 是 | 群聊 | _[游戏内]_ 超级用户强制中止游戏 |
152
+ | `狼人杀预设` | 超级用户 | 否 | 任意 | _[游戏外]_ 超级用户编辑游戏预设 |
153
+
154
+ - 发起游戏时添加 `restart`/`重开`, 可加载上一次游戏的玩家列表, 快速发起游戏。例: `werewolf restart`/`狼人杀 重开`
155
+
156
+ - `狼人杀预设` 命令用法可通过 `狼人杀预设 --help` 获取,或参考 [游戏内容](#游戏内容) 部分的介绍
150
157
 
151
- _其他交互参考游戏内提示_
158
+ - 对于 `OneBot V11` 适配器和 `Satori` 适配器的 `chronocat`, 启用配置项 `werewolf__enable_poke` 后, 可以使用戳一戳代替 _准备阶段_ 的 `加入游戏` 操作 和 游戏内的 `stop` 命令
159
+
160
+ - _其他交互参考游戏内提示_
152
161
 
153
- 对于 `OneBot V11` 适配器和 `Satori` 适配器的 `chronocat`, 启用配置项 `werewolf__enable_poke` 后, 可以使用戳一戳代替 _准备阶段_ 的 `加入游戏` 操作 和 游戏内的 `stop` 命令
154
162
 
155
163
  ### 游戏内容
156
164
 
@@ -164,31 +172,22 @@ _其他交互参考游戏内提示_
164
172
 
165
173
  | 总人数 | 狼人 | 神职 | 平民 |
166
174
  | ------ | ---- | ---- | ---- |
167
- | 6     | 1  | 2   | 3   |
168
- | 7     | 2  | 2   | 3   |
169
- | 8     | 2  | 3   | 3   |
170
- | 9     | 2  | 4   | 3   |
171
- | 10   | 3  | 4   | 3   |
172
- | 11   | 3  | 5   | 3   |
173
- | 12   | 4  | 5   | 3   |
175
+ | 6 | 1 | 2 | 3 |
176
+ | 7 | 2 | 2 | 3 |
177
+ | 8 | 2 | 3 | 3 |
178
+ | 9 | 2 | 4 | 3 |
179
+ | 10 | 3 | 4 | 3 |
180
+ | 11 | 3 | 5 | 3 |
181
+ | 12 | 4 | 5 | 3 |
174
182
 
175
- 职业预设可以通过配置项 `werewolf__role_preset` 修改
183
+ 职业预设可以通过命令 `狼人杀预设 职业 ...` 修改
176
184
 
177
185
  <details>
178
186
  <summary>示例</summary>
179
187
 
180
- 配置项 `werewolf__role_preset`
181
-
182
- ```env
183
- werewolf__role_preset='
184
- [
185
- [6, 1, 3, 2],
186
- [7, 2, 3, 2]
187
- ]
188
- '
189
- ```
188
+ - 命令: `狼人杀预设 职业 6 1 3 2`
190
189
 
191
- 上述配置中,`[6, 1, 3, 2]` 表示当总人数为 6 时,狼人、神职、平民的数量分别为 1、3、2
190
+ - 上述命令指定当总人数为 6 时,狼人、神职、平民的数量分别为 1、3、2
192
191
 
193
192
  </details>
194
193
  <br/>
@@ -198,49 +197,43 @@ werewolf__role_preset='
198
197
  - `狼人`: `狼人`, `狼人`, `狼王`, `狼人`
199
198
  - `神职`: `女巫`, `预言家`, `猎人`, `守卫`, `白痴`
200
199
 
201
- 职业分配优先级可以通过配置项 `werewolf__werewolf_priority` `werewolf__priesthood_proirity` 修改
200
+ 职业分配优先级可以通过命令 `狼人杀预设 狼人/神职` 修改
202
201
 
203
202
  <details>
204
203
  <summary>示例</summary>
205
204
 
206
- #### 配置项 `werewolf__werewolf_priority`
205
+ #### 命令 `狼人杀预设 狼人`
207
206
 
208
- ```env
209
- werewolf__werewolf_priority=[1, 2, 1, 1]
210
- ```
207
+ - 命令: `狼人杀预设 狼人 狼 狼王 狼 狼`
211
208
 
212
- 上述配置中,`[1, 2, 1, 1]` 表示狼人的职业优先级为 `狼人`, `狼王`, `狼人`, `狼人`
209
+ - 上述命令指定狼人的职业优先级为 `狼人`, `狼王`, `狼人`, `狼人`
213
210
 
214
- #### 配置项 `werewolf__priesthood_proirity`
211
+ #### 命令 `狼人杀预设 神职`
215
212
 
216
- ```env
217
- werewolf__priesthood_proirity=[11, 12, 13, 14, 15]
218
- ```
213
+ - 命令: `狼人杀预设 神职 预言家 女巫 猎人 守卫 白痴`
219
214
 
220
- 上述配置中,`[11, 12, 13, 14, 15]` 表示神职的职业优先级为 `预言家`, `女巫`, `猎人`, `守卫`, `白痴`
215
+ - 上述命令指定狼人的职业优先级为 `预言家`, `女巫`, `猎人`, `守卫`, `白痴`
221
216
 
222
- #### 职业与数字的对应关系
217
+ > [!note]
218
+ >
219
+ > 以上两条命令均支持交互式输入
220
+ >
221
+ > 例:向机器人发送命令 `狼人杀预设 狼人`,在接下来的一条消息中发送 `狼人 狼王 狼人 狼人`
222
+ >
223
+ > 其效果等同于以上描述中的单条命令 `狼人杀预设 狼人 狼人 狼王 狼人 狼人`
223
224
 
224
- 上述配置示例中有大量~~意义不明的~~数字, 其对应的是 [`这里`](./nonebot_plugin_werewolf/constant.py) 的枚举类 `Role` 的值
225
+ </details>
226
+ <br/>
225
227
 
226
- 以下列出目前的枚举值供参考
228
+ 对于 `小丑` 职业,当预设中的平民数量大于或等于 2 时,将有 *一定概率* 将其中一个平民替换为小丑。
227
229
 
228
- | 职业 | 枚举值 |
229
- | -------- | ------ |
230
- | `狼人` | `1` |
231
- | `狼王` | `2` |
232
- | `预言家` | `11` |
233
- | `女巫` | `12` |
234
- | `猎人` | `13` |
235
- | `守卫` | `14` |
236
- | `白痴` | `15` |
237
- | `平民` | `0` |
230
+ 小丑属于第三方阵营,胜利条件为在投票阶段被票出,在预言家查验及游戏进程判断时视作平民。
238
231
 
239
- </details>
232
+ 小丑生成概率可以通过命令 `狼人杀预设 小丑 <概率>` 设置,默认值为 0 (不生成小丑)。
240
233
 
241
234
  ### 已知问题
242
235
 
243
- - 截止 chronocat v0.2.19, 调用 [`guild.member.get`](https://github.com/chrononeko/chronocat/blob/8558ad9ff4319395d86abbfda22136939bf66780/packages/engine-chronocat-api/src/api/guild/member/get.ts) / [`user.get`](https://github.com/chrononeko/chronocat/blob/8558ad9ff4319395d86abbfda22136939bf66780/packages/engine-chronocat-api/src/api/user/get.ts) 均无法获取用户名,这将导致在交互过程中的玩家名显示为用户ID
236
+ - 截止 chronocat v0.2.19, 调用 [`guild.member.get`](https://github.com/chrononeko/chronocat/blob/8558ad9ff4319395d86abbfda22136939bf66780/packages/engine-chronocat-api/src/api/guild/member/get.ts) / [`user.get`](https://github.com/chrononeko/chronocat/blob/8558ad9ff4319395d86abbfda22136939bf66780/packages/engine-chronocat-api/src/api/user/get.ts) 均无法获取用户名,这将导致在交互过程中的玩家名显示为用户 ID
244
237
 
245
238
  ## 📝 更新日志
246
239
 
@@ -249,6 +242,17 @@ werewolf__priesthood_proirity=[11, 12, 13, 14, 15]
249
242
 
250
243
  <!-- CHANGELOG -->
251
244
 
245
+ - 2024.10.31 v1.1.7
246
+
247
+ - *Bug fix*
248
+
249
+ - 2024.10.31 v1.1.6
250
+
251
+ - 新增超级用户中止游戏 (#7)
252
+ - 新增快速发起上次游戏 (#8)
253
+ - 准备阶段添加可选的交互按钮
254
+ - 新增超级用户修改游戏预设 (#9)
255
+
252
256
  - 2024.10.23 v1.1.5
253
257
 
254
258
  - 添加对 chronocat:poke 的支持
@@ -26,6 +26,7 @@ _✨ 简单的狼人杀插件 ✨_
26
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
27
 
28
28
  <!-- https://github.com/lgc2333/nonebot-registry-badge -->
29
+
29
30
  [![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)
30
31
  [![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)
31
32
 
@@ -38,7 +39,7 @@ _✨ 简单的狼人杀插件 ✨_
38
39
  ## 💿 安装
39
40
 
40
41
  > [!note]
41
- >
42
+ >
42
43
  > 请确保 NoneBot2 使用的 Python 解释器版本 >=3.10
43
44
 
44
45
  <details open>
@@ -86,17 +87,16 @@ _✨ 简单的狼人杀插件 ✨_
86
87
 
87
88
  ## ⚙️ 配置
88
89
 
89
- 在 nonebot2 项目的 `.env` 文件中添加如下配置
90
+ 在 nonebot2 项目的 `.env` 文件中添加如下配置:
91
+
92
+ | 配置项 | 必填 | 默认值 | 说明 |
93
+ | :-----------------------: | :---: | :-----: | :------------------------: |
94
+ | `werewolf__enable_poke` | 否 | `True` | 是否使用戳一戳简化操作流程 |
95
+ | `werewolf__enable_button` | 否 | `False` | 是否在交互中添加按钮 |
90
96
 
91
- | 配置项 | 必填 | 默认值 | 说明 |
92
- | :-----------------------------: | :--: | :----: | :-----------------------------------------------------------: |
93
- | `werewolf__enable_poke` | 否 | `True` | 是否使用戳一戳简化操作流程<br/>仅在 `OneBot V11` 适配器下生效 |
94
- | `werewolf__role_preset` | 否 | - | 覆写插件内置的职业预设 |
95
- | `werewolf__werewolf_priority` | 否 | - | 自定义狼人职业优先级 |
96
- | `werewolf__priesthood_proirity` | 否 | - | 自定义神职职业优先级 |
97
- | `werewolf__joker_probability` | 否 | `0.0` | 小丑职业替换平民的概率, 范围`[0,1]` |
97
+ `werewolf__enable_poke` 仅在 `OneBot V11` 适配器 / `Satori/chronocat` 下生效
98
98
 
99
- `werewolf__role_preset`, `werewolf__werewolf_priority`, `werewolf__priesthood_proirity` 的配置格式请参考 [`游戏内容`](#游戏内容) 部分
99
+ `werewolf__enable_button` 仅在 `Telegram` 适配器下通过测试,不保证在其他适配器的可用性。如有疑问欢迎提出。
100
100
 
101
101
  ## 🎉 使用
102
102
 
@@ -115,24 +115,31 @@ _✨ 简单的狼人杀插件 ✨_
115
115
 
116
116
  而对于野生机器人,现有协议端通常不支持或不建议使用临时私聊消息。
117
117
 
118
- 在使用本插件前,应当确保机器人可以正常向玩家发送私聊消息。
118
+ 在使用本插件前,应当确保机器人可以正常向玩家发送私聊消息。~~即保证机器人与玩家为好友关系~~
119
119
 
120
120
  </details>
121
121
 
122
122
  ### 指令表
123
123
 
124
- | 指令 | 权限 | 需要@ | 范围 | 说明 |
125
- | :-----------------: | :--------: | :---: | :--: | :---------------------------------: |
126
- | `werewolf`/`狼人杀` | 群员 | 是 | 群聊 | 发起游戏 (进入准备阶段) |
127
- | `开始游戏` | 游戏发起者 | | 群聊 | _[准备阶段]_ 游戏发起者开始游戏 |
128
- | `结束游戏` | 游戏发起者 | | 群聊 | _[准备阶段]_ 游戏发起者结束游戏 |
129
- | `当前玩家` | 群员 | | 群聊 | _[准备阶段]_ 列出参与游戏的玩家列表 |
130
- | `加入游戏` | 群员 | | 群聊 | _[准备阶段]_ 玩家加入游戏 |
131
- | `退出游戏` | 群员 | | 群聊 | _[准备阶段]_ 玩家退出游戏 |
124
+ | 指令 | 权限 | 需要@ | 范围 | 说明 |
125
+ | :-----------------: | :-----------------: | :---: | :---: | :---------------------------------------: |
126
+ | `werewolf`/`狼人杀` | 群员 | 是 | 群聊 | 发起游戏 (进入准备阶段) |
127
+ | `开始游戏` | 游戏发起者 | | 群聊 | _[准备阶段]_ 游戏发起者开始游戏 |
128
+ | `结束游戏` | 游戏发起者/超级用户 | | 群聊 | _[准备阶段]_ 游戏发起者/超级用户 结束游戏 |
129
+ | `当前玩家` | 群员 | | 群聊 | _[准备阶段]_ 列出参与游戏的玩家列表 |
130
+ | `加入游戏` | 群员 | | 群聊 | _[准备阶段]_ 玩家加入游戏 |
131
+ | `退出游戏` | 群员 | | 群聊 | _[准备阶段]_ 玩家退出游戏 |
132
+ | `中止游戏` | 超级用户 | 是 | 群聊 | _[游戏内]_ 超级用户强制中止游戏 |
133
+ | `狼人杀预设` | 超级用户 | 否 | 任意 | _[游戏外]_ 超级用户编辑游戏预设 |
134
+
135
+ - 发起游戏时添加 `restart`/`重开`, 可加载上一次游戏的玩家列表, 快速发起游戏。例: `werewolf restart`/`狼人杀 重开`
136
+
137
+ - `狼人杀预设` 命令用法可通过 `狼人杀预设 --help` 获取,或参考 [游戏内容](#游戏内容) 部分的介绍
132
138
 
133
- _其他交互参考游戏内提示_
139
+ - 对于 `OneBot V11` 适配器和 `Satori` 适配器的 `chronocat`, 启用配置项 `werewolf__enable_poke` 后, 可以使用戳一戳代替 _准备阶段_ 的 `加入游戏` 操作 和 游戏内的 `stop` 命令
140
+
141
+ - _其他交互参考游戏内提示_
134
142
 
135
- 对于 `OneBot V11` 适配器和 `Satori` 适配器的 `chronocat`, 启用配置项 `werewolf__enable_poke` 后, 可以使用戳一戳代替 _准备阶段_ 的 `加入游戏` 操作 和 游戏内的 `stop` 命令
136
143
 
137
144
  ### 游戏内容
138
145
 
@@ -146,31 +153,22 @@ _其他交互参考游戏内提示_
146
153
 
147
154
  | 总人数 | 狼人 | 神职 | 平民 |
148
155
  | ------ | ---- | ---- | ---- |
149
- | 6     | 1  | 2   | 3   |
150
- | 7     | 2  | 2   | 3   |
151
- | 8     | 2  | 3   | 3   |
152
- | 9     | 2  | 4   | 3   |
153
- | 10   | 3  | 4   | 3   |
154
- | 11   | 3  | 5   | 3   |
155
- | 12   | 4  | 5   | 3   |
156
+ | 6 | 1 | 2 | 3 |
157
+ | 7 | 2 | 2 | 3 |
158
+ | 8 | 2 | 3 | 3 |
159
+ | 9 | 2 | 4 | 3 |
160
+ | 10 | 3 | 4 | 3 |
161
+ | 11 | 3 | 5 | 3 |
162
+ | 12 | 4 | 5 | 3 |
156
163
 
157
- 职业预设可以通过配置项 `werewolf__role_preset` 修改
164
+ 职业预设可以通过命令 `狼人杀预设 职业 ...` 修改
158
165
 
159
166
  <details>
160
167
  <summary>示例</summary>
161
168
 
162
- 配置项 `werewolf__role_preset`
163
-
164
- ```env
165
- werewolf__role_preset='
166
- [
167
- [6, 1, 3, 2],
168
- [7, 2, 3, 2]
169
- ]
170
- '
171
- ```
169
+ - 命令: `狼人杀预设 职业 6 1 3 2`
172
170
 
173
- 上述配置中,`[6, 1, 3, 2]` 表示当总人数为 6 时,狼人、神职、平民的数量分别为 1、3、2
171
+ - 上述命令指定当总人数为 6 时,狼人、神职、平民的数量分别为 1、3、2
174
172
 
175
173
  </details>
176
174
  <br/>
@@ -180,49 +178,43 @@ werewolf__role_preset='
180
178
  - `狼人`: `狼人`, `狼人`, `狼王`, `狼人`
181
179
  - `神职`: `女巫`, `预言家`, `猎人`, `守卫`, `白痴`
182
180
 
183
- 职业分配优先级可以通过配置项 `werewolf__werewolf_priority` `werewolf__priesthood_proirity` 修改
181
+ 职业分配优先级可以通过命令 `狼人杀预设 狼人/神职` 修改
184
182
 
185
183
  <details>
186
184
  <summary>示例</summary>
187
185
 
188
- #### 配置项 `werewolf__werewolf_priority`
186
+ #### 命令 `狼人杀预设 狼人`
189
187
 
190
- ```env
191
- werewolf__werewolf_priority=[1, 2, 1, 1]
192
- ```
188
+ - 命令: `狼人杀预设 狼人 狼 狼王 狼 狼`
193
189
 
194
- 上述配置中,`[1, 2, 1, 1]` 表示狼人的职业优先级为 `狼人`, `狼王`, `狼人`, `狼人`
190
+ - 上述命令指定狼人的职业优先级为 `狼人`, `狼王`, `狼人`, `狼人`
195
191
 
196
- #### 配置项 `werewolf__priesthood_proirity`
192
+ #### 命令 `狼人杀预设 神职`
197
193
 
198
- ```env
199
- werewolf__priesthood_proirity=[11, 12, 13, 14, 15]
200
- ```
194
+ - 命令: `狼人杀预设 神职 预言家 女巫 猎人 守卫 白痴`
201
195
 
202
- 上述配置中,`[11, 12, 13, 14, 15]` 表示神职的职业优先级为 `预言家`, `女巫`, `猎人`, `守卫`, `白痴`
196
+ - 上述命令指定狼人的职业优先级为 `预言家`, `女巫`, `猎人`, `守卫`, `白痴`
203
197
 
204
- #### 职业与数字的对应关系
198
+ > [!note]
199
+ >
200
+ > 以上两条命令均支持交互式输入
201
+ >
202
+ > 例:向机器人发送命令 `狼人杀预设 狼人`,在接下来的一条消息中发送 `狼人 狼王 狼人 狼人`
203
+ >
204
+ > 其效果等同于以上描述中的单条命令 `狼人杀预设 狼人 狼人 狼王 狼人 狼人`
205
205
 
206
- 上述配置示例中有大量~~意义不明的~~数字, 其对应的是 [`这里`](./nonebot_plugin_werewolf/constant.py) 的枚举类 `Role` 的值
206
+ </details>
207
+ <br/>
207
208
 
208
- 以下列出目前的枚举值供参考
209
+ 对于 `小丑` 职业,当预设中的平民数量大于或等于 2 时,将有 *一定概率* 将其中一个平民替换为小丑。
209
210
 
210
- | 职业 | 枚举值 |
211
- | -------- | ------ |
212
- | `狼人` | `1` |
213
- | `狼王` | `2` |
214
- | `预言家` | `11` |
215
- | `女巫` | `12` |
216
- | `猎人` | `13` |
217
- | `守卫` | `14` |
218
- | `白痴` | `15` |
219
- | `平民` | `0` |
211
+ 小丑属于第三方阵营,胜利条件为在投票阶段被票出,在预言家查验及游戏进程判断时视作平民。
220
212
 
221
- </details>
213
+ 小丑生成概率可以通过命令 `狼人杀预设 小丑 <概率>` 设置,默认值为 0 (不生成小丑)。
222
214
 
223
215
  ### 已知问题
224
216
 
225
- - 截止 chronocat v0.2.19, 调用 [`guild.member.get`](https://github.com/chrononeko/chronocat/blob/8558ad9ff4319395d86abbfda22136939bf66780/packages/engine-chronocat-api/src/api/guild/member/get.ts) / [`user.get`](https://github.com/chrononeko/chronocat/blob/8558ad9ff4319395d86abbfda22136939bf66780/packages/engine-chronocat-api/src/api/user/get.ts) 均无法获取用户名,这将导致在交互过程中的玩家名显示为用户ID
217
+ - 截止 chronocat v0.2.19, 调用 [`guild.member.get`](https://github.com/chrononeko/chronocat/blob/8558ad9ff4319395d86abbfda22136939bf66780/packages/engine-chronocat-api/src/api/guild/member/get.ts) / [`user.get`](https://github.com/chrononeko/chronocat/blob/8558ad9ff4319395d86abbfda22136939bf66780/packages/engine-chronocat-api/src/api/user/get.ts) 均无法获取用户名,这将导致在交互过程中的玩家名显示为用户 ID
226
218
 
227
219
  ## 📝 更新日志
228
220
 
@@ -231,6 +223,17 @@ werewolf__priesthood_proirity=[11, 12, 13, 14, 15]
231
223
 
232
224
  <!-- CHANGELOG -->
233
225
 
226
+ - 2024.10.31 v1.1.7
227
+
228
+ - *Bug fix*
229
+
230
+ - 2024.10.31 v1.1.6
231
+
232
+ - 新增超级用户中止游戏 (#7)
233
+ - 新增快速发起上次游戏 (#8)
234
+ - 准备阶段添加可选的交互按钮
235
+ - 新增超级用户修改游戏预设 (#9)
236
+
234
237
  - 2024.10.23 v1.1.5
235
238
 
236
239
  - 添加对 chronocat:poke 的支持
@@ -2,6 +2,7 @@ from nonebot import require
2
2
  from nonebot.plugin import PluginMetadata, inherit_supported_adapters
3
3
 
4
4
  require("nonebot_plugin_alconna")
5
+ require("nonebot_plugin_localstore")
5
6
  require("nonebot_plugin_uninfo")
6
7
  require("nonebot_plugin_waiter")
7
8
 
@@ -9,7 +10,7 @@ from . import matchers as matchers
9
10
  from . import players as players
10
11
  from .config import Config
11
12
 
12
- __version__ = "1.1.5"
13
+ __version__ = "1.1.7"
13
14
  __plugin_meta__ = PluginMetadata(
14
15
  name="狼人杀",
15
16
  description="适用于 Nonebot2 的狼人杀插件",
@@ -0,0 +1,45 @@
1
+ import json
2
+
3
+ import nonebot
4
+ from nonebot.compat import model_dump, type_validate_json
5
+ from nonebot_plugin_localstore import get_plugin_data_file
6
+ from pydantic import BaseModel, Field
7
+ from typing_extensions import Self
8
+
9
+ from .constant import (
10
+ default_priesthood_proirity,
11
+ default_role_preset,
12
+ default_werewolf_priority,
13
+ )
14
+ from .models import Role
15
+
16
+
17
+ class PresetData(BaseModel):
18
+ role_preset: dict[int, tuple[int, int, int]] = default_role_preset.copy()
19
+ werewolf_priority: list[Role] = default_werewolf_priority.copy()
20
+ priesthood_proirity: list[Role] = default_priesthood_proirity.copy()
21
+ joker_probability: float = Field(default=0.0, ge=0.0, le=1.0)
22
+
23
+ @classmethod
24
+ def load(cls) -> Self:
25
+ return type_validate_json(cls, preset_data_file.read_text())
26
+
27
+ def save(self) -> None:
28
+ preset_data_file.write_text(json.dumps(model_dump(self)))
29
+
30
+
31
+ class PluginConfig(BaseModel):
32
+ enable_poke: bool = True
33
+ enable_button: bool = False
34
+
35
+
36
+ class Config(BaseModel):
37
+ werewolf: PluginConfig = PluginConfig()
38
+
39
+
40
+ preset_data_file = get_plugin_data_file("preset.json")
41
+ if not preset_data_file.exists():
42
+ PresetData().save()
43
+
44
+ config = nonebot.get_plugin_config(Config).werewolf
45
+ nonebot.logger.debug(f"加载插件配置: {config}")
@@ -0,0 +1,74 @@
1
+ import nonebot
2
+
3
+ from .models import GameStatus, KillReason, Role, RoleGroup
4
+
5
+ COMMAND_START = next(
6
+ iter(sorted(nonebot.get_driver().config.command_start, key=len)), ""
7
+ )
8
+ STOP_COMMAND_PROMPT = f"{COMMAND_START}stop"
9
+ STOP_COMMAND = "{{stop}}"
10
+
11
+
12
+ role_name_conv: dict[Role | RoleGroup, str] = {
13
+ Role.Werewolf: "狼人",
14
+ Role.WolfKing: "狼王",
15
+ Role.Prophet: "预言家",
16
+ Role.Witch: "女巫",
17
+ Role.Hunter: "猎人",
18
+ Role.Guard: "守卫",
19
+ Role.Idiot: "白痴",
20
+ Role.Joker: "小丑",
21
+ Role.Civilian: "平民",
22
+ RoleGroup.Werewolf: "狼人",
23
+ RoleGroup.GoodGuy: "好人",
24
+ RoleGroup.Others: "其他",
25
+ }
26
+
27
+ role_emoji: dict[Role, str] = {
28
+ Role.Werewolf: "🐺",
29
+ Role.WolfKing: "🐺👑",
30
+ Role.Prophet: "🔮",
31
+ Role.Witch: "🧙‍♀️",
32
+ Role.Hunter: "🕵️",
33
+ Role.Guard: "🛡️",
34
+ Role.Idiot: "👨🏻‍🦲",
35
+ Role.Joker: "🤡",
36
+ Role.Civilian: "👨🏻‍🌾",
37
+ }
38
+
39
+ game_status_conv: dict[GameStatus, str] = {
40
+ GameStatus.GoodGuy: "好人",
41
+ GameStatus.Werewolf: "狼人",
42
+ GameStatus.Joker: "小丑",
43
+ }
44
+
45
+ report_text: dict[KillReason, tuple[str, str]] = {
46
+ KillReason.Werewolf: ("🔪", "刀了"),
47
+ KillReason.Poison: ("🧪", "毒死"),
48
+ KillReason.Shoot: ("🔫", "射杀"),
49
+ KillReason.Vote: ("🗳️", "票出"),
50
+ }
51
+
52
+ default_role_preset: dict[int, tuple[int, int, int]] = {
53
+ # 总人数: (狼, 神, 民)
54
+ 6: (1, 2, 3),
55
+ 7: (2, 2, 3),
56
+ 8: (2, 3, 3),
57
+ 9: (2, 4, 3),
58
+ 10: (3, 4, 3),
59
+ 11: (3, 5, 3),
60
+ 12: (4, 5, 3),
61
+ }
62
+ default_werewolf_priority: list[Role] = [
63
+ Role.Werewolf,
64
+ Role.Werewolf,
65
+ Role.WolfKing,
66
+ Role.Werewolf,
67
+ ]
68
+ default_priesthood_proirity: list[Role] = [
69
+ Role.Witch,
70
+ Role.Prophet,
71
+ Role.Hunter,
72
+ Role.Guard,
73
+ Role.Idiot,
74
+ ]
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  from typing import TYPE_CHECKING
4
4
 
5
5
  if TYPE_CHECKING:
6
- from .constant import GameStatus
6
+ from .models import GameStatus
7
7
 
8
8
 
9
9
  class Error(Exception):