Merge pull request #1316 from Kaushal-26/fix-werewolf-game

fix: Werewolf Game
This commit is contained in:
garylin2099 2024-06-04 21:23:04 +08:00 committed by GitHub
commit 5e8bd10517
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 4 additions and 0 deletions

View file

@ -86,6 +86,7 @@ class BasePlayer(Role):
# FIXME: hard code to split, restricted为"Moderator"或"Moderator, 角色profile"
# Moderator加密发给自己的意味着要执行角色的特殊动作
self.rc.todo = self.special_actions[0]()
return True
async def _act(self):
# todo为_think时确定的有两种情况Speak或Protect

View file

@ -171,6 +171,7 @@ class Moderator(BasePlayer):
else:
# 上一轮消息是游戏角色的发言,解析角色的发言
self.rc.todo = ParseSpeak()
return True
def _init_fields_from_obj(self, obs: dict[str, Union[int, str, list[str]]]):
self.game_setup = obs.get("game_setup", "")

View file

@ -13,3 +13,4 @@ class Werewolf(BasePlayer):
await super()._think()
if isinstance(self.rc.todo, Speak):
self.rc.todo = Impersonate()
return True

View file

@ -26,3 +26,4 @@ class Witch(BasePlayer):
self.rc.todo = Poison()
else:
raise ValueError("Moderator's instructions must include save or poison keyword")
return True