新增日志流程用以解决游戏状态的bug
This commit is contained in:
@@ -66,6 +66,7 @@ class WerewolfGame(BaseGame):
|
|||||||
# 提取参数
|
# 提取参数
|
||||||
_, args = CommandParser.extract_command_args(command)
|
_, args = CommandParser.extract_command_args(command)
|
||||||
args = args.strip()
|
args = args.strip()
|
||||||
|
logger.debug(f"狼人杀指令解析 - command: {command}, args: {args}")
|
||||||
|
|
||||||
# 没有参数,显示帮助
|
# 没有参数,显示帮助
|
||||||
if not args:
|
if not args:
|
||||||
@@ -74,6 +75,7 @@ class WerewolfGame(BaseGame):
|
|||||||
# 解析参数
|
# 解析参数
|
||||||
parts = args.split(maxsplit=1)
|
parts = args.split(maxsplit=1)
|
||||||
action = parts[0].lower()
|
action = parts[0].lower()
|
||||||
|
logger.debug(f"狼人杀指令解析 - parts: {parts}, action: {action}")
|
||||||
|
|
||||||
# 创建/加入/开始游戏
|
# 创建/加入/开始游戏
|
||||||
if action == 'open':
|
if action == 'open':
|
||||||
@@ -147,7 +149,9 @@ class WerewolfGame(BaseGame):
|
|||||||
"""
|
"""
|
||||||
state = self.db.get_game_state(chat_id, 0, 'werewolf')
|
state = self.db.get_game_state(chat_id, 0, 'werewolf')
|
||||||
if state:
|
if state:
|
||||||
|
logger.debug(f"获取游戏状态成功: chat_id={chat_id}, status={state['state_data'].get('status')}, phase={state['state_data'].get('phase')}")
|
||||||
return state['state_data']
|
return state['state_data']
|
||||||
|
logger.warning(f"获取游戏状态失败: chat_id={chat_id}, 状态不存在")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _save_game_state(self, chat_id: int, state_data: Dict):
|
def _save_game_state(self, chat_id: int, state_data: Dict):
|
||||||
@@ -157,6 +161,7 @@ class WerewolfGame(BaseGame):
|
|||||||
chat_id: 会话ID
|
chat_id: 会话ID
|
||||||
state_data: 状态数据
|
state_data: 状态数据
|
||||||
"""
|
"""
|
||||||
|
logger.debug(f"保存游戏状态: chat_id={chat_id}, status={state_data.get('status')}, phase={state_data.get('phase')}")
|
||||||
self.db.save_game_state(chat_id, 0, 'werewolf', state_data)
|
self.db.save_game_state(chat_id, 0, 'werewolf', state_data)
|
||||||
|
|
||||||
def _get_phase_description(self, phase: str) -> Dict[str, str]:
|
def _get_phase_description(self, phase: str) -> Dict[str, str]:
|
||||||
@@ -578,8 +583,10 @@ class WerewolfGame(BaseGame):
|
|||||||
Returns:
|
Returns:
|
||||||
提示消息
|
提示消息
|
||||||
"""
|
"""
|
||||||
|
logger.debug(f"处理技能 - chat_id: {chat_id}, user_id: {user_id}, skill: {skill}, target_id: {target_id}")
|
||||||
state_data = self._get_game_state(chat_id)
|
state_data = self._get_game_state(chat_id)
|
||||||
if not state_data:
|
if not state_data:
|
||||||
|
logger.warning(f"技能处理失败 - 未找到游戏状态: chat_id={chat_id}")
|
||||||
return "❌ 没有正在进行的游戏!"
|
return "❌ 没有正在进行的游戏!"
|
||||||
|
|
||||||
if state_data['status'] != 'playing':
|
if state_data['status'] != 'playing':
|
||||||
|
|||||||
Reference in New Issue
Block a user