scense_game/wwwroot/game/api/game_restart.dspy

20 lines
661 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""W-08f 重新开始:任意状态 -> playing重置分数/关卡/时长/进度。"""
result = {'success': False, 'data': {}}
try:
user_id = await get_user()
session_id = params_kw.get('session_id', '')
if not session_id:
result['code'] = 400
result['error'] = '缺少 session_id'
else:
data = await game_restart_session(user_id, session_id)
result['success'] = True
result['data'] = data
except ValueError as e:
result['code'] = 400
result['error'] = str(e)
except Exception as e:
result['error'] = str(e)
return json.dumps(result, ensure_ascii=False, default=str)