nonebot-plugin-werewolf 1.1.7__py3-none-any.whl → 1.1.9__py3-none-any.whl

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 (38) hide show
  1. nonebot_plugin_werewolf/__init__.py +1 -1
  2. nonebot_plugin_werewolf/config.py +74 -15
  3. nonebot_plugin_werewolf/constant.py +59 -46
  4. nonebot_plugin_werewolf/exception.py +2 -4
  5. nonebot_plugin_werewolf/game.py +200 -171
  6. nonebot_plugin_werewolf/matchers/__init__.py +1 -0
  7. nonebot_plugin_werewolf/matchers/depends.py +4 -4
  8. nonebot_plugin_werewolf/matchers/edit_behavior.py +217 -0
  9. nonebot_plugin_werewolf/matchers/edit_preset.py +11 -11
  10. nonebot_plugin_werewolf/matchers/message_in_game.py +3 -1
  11. nonebot_plugin_werewolf/matchers/poke/chronocat_poke.py +8 -5
  12. nonebot_plugin_werewolf/matchers/poke/ob11_poke.py +3 -3
  13. nonebot_plugin_werewolf/matchers/start_game.py +214 -175
  14. nonebot_plugin_werewolf/matchers/superuser_ops.py +3 -3
  15. nonebot_plugin_werewolf/models.py +46 -22
  16. nonebot_plugin_werewolf/player.py +366 -0
  17. nonebot_plugin_werewolf/player_set.py +40 -22
  18. nonebot_plugin_werewolf/players/__init__.py +1 -2
  19. nonebot_plugin_werewolf/players/civilian.py +3 -3
  20. nonebot_plugin_werewolf/players/guard.py +27 -20
  21. nonebot_plugin_werewolf/players/hunter.py +6 -5
  22. nonebot_plugin_werewolf/players/idiot.py +27 -19
  23. nonebot_plugin_werewolf/players/jester.py +29 -0
  24. nonebot_plugin_werewolf/players/prophet.py +20 -14
  25. nonebot_plugin_werewolf/players/shooter.py +54 -0
  26. nonebot_plugin_werewolf/players/werewolf.py +88 -29
  27. nonebot_plugin_werewolf/players/witch.py +48 -24
  28. nonebot_plugin_werewolf/players/wolfking.py +14 -8
  29. nonebot_plugin_werewolf/utils.py +107 -8
  30. {nonebot_plugin_werewolf-1.1.7.dist-info → nonebot_plugin_werewolf-1.1.9.dist-info}/METADATA +30 -20
  31. nonebot_plugin_werewolf-1.1.9.dist-info/RECORD +35 -0
  32. {nonebot_plugin_werewolf-1.1.7.dist-info → nonebot_plugin_werewolf-1.1.9.dist-info}/WHEEL +1 -1
  33. nonebot_plugin_werewolf/players/can_shoot.py +0 -54
  34. nonebot_plugin_werewolf/players/joker.py +0 -25
  35. nonebot_plugin_werewolf/players/player.py +0 -226
  36. nonebot_plugin_werewolf-1.1.7.dist-info/RECORD +0 -34
  37. {nonebot_plugin_werewolf-1.1.7.dist-info → nonebot_plugin_werewolf-1.1.9.dist-info/licenses}/LICENSE +0 -0
  38. {nonebot_plugin_werewolf-1.1.7.dist-info → nonebot_plugin_werewolf-1.1.9.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: nonebot-plugin-werewolf
3
- Version: 1.1.7
3
+ Version: 1.1.9
4
4
  Summary: 适用于 Nonebot2 的狼人杀插件
5
5
  Author-email: wyf7685 <wyf7685@163.com>
6
6
  License: MIT
@@ -10,12 +10,13 @@ Project-URL: bug-tracker, https://github.com/wyf7685/nonebot-plugin-werewolf/iss
10
10
  Requires-Python: >=3.10
11
11
  Description-Content-Type: text/markdown
12
12
  License-File: LICENSE
13
- Requires-Dist: nonebot2 >=2.3.3
14
- Requires-Dist: nonebot-plugin-alconna >=0.52.1
15
- Requires-Dist: nonebot-plugin-localstore >=0.7.1
16
- Requires-Dist: nonebot-plugin-uninfo >=0.4.0
17
- Requires-Dist: nonebot-plugin-waiter >=0.7.1
18
- Requires-Dist: anyio >=4.6.0
13
+ Requires-Dist: nonebot2>=2.3.3
14
+ Requires-Dist: nonebot-plugin-alconna>=0.52.1
15
+ Requires-Dist: nonebot-plugin-localstore>=0.7.1
16
+ Requires-Dist: nonebot-plugin-uninfo>=0.4.0
17
+ Requires-Dist: nonebot-plugin-waiter>=0.7.1
18
+ Requires-Dist: anyio>=4.6.0
19
+ Dynamic: license-file
19
20
 
20
21
  <div align="center">
21
22
  <a href="https://v2.nonebot.dev/store">
@@ -32,20 +33,13 @@ _✨ 简单的狼人杀插件 ✨_
32
33
  [![license](https://img.shields.io/github/license/wyf7685/nonebot-plugin-werewolf.svg)](./LICENSE)
33
34
  [![pypi](https://img.shields.io/pypi/v/nonebot-plugin-werewolf?logo=python&logoColor=edb641)](https://pypi.python.org/pypi/nonebot-plugin-werewolf)
34
35
  [![python](https://img.shields.io/badge/python-3.10+-blue?logo=python&logoColor=edb641)](https://www.python.org/)
35
-
36
- [![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)
37
36
  [![ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
38
- [![isort](https://img.shields.io/badge/%20imports-isort-%231674b1)](https://pycqa.github.io/isort/)
39
- [![black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
40
- [![pyright](https://img.shields.io/badge/types-pyright-797952.svg?logo=python&logoColor=edb641)](https://github.com/Microsoft/pyright)
41
37
 
42
38
  [![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)
43
39
  [![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)
44
- [![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)
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)
40
+ [![lint](https://github.com/wyf7685/nonebot-plugin-werewolf/actions/workflows/lint.yml/badge.svg?branch=master&event=push)](https://github.com/wyf7685/nonebot-plugin-werewolf/actions/workflows/lint.yml)
46
41
 
47
42
  <!-- https://github.com/lgc2333/nonebot-registry-badge -->
48
-
49
43
  [![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)
50
44
  [![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)
51
45
 
@@ -108,10 +102,11 @@ _✨ 简单的狼人杀插件 ✨_
108
102
 
109
103
  在 nonebot2 项目的 `.env` 文件中添加如下配置:
110
104
 
111
- | 配置项 | 必填 | 默认值 | 说明 |
112
- | :-----------------------: | :---: | :-----: | :------------------------: |
113
- | `werewolf__enable_poke` | 否 | `True` | 是否使用戳一戳简化操作流程 |
114
- | `werewolf__enable_button` | 否 | `False` | 是否在交互中添加按钮 |
105
+ | 配置项 | 必填 | 默认值 | 说明 |
106
+ | :-----------------------: | :---: | :-----: | :--------------------------: |
107
+ | `werewolf__enable_poke` | 否 | `True` | 是否使用戳一戳简化操作流程 |
108
+ | `werewolf__enable_button` | 否 | `False` | 是否在交互中添加按钮 |
109
+ | `werewolf__stop_command` | 否 | `stop` | 修改游戏进程中的 `stop` 命令 |
115
110
 
116
111
  `werewolf__enable_poke` 仅在 `OneBot V11` 适配器 / `Satori/chronocat` 下生效
117
112
 
@@ -150,11 +145,14 @@ _✨ 简单的狼人杀插件 ✨_
150
145
  | `退出游戏` | 群员 | 否 | 群聊 | _[准备阶段]_ 玩家退出游戏 |
151
146
  | `中止游戏` | 超级用户 | 是 | 群聊 | _[游戏内]_ 超级用户强制中止游戏 |
152
147
  | `狼人杀预设` | 超级用户 | 否 | 任意 | _[游戏外]_ 超级用户编辑游戏预设 |
148
+ | `狼人杀配置` | 超级用户 | 否 | 任意 | _[游戏外]_ 超级用户编辑游戏配置 |
153
149
 
154
150
  - 发起游戏时添加 `restart`/`重开`, 可加载上一次游戏的玩家列表, 快速发起游戏。例: `werewolf restart`/`狼人杀 重开`
155
151
 
156
152
  - `狼人杀预设` 命令用法可通过 `狼人杀预设 --help` 获取,或参考 [游戏内容](#游戏内容) 部分的介绍
157
153
 
154
+ - `狼人杀配置` 命令用法可通过 `狼人杀预设 --help` 获取
155
+
158
156
  - 对于 `OneBot V11` 适配器和 `Satori` 适配器的 `chronocat`, 启用配置项 `werewolf__enable_poke` 后, 可以使用戳一戳代替 _准备阶段_ 的 `加入游戏` 操作 和 游戏内的 `stop` 命令
159
157
 
160
158
  - _其他交互参考游戏内提示_
@@ -242,6 +240,18 @@ _✨ 简单的狼人杀插件 ✨_
242
240
 
243
241
  <!-- CHANGELOG -->
244
242
 
243
+ - 2025.04.15 v1.1.9
244
+
245
+ - 添加游戏行为配置 `werewolf_multi_select`
246
+ - 重构玩家类
247
+ - 添加轮流发言模式缺失的 at 消息段
248
+
249
+ - 2025.02.13 v1.1.8
250
+
251
+ - 优化交互按钮
252
+ - 新增命令 `狼人杀配置` 用于调整游戏行为
253
+ - 新增配置项 `werewolf__stop_command`
254
+
245
255
  - 2024.10.31 v1.1.7
246
256
 
247
257
  - *Bug fix*
@@ -0,0 +1,35 @@
1
+ nonebot_plugin_werewolf/__init__.py,sha256=lDOYm3Z6UA_fFXiKT9cGweOiND3X-Y3RAiKB5iqpTVc,931
2
+ nonebot_plugin_werewolf/config.py,sha256=Dlng9cRvTf8dEPFngOobeV3S-TnrVrjs9Eqje8dH1wQ,3160
3
+ nonebot_plugin_werewolf/constant.py,sha256=NVKMx4CI64hgftJJySa6VnK2K8ZBmGtrAyMxel3HS2o,2053
4
+ nonebot_plugin_werewolf/exception.py,sha256=SP9RdzsREB6PtpRfhZjxqybtvO0aw48hpN9QMU9jDZY,366
5
+ nonebot_plugin_werewolf/game.py,sha256=UL68ftCEgV9h34Xgw1sZPAUbyjIhFhGAdc70w8huWuQ,19438
6
+ nonebot_plugin_werewolf/models.py,sha256=PiQ-5_R-cUlHKWDa5G0bFnz7jv20200_kr449G9Jgjg,2300
7
+ nonebot_plugin_werewolf/player.py,sha256=EzV_In8KmlZAx0GGV-Cj9qIJjIefIf7CXzlchCTJvFo,11259
8
+ nonebot_plugin_werewolf/player_set.py,sha256=RF3aQXLZyUBPa0_G-Q48NUARictMRp6IV2WD-BKtNTQ,2913
9
+ nonebot_plugin_werewolf/utils.py,sha256=bwbBLApPWis15_perT89Mmy33gAdaHR8fKJWVnDGh9E,6803
10
+ nonebot_plugin_werewolf/matchers/__init__.py,sha256=lQ9AZDEWgtbP-W8KWvjkEYc_UfTHSUwjaGdZ7PT3z0E,219
11
+ nonebot_plugin_werewolf/matchers/depends.py,sha256=TITA2brcyHSavFA3K_HgqkoQtkwxdM8miyEKafcfZz4,1343
12
+ nonebot_plugin_werewolf/matchers/edit_behavior.py,sha256=DaxMS9wcSyYpdhnHHXb0GqRgRNm6LNr5W1vbk-B63n4,7014
13
+ nonebot_plugin_werewolf/matchers/edit_preset.py,sha256=PXABbjhQM0DiKfEqjOMKtSrJs2fKoVh91iTJlVD3hKA,8089
14
+ nonebot_plugin_werewolf/matchers/message_in_game.py,sha256=Lm9VqZcnAU023SJ6R8LH-3-tSp8KRtmOJ4x4dTZGb1o,969
15
+ nonebot_plugin_werewolf/matchers/start_game.py,sha256=cFa9KzZ3zEri5Ras1ccFyZQWK8HPcs6KRNZr2ArsdsA,11956
16
+ nonebot_plugin_werewolf/matchers/superuser_ops.py,sha256=oz-znCaraxCJS08Ox1xcbhC0X-Uy-WXeNYTH1LgT2zU,700
17
+ nonebot_plugin_werewolf/matchers/poke/__init__.py,sha256=gYysvGjztN3iDQpX6v5nkPT195FXnk7fqP9kzByTES0,220
18
+ nonebot_plugin_werewolf/matchers/poke/chronocat_poke.py,sha256=kYJfhOGbZkYWmti0S7b82yYxcoEO9baMHORCXA19cpY,4013
19
+ nonebot_plugin_werewolf/matchers/poke/ob11_poke.py,sha256=XYkEYoYqaViLp5pzRBZqyjBqanJp-sZL4595-fhfrys,2587
20
+ nonebot_plugin_werewolf/players/__init__.py,sha256=lDHCYkk6h_1Bl9DKIqF6vPAcLXNhCGlxBFQzPH4NvUQ,345
21
+ nonebot_plugin_werewolf/players/civilian.py,sha256=Y6A5yB74Ckn_U0vAOoRJhpwhm3MyG6m47TalQ2mjhtw,151
22
+ nonebot_plugin_werewolf/players/guard.py,sha256=2HE3MRG92Ujc4JUHEB86EwNB-l7PgdpNUFxCU8cDBKQ,1354
23
+ nonebot_plugin_werewolf/players/hunter.py,sha256=iYeM2srPaoncBrft2LRuyNVUeGyeBF-rs0BAHl7RP7s,228
24
+ nonebot_plugin_werewolf/players/idiot.py,sha256=OfbLuSLhXNJueB9IYheNT7OpenqaFQjKaAKBlOH3hE0,1659
25
+ nonebot_plugin_werewolf/players/jester.py,sha256=aErVfQS30hS0t2KiQSNFfTHmC2_hqtaHdQvQ4U1Ts_Y,1016
26
+ nonebot_plugin_werewolf/players/prophet.py,sha256=OlMYIdSlZppbHVpfpeO60nFwdh1YtxMVCWEuapFZSyA,1084
27
+ nonebot_plugin_werewolf/players/shooter.py,sha256=1bWkqcSFX6Crynh3IrlI-2RGrNiP6d4XJAc8_FAF2JU,1946
28
+ nonebot_plugin_werewolf/players/werewolf.py,sha256=7lAJT7FjEt42J04RNAXkfDDIN-1mQOej0NaIo0dEWMQ,5347
29
+ nonebot_plugin_werewolf/players/witch.py,sha256=flugzsDkpYiMW-BQGvvqwcXHX_UGcsryAnyYKmh07l4,3049
30
+ nonebot_plugin_werewolf/players/wolfking.py,sha256=CMZ5Tq74wupcRPjAzXHEF2Gts4z3thsD57q64uGp_-c,628
31
+ nonebot_plugin_werewolf-1.1.9.dist-info/licenses/LICENSE,sha256=B_WbEqjGr6GYVNfEJPY31T1Opik7OtgOkhRs4Ig3e2M,1064
32
+ nonebot_plugin_werewolf-1.1.9.dist-info/METADATA,sha256=ZL27XQ01QhEddypOZDVFVr5cRfB9WO5MUE19o7GA-jQ,11912
33
+ nonebot_plugin_werewolf-1.1.9.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
34
+ nonebot_plugin_werewolf-1.1.9.dist-info/top_level.txt,sha256=wLTfg8sTKbH9lLT9LtU118C9cTspEBJareLsrYM52YA,24
35
+ nonebot_plugin_werewolf-1.1.9.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.3.0)
2
+ Generator: setuptools (78.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,54 +0,0 @@
1
- from nonebot_plugin_alconna.uniseg import UniMessage
2
- from typing_extensions import override
3
-
4
- from ..constant import STOP_COMMAND_PROMPT
5
- from ..models import KillReason
6
- from .player import Player
7
-
8
-
9
- class CanShoot(Player):
10
- @override
11
- async def post_kill(self) -> None:
12
- if self.kill_info and self.kill_info.reason == KillReason.Poison:
13
- await self.send("⚠️你昨晚被女巫毒杀,无法使用技能")
14
- return await super().post_kill()
15
-
16
- await self.game.send(
17
- UniMessage.text("🕵️玩家 ")
18
- .at(self.user_id)
19
- .text(" 死了\n请在私聊决定射杀目标...")
20
- )
21
-
22
- self.game.state.shoot = None
23
- shoot = await self.shoot()
24
-
25
- if shoot is not None:
26
- self.game.state.shoot = self
27
- await self.send(
28
- UniMessage.text(f"🔫{self.role_name} ")
29
- .at(self.user_id)
30
- .text(" 射杀了玩家 ")
31
- .at(shoot.user_id)
32
- )
33
- await shoot.kill(KillReason.Shoot, self)
34
- self.selected = shoot
35
- else:
36
- await self.send(f"ℹ️{self.role_name}选择了取消技能")
37
- return await super().post_kill()
38
-
39
- async def shoot(self) -> Player | None:
40
- players = self.game.players.alive().exclude(self)
41
- await self.send(
42
- "💫请选择需要射杀的玩家:\n"
43
- + players.show()
44
- + "\n\n🔫发送编号选择玩家"
45
- + f"\n❌发送 “{STOP_COMMAND_PROMPT}” 取消技能"
46
- )
47
-
48
- if selected := await self._select_player(
49
- players,
50
- on_stop="ℹ️已取消技能,回合结束",
51
- ):
52
- await self.send(f"🎯选择射杀的玩家: {selected.name}")
53
-
54
- return selected
@@ -1,25 +0,0 @@
1
- from typing import TYPE_CHECKING
2
-
3
- from typing_extensions import override
4
-
5
- from ..exception import GameFinished
6
- from ..models import GameStatus, KillReason, Role, RoleGroup
7
- from .player import Player
8
-
9
-
10
- @Player.register_role(Role.Joker, RoleGroup.Others)
11
- class Joker(Player):
12
- @override
13
- async def notify_role(self) -> None:
14
- await super().notify_role()
15
- await self.send("⚙️你的胜利条件: 被投票放逐")
16
-
17
- @override
18
- async def kill(self, reason: KillReason, *killers: Player) -> bool:
19
- await super().kill(reason, *killers)
20
- if reason == KillReason.Vote:
21
- if TYPE_CHECKING:
22
- assert self.kill_info is not None
23
- self.game.killed_players.append((self.name, self.kill_info))
24
- raise GameFinished(GameStatus.Joker)
25
- return True
@@ -1,226 +0,0 @@
1
- import functools
2
- import weakref
3
- from collections.abc import Callable
4
- from typing import TYPE_CHECKING, ClassVar, Final, TypeVar, final
5
-
6
- import anyio
7
- import nonebot
8
- from nonebot.adapters import Bot
9
- from nonebot.utils import escape_tag
10
- from nonebot_plugin_alconna.uniseg import Receipt, Target, UniMessage
11
- from nonebot_plugin_uninfo import SceneType
12
-
13
- from ..constant import STOP_COMMAND, STOP_COMMAND_PROMPT, role_emoji, role_name_conv
14
- from ..models import KillInfo, KillReason, Role, RoleGroup
15
- from ..utils import InputStore, check_index, link
16
-
17
- if TYPE_CHECKING:
18
- from ..game import Game
19
- from ..player_set import PlayerSet
20
-
21
-
22
- _P = TypeVar("_P", bound=type["Player"])
23
-
24
- logger = nonebot.logger.opt(colors=True)
25
-
26
-
27
- class Player:
28
- __player_class: ClassVar[dict[Role, type["Player"]]] = {}
29
- role: ClassVar[Role]
30
- role_group: ClassVar[RoleGroup]
31
-
32
- bot: Final[Bot]
33
- alive: bool = True
34
- killed: Final[anyio.Event]
35
- kill_info: KillInfo | None = None
36
- selected: "Player | None" = None
37
-
38
- @final
39
- def __init__(self, bot: Bot, game: "Game", user_id: str) -> None:
40
- self.__user = Target(
41
- user_id,
42
- private=True,
43
- self_id=bot.self_id,
44
- adapter=bot.adapter.get_name(),
45
- )
46
- self.__game_ref = weakref.ref(game)
47
- self.bot = bot
48
- self.killed = anyio.Event()
49
- self._member = None
50
-
51
- @classmethod
52
- def register_role(cls, role: Role, role_group: RoleGroup, /) -> Callable[[_P], _P]:
53
- def decorator(c: _P, /) -> _P:
54
- c.role = role
55
- c.role_group = role_group
56
- cls.__player_class[role] = c
57
- return c
58
-
59
- return decorator
60
-
61
- @final
62
- @classmethod
63
- def new(cls, role: Role, bot: Bot, game: "Game", user_id: str) -> "Player":
64
- if role not in cls.__player_class:
65
- raise ValueError(f"Unexpected role: {role!r}")
66
-
67
- return cls.__player_class[role](bot, game, user_id)
68
-
69
- def __repr__(self) -> str:
70
- return (
71
- f"<Player {self.role_name}: user={self.user_id!r} " f"alive={self.alive}>"
72
- )
73
-
74
- @property
75
- def game(self) -> "Game":
76
- if game := self.__game_ref():
77
- return game
78
- raise ValueError("Game not exist")
79
-
80
- @functools.cached_property
81
- def user_id(self) -> str:
82
- return self.__user.id
83
-
84
- @functools.cached_property
85
- def role_name(self) -> str:
86
- return role_name_conv[self.role]
87
-
88
- async def _fetch_member(self) -> None:
89
- member = await self.game.interface.get_member(
90
- SceneType.GROUP,
91
- self.game.group.id,
92
- self.user_id,
93
- )
94
- if member is None:
95
- member = await self.game.interface.get_member(
96
- SceneType.GUILD,
97
- self.game.group.id,
98
- self.user_id,
99
- )
100
-
101
- self._member = member
102
-
103
- @final
104
- @property
105
- def _member_nick(self) -> str | None:
106
- return self._member and (
107
- self._member.nick or self._member.user.nick or self._member.user.name
108
- )
109
-
110
- @final
111
- @property
112
- def name(self) -> str:
113
- return self._member_nick or self.user_id
114
-
115
- @final
116
- @property
117
- def colored_name(self) -> str:
118
- name = escape_tag(self.user_id)
119
-
120
- if self._member is None or (nick := self._member_nick) is None:
121
- name = f"<b><e>{name}</e></b>"
122
- else:
123
- name = f"<y>{nick}</y>(<b><e>{name}</e></b>)"
124
-
125
- if self._member is not None and self._member.user.avatar is not None:
126
- name = link(name, self._member.user.avatar)
127
-
128
- return name
129
-
130
- @final
131
- def _log(self, text: str) -> None:
132
- text = text.replace("\n", "\\n")
133
- logger.info(
134
- f"{self.game.colored_name} | "
135
- f"[<b><m>{self.role_name}</m></b>] "
136
- f"{self.colored_name} | {text}",
137
- )
138
-
139
- @final
140
- async def send(self, message: str | UniMessage) -> Receipt:
141
- if isinstance(message, str):
142
- message = UniMessage.text(message)
143
-
144
- self._log(f"<g>Send</g> | {escape_tag(str(message))}")
145
- return await message.send(target=self.__user, bot=self.bot)
146
-
147
- @final
148
- async def receive(self, prompt: str | UniMessage | None = None) -> UniMessage:
149
- if prompt:
150
- await self.send(prompt)
151
-
152
- result = await InputStore.fetch(self.user_id)
153
- self._log(f"<y>Recv</y> | {escape_tag(str(result))}")
154
- return result
155
-
156
- @final
157
- async def receive_text(self) -> str:
158
- return (await self.receive()).extract_plain_text()
159
-
160
- async def interact(self) -> None:
161
- return
162
-
163
- async def notify_role(self) -> None:
164
- await self._fetch_member()
165
- await self.send(f"⚙️你的身份: {role_emoji[self.role]}{self.role_name}")
166
-
167
- async def kill(self, reason: KillReason, *killers: "Player") -> bool:
168
- if self.alive:
169
- self.alive = False
170
- self.kill_info = KillInfo(reason=reason, killers=[p.name for p in killers])
171
- return True
172
-
173
- async def post_kill(self) -> None:
174
- self.killed.set()
175
-
176
- async def vote(self, players: "PlayerSet") -> "Player | None":
177
- await self.send(
178
- f"💫请选择需要投票的玩家:\n{players.show()}"
179
- f"\n\n🗳️发送编号选择玩家\n❌发送 “{STOP_COMMAND_PROMPT}” 弃票"
180
- f"\n\n限时1分钟,超时将视为弃票"
181
- )
182
-
183
- try:
184
- with anyio.fail_after(60):
185
- selected = await self._select_player(
186
- players,
187
- on_stop="⚠️你选择了弃票",
188
- on_index_error="⚠️输入错误: 请发送编号选择玩家",
189
- )
190
- except TimeoutError:
191
- selected = None
192
- await self.send("⚠️投票超时,将视为弃票")
193
-
194
- if selected is not None:
195
- await self.send(f"🔨投票的玩家: {selected.name}")
196
- return selected
197
-
198
- async def _check_selected(self, player: "Player") -> "Player | None":
199
- return player
200
-
201
- async def _select_player(
202
- self,
203
- players: "PlayerSet",
204
- *,
205
- on_stop: str | None = None,
206
- on_index_error: str | None = None,
207
- ) -> "Player | None":
208
- on_stop = on_stop or "ℹ️你选择了取消,回合结束"
209
- on_index_error = (
210
- on_index_error or f"⚠️输入错误: 请发送玩家编号或 “{STOP_COMMAND_PROMPT}”"
211
- )
212
- selected = None
213
-
214
- while selected is None:
215
- text = await self.receive_text()
216
- if text == STOP_COMMAND:
217
- if on_stop is not None:
218
- await self.send(on_stop)
219
- return None
220
- index = check_index(text, len(players))
221
- if index is None:
222
- await self.send(on_index_error)
223
- continue
224
- selected = await self._check_selected(players[index - 1])
225
-
226
- return selected
@@ -1,34 +0,0 @@
1
- nonebot_plugin_werewolf/__init__.py,sha256=CMvcf07CmixM1tCOtCNQ50ksjjU-W_HxdNQHRFXratM,931
2
- nonebot_plugin_werewolf/config.py,sha256=QKE_EomWI58L-LV6KvHth1C0n77jwZG9pFz_hMY4hjQ,1272
3
- nonebot_plugin_werewolf/constant.py,sha256=_ngw2xtXVZMTQXQ0gv4l9h4Lo1jq5v28fKLOGJ7G57o,1796
4
- nonebot_plugin_werewolf/exception.py,sha256=2F2kZsMaRIa7jOiIQJiM10K7Z59ouCpaZENcnEcEEXQ,398
5
- nonebot_plugin_werewolf/game.py,sha256=V0RBr1rP6cQOFiUBelxAysschx3HDv41PUZhf_Wi4-Y,19046
6
- nonebot_plugin_werewolf/models.py,sha256=ljWy6BaTVyIK4Ng-wUVRteBLZe2pQLf8l3yWFZzWXHQ,1505
7
- nonebot_plugin_werewolf/player_set.py,sha256=84hZOOAaPjTyZZDje6mNy7zm4G5UH2nGDq1pvDNFT9w,2538
8
- nonebot_plugin_werewolf/utils.py,sha256=ekqyjXndl0_Ih-4pTTMXPOp7WMezlxUY7Xd6DcFjgpk,4086
9
- nonebot_plugin_werewolf/matchers/__init__.py,sha256=BnzEDmW8n1wkyI-un0DYXt2k_6CFv6NE8itZ2daw4zQ,174
10
- nonebot_plugin_werewolf/matchers/depends.py,sha256=poMQJ7Mzd3IZFvh2MvnfYdnnb2c-r6XFK_IOr50PL3o,1321
11
- nonebot_plugin_werewolf/matchers/edit_preset.py,sha256=gKd1csoR9u4VoeulTtxUUgxsOdgB0SDC1FMxMRdgw5I,8087
12
- nonebot_plugin_werewolf/matchers/message_in_game.py,sha256=lW0TMC85B-g9wZQcL7Q-LQSYyvO4-uem3Ye1szX2hU8,837
13
- nonebot_plugin_werewolf/matchers/start_game.py,sha256=YM4VGKpV8GQ29SgPh0jvWUHnx8onAvx_m4RWyeuRxmc,10187
14
- nonebot_plugin_werewolf/matchers/superuser_ops.py,sha256=Xjsmwzkt6Y-M_QlQwUL0EXN_fDqEqKSM4fcLk9fTvDY,685
15
- nonebot_plugin_werewolf/matchers/poke/__init__.py,sha256=gYysvGjztN3iDQpX6v5nkPT195FXnk7fqP9kzByTES0,220
16
- nonebot_plugin_werewolf/matchers/poke/chronocat_poke.py,sha256=SrFN8dQELFVDR5US9sOcE2gaOnH7AFiRVVK2RNa-Y5o,4023
17
- nonebot_plugin_werewolf/matchers/poke/ob11_poke.py,sha256=LROxtbauw4xbB8UKglsx6b6hkKWs_17HmgK4NTXW1HY,2640
18
- nonebot_plugin_werewolf/players/__init__.py,sha256=djAI5XxR2I-XvnH-lVqX_YCHB_AiT-6jdmwFE1ffN_0,379
19
- nonebot_plugin_werewolf/players/can_shoot.py,sha256=Z0AR_jCfcU1ps5629sWB_mH8O_iVLy8-DyePgBfznNA,1814
20
- nonebot_plugin_werewolf/players/civilian.py,sha256=9m-bgzqHji-9Aejl2TnchSIRw_SZpKLqCGdaEWXhopc,155
21
- nonebot_plugin_werewolf/players/guard.py,sha256=gHPlIfBXtQ8MSoWvucIIq0XrJQx9KIIKIVl-jwAHhgc,1132
22
- nonebot_plugin_werewolf/players/hunter.py,sha256=q17IjSXt5knDAc49NbV0NCwNW7qASqODUNgC0L1zqeI,193
23
- nonebot_plugin_werewolf/players/idiot.py,sha256=jz13BN4BsYcmiZdTwSlXUm4yc0KR8GUmQmq2GI7_Kzo,1431
24
- nonebot_plugin_werewolf/players/joker.py,sha256=n_jlddGMpFJ0O0sc_1J6IybfPsPJSWeS4GC0S6IZoTk,826
25
- nonebot_plugin_werewolf/players/player.py,sha256=j6m75GxYx3dpsO1frfk48D6jFdSi8orqaIVB-jvRxU0,6962
26
- nonebot_plugin_werewolf/players/prophet.py,sha256=wrTR8BnktiZ8aEI4VzYa5kt4GXyFnyi5wZmCO933-rE,917
27
- nonebot_plugin_werewolf/players/werewolf.py,sha256=qi6OLWnTWhe2O_XYEb80n9x_4j05qjWU2IwnG3vpMuA,3273
28
- nonebot_plugin_werewolf/players/witch.py,sha256=FOM_MMKUjO6QpOQK9JvHq9zwa4GTVCVnW7UtPgT_BTw,2360
29
- nonebot_plugin_werewolf/players/wolfking.py,sha256=Y_G1eDdFYGTip5Pl9Sz0OvPsP0aiiFH8NkfGiFu7r1E,438
30
- nonebot_plugin_werewolf-1.1.7.dist-info/LICENSE,sha256=B_WbEqjGr6GYVNfEJPY31T1Opik7OtgOkhRs4Ig3e2M,1064
31
- nonebot_plugin_werewolf-1.1.7.dist-info/METADATA,sha256=lF1x5SYiaOUgjmow7_Kcb_eovQZbxvbN8dAJmc2aFkA,11990
32
- nonebot_plugin_werewolf-1.1.7.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
33
- nonebot_plugin_werewolf-1.1.7.dist-info/top_level.txt,sha256=wLTfg8sTKbH9lLT9LtU118C9cTspEBJareLsrYM52YA,24
34
- nonebot_plugin_werewolf-1.1.7.dist-info/RECORD,,