修复狼人投票bug
This commit is contained in:
@@ -373,6 +373,22 @@ if game_type == 'werewolf':
|
||||
|
||||
- 状态:未确认
|
||||
|
||||
[2025-11-10_10:36:39]
|
||||
- 已修改:
|
||||
1. games/werewolf.py - 修复狼人投票流程与阶段推进
|
||||
|
||||
- 更改:
|
||||
1. `_wolf_kill()` 读取 `wolf_votes` 时统一转换为整数键,存储与统计均使用整数
|
||||
2. `_wolf_kill()`、`_seer_check()`、`_witch_save()`、`_witch_poison()`、`_witch_pass()` 中的 `_advance_phase` 调用改为 `await`
|
||||
|
||||
- 原因:
|
||||
修复狼人投票完成后仍判定未投票、平安夜提示错误及阶段推进信息显示 `<coroutine>` 的问题
|
||||
|
||||
- 阻碍因素:
|
||||
无
|
||||
|
||||
- 状态:未确认
|
||||
|
||||
# 最终审查
|
||||
|
||||
待审查阶段完成...
|
||||
|
||||
@@ -744,8 +744,8 @@ class WerewolfGame(BaseGame):
|
||||
|
||||
# 记录投票(允许改票)
|
||||
wolf_votes = state_data.get('wolf_votes', {})
|
||||
wolf_votes = {str(k): v for k, v in wolf_votes.items()}
|
||||
wolf_votes[str(player['user_id'])] = target_id
|
||||
wolf_votes = {int(k): v for k, v in wolf_votes.items()}
|
||||
wolf_votes[player['user_id']] = target_id
|
||||
state_data['wolf_votes'] = wolf_votes
|
||||
self._save_game_state(chat_id, state_data)
|
||||
|
||||
@@ -756,7 +756,7 @@ class WerewolfGame(BaseGame):
|
||||
alive_wolves.append(p['user_id'])
|
||||
|
||||
# 检查是否所有狼人都已投票
|
||||
voted_wolves = {int(k) for k in wolf_votes.keys()}
|
||||
voted_wolves = set(wolf_votes.keys())
|
||||
all_wolves = set(alive_wolves)
|
||||
|
||||
if not all_wolves.issubset(voted_wolves):
|
||||
@@ -794,7 +794,7 @@ class WerewolfGame(BaseGame):
|
||||
await self._send_to_player(p['user_id'], 空刀_msg, sender="系统")
|
||||
|
||||
# 自动推进到下一阶段
|
||||
next_phase_msg = self._advance_phase(chat_id, state_data)
|
||||
next_phase_msg = await self._advance_phase(chat_id, state_data)
|
||||
|
||||
return f"✅ 狼人投票完成{next_phase_msg}"
|
||||
|
||||
@@ -831,7 +831,7 @@ class WerewolfGame(BaseGame):
|
||||
await self._send_to_player(p['user_id'], vote_msg, sender="系统")
|
||||
|
||||
# 自动推进到下一阶段
|
||||
next_phase_msg = self._advance_phase(chat_id, state_data)
|
||||
next_phase_msg = await self._advance_phase(chat_id, state_data)
|
||||
|
||||
# 群消息不透露击杀目标
|
||||
return f"✅ 狼人投票完成{next_phase_msg}"
|
||||
@@ -880,7 +880,7 @@ class WerewolfGame(BaseGame):
|
||||
await self._send_to_player(player['user_id'], msg, sender="系统")
|
||||
|
||||
# 自动推进到下一阶段
|
||||
next_phase_msg = self._advance_phase(chat_id, state_data)
|
||||
next_phase_msg = await self._advance_phase(chat_id, state_data)
|
||||
|
||||
return f"✅ 验人成功!已私聊发送结果{next_phase_msg}"
|
||||
|
||||
@@ -925,7 +925,7 @@ class WerewolfGame(BaseGame):
|
||||
self._save_game_state(chat_id, state_data)
|
||||
|
||||
# 自动推进到下一阶段
|
||||
next_phase_msg = self._advance_phase(chat_id, state_data)
|
||||
next_phase_msg = await self._advance_phase(chat_id, state_data)
|
||||
|
||||
return f"✅ 救人成功:救了{target_id}号玩家{next_phase_msg}"
|
||||
|
||||
@@ -1017,7 +1017,7 @@ class WerewolfGame(BaseGame):
|
||||
return f"❌ 当前不是女巫行动阶段!当前阶段:{self._get_phase_description(current_phase)['name']}"
|
||||
|
||||
# 自动推进到下一阶段(使用 game_chat_id)
|
||||
next_phase_msg = self._advance_phase(game_chat_id, state_data)
|
||||
next_phase_msg = await self._advance_phase(game_chat_id, state_data)
|
||||
|
||||
return f"✅ 女巫选择跳过,不行动{next_phase_msg}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user