nonebot-plugin-werewolf 1.1.5__py3-none-any.whl → 1.1.7__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.
- nonebot_plugin_werewolf/__init__.py +2 -1
- nonebot_plugin_werewolf/config.py +21 -58
- nonebot_plugin_werewolf/constant.py +14 -74
- nonebot_plugin_werewolf/exception.py +1 -1
- nonebot_plugin_werewolf/game.py +217 -226
- nonebot_plugin_werewolf/matchers/__init__.py +2 -0
- nonebot_plugin_werewolf/matchers/depends.py +17 -5
- nonebot_plugin_werewolf/matchers/edit_preset.py +263 -0
- nonebot_plugin_werewolf/matchers/message_in_game.py +8 -3
- nonebot_plugin_werewolf/matchers/start_game.py +140 -48
- nonebot_plugin_werewolf/matchers/superuser_ops.py +24 -0
- nonebot_plugin_werewolf/models.py +73 -0
- nonebot_plugin_werewolf/player_set.py +1 -1
- nonebot_plugin_werewolf/players/can_shoot.py +4 -3
- nonebot_plugin_werewolf/players/civilian.py +1 -1
- nonebot_plugin_werewolf/players/guard.py +2 -1
- nonebot_plugin_werewolf/players/hunter.py +1 -1
- nonebot_plugin_werewolf/players/idiot.py +1 -1
- nonebot_plugin_werewolf/players/joker.py +6 -2
- nonebot_plugin_werewolf/players/player.py +18 -25
- nonebot_plugin_werewolf/players/prophet.py +2 -1
- nonebot_plugin_werewolf/players/werewolf.py +25 -26
- nonebot_plugin_werewolf/players/witch.py +2 -1
- nonebot_plugin_werewolf/players/wolfking.py +1 -1
- nonebot_plugin_werewolf/utils.py +69 -5
- {nonebot_plugin_werewolf-1.1.5.dist-info → nonebot_plugin_werewolf-1.1.7.dist-info}/METADATA +71 -67
- nonebot_plugin_werewolf-1.1.7.dist-info/RECORD +34 -0
- {nonebot_plugin_werewolf-1.1.5.dist-info → nonebot_plugin_werewolf-1.1.7.dist-info}/WHEEL +1 -1
- nonebot_plugin_werewolf-1.1.5.dist-info/RECORD +0 -31
- {nonebot_plugin_werewolf-1.1.5.dist-info → nonebot_plugin_werewolf-1.1.7.dist-info}/LICENSE +0 -0
- {nonebot_plugin_werewolf-1.1.5.dist-info → nonebot_plugin_werewolf-1.1.7.dist-info}/top_level.txt +0 -0
@@ -1,7 +1,8 @@
|
|
1
1
|
from nonebot_plugin_alconna.uniseg import UniMessage
|
2
2
|
from typing_extensions import override
|
3
3
|
|
4
|
-
from ..constant import STOP_COMMAND_PROMPT
|
4
|
+
from ..constant import STOP_COMMAND_PROMPT
|
5
|
+
from ..models import KillReason
|
5
6
|
from .player import Player
|
6
7
|
|
7
8
|
|
@@ -13,9 +14,9 @@ class CanShoot(Player):
|
|
13
14
|
return await super().post_kill()
|
14
15
|
|
15
16
|
await self.game.send(
|
16
|
-
UniMessage.text(
|
17
|
+
UniMessage.text("🕵️玩家 ")
|
17
18
|
.at(self.user_id)
|
18
|
-
.text(
|
19
|
+
.text(" 死了\n请在私聊决定射杀目标...")
|
19
20
|
)
|
20
21
|
|
21
22
|
self.game.state.shoot = None
|
@@ -1,7 +1,8 @@
|
|
1
1
|
from nonebot_plugin_alconna.uniseg import UniMessage
|
2
2
|
from typing_extensions import override
|
3
3
|
|
4
|
-
from ..constant import STOP_COMMAND_PROMPT
|
4
|
+
from ..constant import STOP_COMMAND_PROMPT
|
5
|
+
from ..models import Role, RoleGroup
|
5
6
|
from .player import Player
|
6
7
|
|
7
8
|
|
@@ -5,7 +5,7 @@ from typing import TYPE_CHECKING
|
|
5
5
|
from nonebot_plugin_alconna.uniseg import UniMessage
|
6
6
|
from typing_extensions import override
|
7
7
|
|
8
|
-
from ..
|
8
|
+
from ..models import KillReason, Role, RoleGroup
|
9
9
|
from .player import Player
|
10
10
|
|
11
11
|
if TYPE_CHECKING:
|
@@ -1,7 +1,9 @@
|
|
1
|
+
from typing import TYPE_CHECKING
|
2
|
+
|
1
3
|
from typing_extensions import override
|
2
4
|
|
3
|
-
from ..constant import GameStatus, KillReason, Role, RoleGroup
|
4
5
|
from ..exception import GameFinished
|
6
|
+
from ..models import GameStatus, KillReason, Role, RoleGroup
|
5
7
|
from .player import Player
|
6
8
|
|
7
9
|
|
@@ -16,6 +18,8 @@ class Joker(Player):
|
|
16
18
|
async def kill(self, reason: KillReason, *killers: Player) -> bool:
|
17
19
|
await super().kill(reason, *killers)
|
18
20
|
if reason == KillReason.Vote:
|
19
|
-
|
21
|
+
if TYPE_CHECKING:
|
22
|
+
assert self.kill_info is not None
|
23
|
+
self.game.killed_players.append((self.name, self.kill_info))
|
20
24
|
raise GameFinished(GameStatus.Joker)
|
21
25
|
return True
|
@@ -1,26 +1,18 @@
|
|
1
1
|
import functools
|
2
2
|
import weakref
|
3
3
|
from collections.abc import Callable
|
4
|
-
from dataclasses import dataclass
|
5
4
|
from typing import TYPE_CHECKING, ClassVar, Final, TypeVar, final
|
6
5
|
|
7
6
|
import anyio
|
7
|
+
import nonebot
|
8
8
|
from nonebot.adapters import Bot
|
9
|
-
from nonebot.log import logger
|
10
9
|
from nonebot.utils import escape_tag
|
11
10
|
from nonebot_plugin_alconna.uniseg import Receipt, Target, UniMessage
|
12
11
|
from nonebot_plugin_uninfo import SceneType
|
13
12
|
|
14
|
-
from ..constant import
|
15
|
-
|
16
|
-
|
17
|
-
KillReason,
|
18
|
-
Role,
|
19
|
-
RoleGroup,
|
20
|
-
role_emoji,
|
21
|
-
role_name_conv,
|
22
|
-
)
|
23
|
-
from ..utils import InputStore, as_player_set, check_index, link
|
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
|
24
16
|
|
25
17
|
if TYPE_CHECKING:
|
26
18
|
from ..game import Game
|
@@ -29,11 +21,7 @@ if TYPE_CHECKING:
|
|
29
21
|
|
30
22
|
_P = TypeVar("_P", bound=type["Player"])
|
31
23
|
|
32
|
-
|
33
|
-
@dataclass
|
34
|
-
class KillInfo:
|
35
|
-
reason: KillReason
|
36
|
-
killers: "PlayerSet"
|
24
|
+
logger = nonebot.logger.opt(colors=True)
|
37
25
|
|
38
26
|
|
39
27
|
class Player:
|
@@ -140,9 +128,9 @@ class Player:
|
|
140
128
|
return name
|
141
129
|
|
142
130
|
@final
|
143
|
-
|
131
|
+
def _log(self, text: str) -> None:
|
144
132
|
text = text.replace("\n", "\\n")
|
145
|
-
logger.
|
133
|
+
logger.info(
|
146
134
|
f"{self.game.colored_name} | "
|
147
135
|
f"[<b><m>{self.role_name}</m></b>] "
|
148
136
|
f"{self.colored_name} | {text}",
|
@@ -153,7 +141,7 @@ class Player:
|
|
153
141
|
if isinstance(message, str):
|
154
142
|
message = UniMessage.text(message)
|
155
143
|
|
156
|
-
|
144
|
+
self._log(f"<g>Send</g> | {escape_tag(str(message))}")
|
157
145
|
return await message.send(target=self.__user, bot=self.bot)
|
158
146
|
|
159
147
|
@final
|
@@ -162,7 +150,7 @@ class Player:
|
|
162
150
|
await self.send(prompt)
|
163
151
|
|
164
152
|
result = await InputStore.fetch(self.user_id)
|
165
|
-
|
153
|
+
self._log(f"<y>Recv</y> | {escape_tag(str(result))}")
|
166
154
|
return result
|
167
155
|
|
168
156
|
@final
|
@@ -177,8 +165,9 @@ class Player:
|
|
177
165
|
await self.send(f"⚙️你的身份: {role_emoji[self.role]}{self.role_name}")
|
178
166
|
|
179
167
|
async def kill(self, reason: KillReason, *killers: "Player") -> bool:
|
180
|
-
self.alive
|
181
|
-
|
168
|
+
if self.alive:
|
169
|
+
self.alive = False
|
170
|
+
self.kill_info = KillInfo(reason=reason, killers=[p.name for p in killers])
|
182
171
|
return True
|
183
172
|
|
184
173
|
async def post_kill(self) -> None:
|
@@ -213,9 +202,13 @@ class Player:
|
|
213
202
|
self,
|
214
203
|
players: "PlayerSet",
|
215
204
|
*,
|
216
|
-
on_stop: str | None =
|
217
|
-
on_index_error: str
|
205
|
+
on_stop: str | None = None,
|
206
|
+
on_index_error: str | None = None,
|
218
207
|
) -> "Player | None":
|
208
|
+
on_stop = on_stop or "ℹ️你选择了取消,回合结束"
|
209
|
+
on_index_error = (
|
210
|
+
on_index_error or f"⚠️输入错误: 请发送玩家编号或 “{STOP_COMMAND_PROMPT}”"
|
211
|
+
)
|
219
212
|
selected = None
|
220
213
|
|
221
214
|
while selected is None:
|
@@ -1,7 +1,8 @@
|
|
1
1
|
from nonebot_plugin_alconna.uniseg import UniMessage
|
2
2
|
from typing_extensions import override
|
3
3
|
|
4
|
-
from ..constant import STOP_COMMAND_PROMPT
|
4
|
+
from ..constant import STOP_COMMAND_PROMPT
|
5
|
+
from ..models import Role, RoleGroup
|
5
6
|
from .player import Player
|
6
7
|
|
7
8
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
from typing import TYPE_CHECKING
|
2
2
|
|
3
3
|
import anyio
|
4
|
-
from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream
|
5
4
|
from nonebot_plugin_alconna.uniseg import UniMessage
|
6
5
|
from typing_extensions import override
|
7
6
|
|
8
|
-
from ..constant import STOP_COMMAND, STOP_COMMAND_PROMPT
|
9
|
-
from ..
|
7
|
+
from ..constant import STOP_COMMAND, STOP_COMMAND_PROMPT
|
8
|
+
from ..models import Role, RoleGroup
|
9
|
+
from ..utils import ObjectStream, check_index
|
10
10
|
from .player import Player
|
11
11
|
|
12
12
|
if TYPE_CHECKING:
|
@@ -15,6 +15,8 @@ if TYPE_CHECKING:
|
|
15
15
|
|
16
16
|
@Player.register_role(Role.Werewolf, RoleGroup.Werewolf)
|
17
17
|
class Werewolf(Player):
|
18
|
+
stream: ObjectStream[str | UniMessage]
|
19
|
+
|
18
20
|
@override
|
19
21
|
async def notify_role(self) -> None:
|
20
22
|
await super().notify_role()
|
@@ -25,12 +27,7 @@ class Werewolf(Player):
|
|
25
27
|
+ "\n".join(f" {p.role_name}: {p.name}" for p in partners)
|
26
28
|
)
|
27
29
|
|
28
|
-
async def _handle_interact(
|
29
|
-
self,
|
30
|
-
players: "PlayerSet",
|
31
|
-
stream: MemoryObjectSendStream[str | UniMessage],
|
32
|
-
finished: anyio.Event,
|
33
|
-
) -> None:
|
30
|
+
async def _handle_interact(self, players: "PlayerSet") -> None:
|
34
31
|
self.selected = None
|
35
32
|
|
36
33
|
while True:
|
@@ -41,25 +38,25 @@ class Werewolf(Player):
|
|
41
38
|
self.selected = players[index - 1]
|
42
39
|
msg = f"当前选择玩家: {self.selected.name}"
|
43
40
|
await self.send(f"🎯{msg}\n发送 “{STOP_COMMAND_PROMPT}” 结束回合")
|
44
|
-
await stream.send(f"📝队友 {self.name} {msg}")
|
41
|
+
await self.stream.send(f"📝队友 {self.name} {msg}")
|
45
42
|
if text == STOP_COMMAND:
|
46
43
|
if self.selected is not None:
|
47
44
|
await self.send("✅你已结束当前回合")
|
48
|
-
await stream.send(f"📝队友 {self.name} 结束当前回合")
|
49
|
-
|
45
|
+
await self.stream.send(f"📝队友 {self.name} 结束当前回合")
|
46
|
+
self.stream.close()
|
50
47
|
return
|
51
48
|
await self.send("⚠️当前未选择玩家,无法结束回合")
|
52
49
|
else:
|
53
|
-
await stream.send(UniMessage
|
50
|
+
await self.stream.send(UniMessage(f"💬队友 {self.name}:\n") + input_msg)
|
51
|
+
|
52
|
+
async def _handle_broadcast(self, partners: "PlayerSet") -> None:
|
53
|
+
while not self.stream.closed:
|
54
|
+
try:
|
55
|
+
message = await self.stream.recv()
|
56
|
+
except anyio.EndOfStream:
|
57
|
+
return
|
54
58
|
|
55
|
-
|
56
|
-
self,
|
57
|
-
partners: "PlayerSet",
|
58
|
-
stream: MemoryObjectReceiveStream[str | UniMessage],
|
59
|
-
finished: anyio.Event,
|
60
|
-
) -> None:
|
61
|
-
while not finished.is_set() or stream.statistics().tasks_waiting_receive:
|
62
|
-
await partners.broadcast(await stream.receive())
|
59
|
+
await partners.broadcast(message)
|
63
60
|
|
64
61
|
@override
|
65
62
|
async def interact(self) -> None:
|
@@ -81,9 +78,11 @@ class Werewolf(Player):
|
|
81
78
|
.text("\n\n⚠️意见未统一将空刀")
|
82
79
|
)
|
83
80
|
|
84
|
-
|
85
|
-
finished = anyio.Event()
|
81
|
+
self.stream = ObjectStream[str | UniMessage](8)
|
86
82
|
|
87
|
-
|
88
|
-
|
89
|
-
|
83
|
+
try:
|
84
|
+
async with anyio.create_task_group() as tg:
|
85
|
+
tg.start_soon(self._handle_interact, players)
|
86
|
+
tg.start_soon(self._handle_broadcast, partners)
|
87
|
+
finally:
|
88
|
+
del self.stream
|
@@ -1,7 +1,8 @@
|
|
1
1
|
from nonebot_plugin_alconna.uniseg import UniMessage
|
2
2
|
from typing_extensions import override
|
3
3
|
|
4
|
-
from ..constant import STOP_COMMAND_PROMPT
|
4
|
+
from ..constant import STOP_COMMAND_PROMPT
|
5
|
+
from ..models import Role, RoleGroup
|
5
6
|
from ..utils import as_player_set
|
6
7
|
from .player import Player
|
7
8
|
|
nonebot_plugin_werewolf/utils.py
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
import functools
|
2
|
+
import itertools
|
2
3
|
from collections import defaultdict
|
3
|
-
from typing import TYPE_CHECKING, Any, ClassVar, TypeVar
|
4
|
+
from typing import TYPE_CHECKING, Any, ClassVar, Generic, TypeVar
|
4
5
|
|
5
6
|
import anyio
|
7
|
+
import anyio.streams.memory
|
6
8
|
from nonebot_plugin_alconna import UniMessage
|
7
9
|
from nonebot_plugin_uninfo import Session
|
8
10
|
|
11
|
+
from .constant import STOP_COMMAND
|
12
|
+
|
9
13
|
if TYPE_CHECKING:
|
10
14
|
from .player_set import PlayerSet
|
11
15
|
from .players import Player
|
@@ -53,22 +57,37 @@ class InputStore:
|
|
53
57
|
locks: ClassVar[dict[str, anyio.Lock]] = defaultdict(anyio.Lock)
|
54
58
|
tasks: ClassVar[dict[str, _InputTask]] = {}
|
55
59
|
|
60
|
+
@staticmethod
|
61
|
+
def _key(user_id: str, group_id: str | None) -> str:
|
62
|
+
return f"{group_id}_{user_id}"
|
63
|
+
|
56
64
|
@classmethod
|
57
65
|
async def fetch(cls, user_id: str, group_id: str | None = None) -> UniMessage[Any]:
|
58
|
-
key =
|
66
|
+
key = cls._key(user_id, group_id)
|
59
67
|
async with cls.locks[key]:
|
60
68
|
cls.tasks[key] = task = _InputTask()
|
61
|
-
|
69
|
+
try:
|
70
|
+
return await task.wait()
|
71
|
+
finally:
|
72
|
+
cls.tasks.pop(key, None)
|
73
|
+
|
74
|
+
@classmethod
|
75
|
+
async def fetch_until_stop(cls, user_id: str, group_id: str | None = None) -> None:
|
76
|
+
while True:
|
77
|
+
msg = await cls.fetch(user_id, group_id)
|
78
|
+
if msg.extract_plain_text().strip() == STOP_COMMAND:
|
79
|
+
return
|
62
80
|
|
63
81
|
@classmethod
|
64
82
|
def put(cls, msg: UniMessage, user_id: str, group_id: str | None = None) -> None:
|
65
|
-
key =
|
83
|
+
key = cls._key(user_id, group_id)
|
66
84
|
if task := cls.tasks.pop(key, None):
|
67
85
|
task.set(msg)
|
68
86
|
|
69
87
|
@classmethod
|
70
88
|
def cleanup(cls, players: list[str], group_id: str) -> None:
|
71
|
-
for
|
89
|
+
for p, g in itertools.product(players, (group_id, None)):
|
90
|
+
key = cls._key(p, g)
|
72
91
|
if key in cls.locks:
|
73
92
|
del cls.locks[key]
|
74
93
|
if key in cls.tasks:
|
@@ -84,3 +103,48 @@ def cached_player_set() -> type["PlayerSet"]:
|
|
84
103
|
|
85
104
|
def as_player_set(*player: "Player") -> "PlayerSet":
|
86
105
|
return cached_player_set()(player)
|
106
|
+
|
107
|
+
|
108
|
+
class ObjectStream(Generic[T]):
|
109
|
+
__unset: Any = object()
|
110
|
+
_send: anyio.streams.memory.MemoryObjectSendStream[T]
|
111
|
+
_recv: anyio.streams.memory.MemoryObjectReceiveStream[T]
|
112
|
+
_closed: anyio.Event
|
113
|
+
|
114
|
+
def __init__(self, max_buffer_size: float = 0) -> None:
|
115
|
+
self._send, self._recv = anyio.create_memory_object_stream(max_buffer_size)
|
116
|
+
self._closed = anyio.Event()
|
117
|
+
|
118
|
+
async def send(self, obj: T) -> None:
|
119
|
+
await self._send.send(obj)
|
120
|
+
|
121
|
+
async def recv(self) -> T:
|
122
|
+
result = self.__unset
|
123
|
+
|
124
|
+
async def _recv() -> None:
|
125
|
+
nonlocal result
|
126
|
+
result = await self._recv.receive()
|
127
|
+
tg.cancel_scope.cancel()
|
128
|
+
|
129
|
+
async def _cancel() -> None:
|
130
|
+
await self._closed.wait()
|
131
|
+
tg.cancel_scope.cancel()
|
132
|
+
|
133
|
+
async with anyio.create_task_group() as tg:
|
134
|
+
tg.start_soon(_recv)
|
135
|
+
tg.start_soon(_cancel)
|
136
|
+
|
137
|
+
if result is self.__unset:
|
138
|
+
raise anyio.EndOfStream
|
139
|
+
|
140
|
+
return result
|
141
|
+
|
142
|
+
def close(self) -> None:
|
143
|
+
self._closed.set()
|
144
|
+
|
145
|
+
@property
|
146
|
+
def closed(self) -> bool:
|
147
|
+
return self._closed.is_set()
|
148
|
+
|
149
|
+
async def wait_closed(self) -> None:
|
150
|
+
await self._closed.wait()
|
{nonebot_plugin_werewolf-1.1.5.dist-info → nonebot_plugin_werewolf-1.1.7.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: nonebot-plugin-werewolf
|
3
|
-
Version: 1.1.
|
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
|
[](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
|
[](https://registry.nonebot.dev/plugin/nonebot-plugin-werewolf:nonebot_plugin_werewolf)
|
48
50
|
[](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
|
-
`
|
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
|
168
|
-
| 7
|
169
|
-
| 8
|
170
|
-
| 9
|
171
|
-
| 10
|
172
|
-
| 11
|
173
|
-
| 12
|
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
|
-
|
183
|
+
职业预设可以通过命令 `狼人杀预设 职业 ...` 修改
|
176
184
|
|
177
185
|
<details>
|
178
186
|
<summary>示例</summary>
|
179
187
|
|
180
|
-
|
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
|
-
|
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
|
-
|
200
|
+
职业分配优先级可以通过命令 `狼人杀预设 狼人/神职` 修改
|
202
201
|
|
203
202
|
<details>
|
204
203
|
<summary>示例</summary>
|
205
204
|
|
206
|
-
####
|
205
|
+
#### 命令 `狼人杀预设 狼人`
|
207
206
|
|
208
|
-
|
209
|
-
werewolf__werewolf_priority=[1, 2, 1, 1]
|
210
|
-
```
|
207
|
+
- 命令: `狼人杀预设 狼人 狼 狼王 狼 狼`
|
211
208
|
|
212
|
-
|
209
|
+
- 上述命令指定狼人的职业优先级为 `狼人`, `狼王`, `狼人`, `狼人`
|
213
210
|
|
214
|
-
####
|
211
|
+
#### 命令 `狼人杀预设 神职`
|
215
212
|
|
216
|
-
|
217
|
-
werewolf__priesthood_proirity=[11, 12, 13, 14, 15]
|
218
|
-
```
|
213
|
+
- 命令: `狼人杀预设 神职 预言家 女巫 猎人 守卫 白痴`
|
219
214
|
|
220
|
-
|
215
|
+
- 上述命令指定狼人的职业优先级为 `预言家`, `女巫`, `猎人`, `守卫`, `白痴`
|
221
216
|
|
222
|
-
|
217
|
+
> [!note]
|
218
|
+
>
|
219
|
+
> 以上两条命令均支持交互式输入
|
220
|
+
>
|
221
|
+
> 例:向机器人发送命令 `狼人杀预设 狼人`,在接下来的一条消息中发送 `狼人 狼王 狼人 狼人`
|
222
|
+
>
|
223
|
+
> 其效果等同于以上描述中的单条命令 `狼人杀预设 狼人 狼人 狼王 狼人 狼人`
|
223
224
|
|
224
|
-
|
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
|
-
|
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 的支持
|