nonebot-plugin-werewolf 1.1.2__py3-none-any.whl → 1.1.5__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 +9 -4
- nonebot_plugin_werewolf/config.py +11 -15
- nonebot_plugin_werewolf/constant.py +40 -3
- nonebot_plugin_werewolf/game.py +219 -181
- nonebot_plugin_werewolf/matchers/__init__.py +2 -0
- nonebot_plugin_werewolf/matchers/depends.py +38 -0
- nonebot_plugin_werewolf/matchers/message_in_game.py +25 -0
- nonebot_plugin_werewolf/matchers/poke/__init__.py +8 -0
- nonebot_plugin_werewolf/matchers/poke/chronocat_poke.py +117 -0
- nonebot_plugin_werewolf/matchers/poke/ob11_poke.py +80 -0
- nonebot_plugin_werewolf/matchers/start_game.py +202 -0
- nonebot_plugin_werewolf/player_set.py +37 -36
- nonebot_plugin_werewolf/players/__init__.py +10 -0
- nonebot_plugin_werewolf/players/can_shoot.py +53 -0
- nonebot_plugin_werewolf/players/civilian.py +7 -0
- nonebot_plugin_werewolf/players/guard.py +30 -0
- nonebot_plugin_werewolf/players/hunter.py +8 -0
- nonebot_plugin_werewolf/players/idiot.py +44 -0
- nonebot_plugin_werewolf/players/joker.py +21 -0
- nonebot_plugin_werewolf/players/player.py +233 -0
- nonebot_plugin_werewolf/players/prophet.py +22 -0
- nonebot_plugin_werewolf/players/werewolf.py +89 -0
- nonebot_plugin_werewolf/players/witch.py +66 -0
- nonebot_plugin_werewolf/players/wolfking.py +14 -0
- nonebot_plugin_werewolf/utils.py +58 -173
- {nonebot_plugin_werewolf-1.1.2.dist-info → nonebot_plugin_werewolf-1.1.5.dist-info}/METADATA +24 -4
- nonebot_plugin_werewolf-1.1.5.dist-info/RECORD +31 -0
- {nonebot_plugin_werewolf-1.1.2.dist-info → nonebot_plugin_werewolf-1.1.5.dist-info}/WHEEL +1 -1
- nonebot_plugin_werewolf/_timeout.py +0 -110
- nonebot_plugin_werewolf/matchers.py +0 -62
- nonebot_plugin_werewolf/ob11_ext.py +0 -72
- nonebot_plugin_werewolf/player.py +0 -462
- nonebot_plugin_werewolf-1.1.2.dist-info/RECORD +0 -16
- {nonebot_plugin_werewolf-1.1.2.dist-info → nonebot_plugin_werewolf-1.1.5.dist-info}/LICENSE +0 -0
- {nonebot_plugin_werewolf-1.1.2.dist-info → nonebot_plugin_werewolf-1.1.5.dist-info}/top_level.txt +0 -0
@@ -2,13 +2,14 @@ from nonebot import require
|
|
2
2
|
from nonebot.plugin import PluginMetadata, inherit_supported_adapters
|
3
3
|
|
4
4
|
require("nonebot_plugin_alconna")
|
5
|
-
require("
|
5
|
+
require("nonebot_plugin_uninfo")
|
6
6
|
require("nonebot_plugin_waiter")
|
7
7
|
|
8
8
|
from . import matchers as matchers
|
9
|
+
from . import players as players
|
9
10
|
from .config import Config
|
10
11
|
|
11
|
-
__version__ = "1.1.
|
12
|
+
__version__ = "1.1.5"
|
12
13
|
__plugin_meta__ = PluginMetadata(
|
13
14
|
name="狼人杀",
|
14
15
|
description="适用于 Nonebot2 的狼人杀插件",
|
@@ -18,8 +19,12 @@ __plugin_meta__ = PluginMetadata(
|
|
18
19
|
config=Config,
|
19
20
|
supported_adapters=inherit_supported_adapters(
|
20
21
|
"nonebot_plugin_alconna",
|
21
|
-
"
|
22
|
+
"nonebot_plugin_uninfo",
|
22
23
|
"nonebot_plugin_waiter",
|
23
24
|
),
|
24
|
-
extra={
|
25
|
+
extra={
|
26
|
+
"Author": "wyf7685",
|
27
|
+
"Version": __version__,
|
28
|
+
"Bug Tracker": "https://github.com/wyf7685/nonebot-plugin-werewolf/issues",
|
29
|
+
},
|
25
30
|
)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from typing import Literal, overload
|
1
|
+
from typing import Any, Literal, overload
|
2
2
|
|
3
3
|
from nonebot import get_plugin_config, logger
|
4
4
|
from nonebot.compat import PYDANTIC_V2
|
@@ -7,6 +7,8 @@ from typing_extensions import Self
|
|
7
7
|
|
8
8
|
from .constant import (
|
9
9
|
Role,
|
10
|
+
RolePresetConfig,
|
11
|
+
RolePresetDict,
|
10
12
|
default_priesthood_proirity,
|
11
13
|
default_role_preset,
|
12
14
|
default_werewolf_priority,
|
@@ -18,12 +20,12 @@ else:
|
|
18
20
|
from pydantic import root_validator
|
19
21
|
|
20
22
|
@overload
|
21
|
-
def model_validator(*, mode: Literal["before"]): ... # noqa:
|
23
|
+
def model_validator(*, mode: Literal["before"]) -> Any: ... # noqa: ANN401
|
22
24
|
|
23
25
|
@overload
|
24
|
-
def model_validator(*, mode: Literal["after"]): ... # noqa:
|
26
|
+
def model_validator(*, mode: Literal["after"]) -> Any: ... # noqa: ANN401
|
25
27
|
|
26
|
-
def model_validator(*, mode: Literal["before", "after"]):
|
28
|
+
def model_validator(*, mode: Literal["before", "after"]) -> Any:
|
27
29
|
return root_validator(
|
28
30
|
pre=mode == "before", # pyright: ignore[reportArgumentType]
|
29
31
|
allow_reuse=True,
|
@@ -31,16 +33,10 @@ else:
|
|
31
33
|
|
32
34
|
|
33
35
|
class PluginConfig(BaseModel):
|
34
|
-
enable_poke: bool =
|
35
|
-
role_preset:
|
36
|
-
|
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
|
-
)
|
36
|
+
enable_poke: bool = True
|
37
|
+
role_preset: RolePresetConfig = default_role_preset.copy()
|
38
|
+
werewolf_priority: list[Role] = default_werewolf_priority.copy()
|
39
|
+
priesthood_proirity: list[Role] = default_priesthood_proirity.copy()
|
44
40
|
joker_probability: float = Field(default=0.0, ge=0.0, le=1.0)
|
45
41
|
|
46
42
|
@model_validator(mode="after")
|
@@ -72,7 +68,7 @@ class PluginConfig(BaseModel):
|
|
72
68
|
|
73
69
|
return self
|
74
70
|
|
75
|
-
def get_role_preset(self) ->
|
71
|
+
def get_role_preset(self) -> RolePresetDict:
|
76
72
|
if isinstance(self.role_preset, list):
|
77
73
|
self.role_preset = {i[0]: i[1:] for i in self.role_preset}
|
78
74
|
return self.role_preset
|
@@ -4,8 +4,17 @@ import dataclasses
|
|
4
4
|
from enum import Enum, auto
|
5
5
|
from typing import TYPE_CHECKING
|
6
6
|
|
7
|
+
import nonebot
|
8
|
+
|
7
9
|
if TYPE_CHECKING:
|
8
|
-
from .
|
10
|
+
from .players import Player
|
11
|
+
|
12
|
+
|
13
|
+
COMMAND_START = next(
|
14
|
+
iter(sorted(nonebot.get_driver().config.command_start, key=len)), ""
|
15
|
+
)
|
16
|
+
STOP_COMMAND_PROMPT = f"{COMMAND_START}stop"
|
17
|
+
STOP_COMMAND = "{{stop}}"
|
9
18
|
|
10
19
|
|
11
20
|
class Role(Enum):
|
@@ -49,11 +58,24 @@ class GameStatus(Enum):
|
|
49
58
|
@dataclasses.dataclass
|
50
59
|
class GameState:
|
51
60
|
day: int
|
61
|
+
"""当前天数记录, 不会被 `reset()` 重置"""
|
52
62
|
killed: Player | None = None
|
53
|
-
|
63
|
+
"""当晚狼人击杀目标, `None` 则为空刀"""
|
64
|
+
shoot: Player | None = None
|
65
|
+
"""当前执行射杀操作的玩家"""
|
54
66
|
antidote: set[Player] = dataclasses.field(default_factory=set)
|
67
|
+
"""当晚女巫使用解药的目标"""
|
55
68
|
poison: set[Player] = dataclasses.field(default_factory=set)
|
69
|
+
"""当晚使用了毒药的女巫"""
|
56
70
|
protected: set[Player] = dataclasses.field(default_factory=set)
|
71
|
+
"""当晚守卫保护的目标"""
|
72
|
+
|
73
|
+
def reset(self) -> None:
|
74
|
+
self.killed = None
|
75
|
+
self.shoot = None
|
76
|
+
self.antidote = set()
|
77
|
+
self.poison = set()
|
78
|
+
self.protected = set()
|
57
79
|
|
58
80
|
|
59
81
|
role_name_conv: dict[Role | RoleGroup, str] = {
|
@@ -71,7 +93,22 @@ role_name_conv: dict[Role | RoleGroup, str] = {
|
|
71
93
|
RoleGroup.Others: "其他",
|
72
94
|
}
|
73
95
|
|
74
|
-
|
96
|
+
role_emoji: dict[Role, str] = {
|
97
|
+
Role.Werewolf: "🐺",
|
98
|
+
Role.WolfKing: "🐺👑",
|
99
|
+
Role.Prophet: "🔮",
|
100
|
+
Role.Witch: "🧙♀️",
|
101
|
+
Role.Hunter: "🕵️",
|
102
|
+
Role.Guard: "🛡️",
|
103
|
+
Role.Idiot: "👨🏻🦲",
|
104
|
+
Role.Joker: "🤡",
|
105
|
+
Role.Civilian: "👨🏻🌾",
|
106
|
+
}
|
107
|
+
|
108
|
+
RolePresetDict = dict[int, tuple[int, int, int]]
|
109
|
+
RolePresetConfig = RolePresetDict | list[tuple[int, int, int, int]]
|
110
|
+
|
111
|
+
default_role_preset: RolePresetDict = {
|
75
112
|
# 总人数: (狼, 神, 民)
|
76
113
|
6: (1, 2, 3),
|
77
114
|
7: (2, 2, 3),
|