mirror of
https://github.com/LHY0125/Gobang-Game.git
synced 2026-06-29 08:55:53 +08:00
fix: 代码审查修复 — serde camelCase/CSP/TS检查/replay/undo/AI禁手/星位/未使用依赖
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -98,6 +98,14 @@ pub fn undo(steps: u32, state: State<AppState>) -> Result<(), String> {
|
||||
board = board.undo().map_err(|e| e.to_string())?;
|
||||
}
|
||||
|
||||
// 根据剩余步数修正当前颜色 (偶数 = 黑, 奇数 = 白)
|
||||
let corrected_color = match board.history().last() {
|
||||
Some(last_move) => last_move.color.opponent(),
|
||||
None => state.config.lock().map_err(|e| e.to_string())?.player_color,
|
||||
};
|
||||
*state.current_color.lock().map_err(|e| e.to_string())? = corrected_color;
|
||||
*state.game_over.lock().map_err(|e| e.to_string())? = false;
|
||||
|
||||
*board_opt = Some(board);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user