mirror of
https://github.com/LHY0125/Gobang-Game.git
synced 2026-06-28 16:35:55 +08:00
chore: 删除未使用的 get_board IPC 命令,修复 clippy needless_range_loop 警告
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -110,23 +110,6 @@ pub fn undo(steps: u32, state: State<AppState>) -> Result<(), String> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn get_board(state: State<AppState>) -> Result<Vec<Vec<i32>>, String> {
|
||||
let board_opt = state.board.lock().map_err(|e| e.to_string())?;
|
||||
let board = board_opt.as_ref().ok_or("游戏未开始")?;
|
||||
|
||||
let mut result = vec![vec![0i32; board.size]; board.size];
|
||||
for x in 0..board.size {
|
||||
for y in 0..board.size {
|
||||
result[x][y] = match board.get(Position::new(x, y)) {
|
||||
CellState::Empty => 0,
|
||||
CellState::Occupied(Color::Black) => 1,
|
||||
CellState::Occupied(Color::White) => 2,
|
||||
};
|
||||
}
|
||||
}
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn ai_move(state: State<AppState>) -> Result<Option<(usize, usize)>, String> {
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ pub fn run() {
|
||||
commands::new_game,
|
||||
commands::place_piece,
|
||||
commands::undo,
|
||||
commands::get_board,
|
||||
|
||||
commands::ai_move,
|
||||
commands::get_game_state,
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user