mirror of
https://github.com/LHY0125/Gobang-Game.git
synced 2026-06-29 00:45: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(())
|
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]
|
#[tauri::command]
|
||||||
pub fn ai_move(state: State<AppState>) -> Result<Option<(usize, usize)>, String> {
|
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::new_game,
|
||||||
commands::place_piece,
|
commands::place_piece,
|
||||||
commands::undo,
|
commands::undo,
|
||||||
commands::get_board,
|
|
||||||
commands::ai_move,
|
commands::ai_move,
|
||||||
commands::get_game_state,
|
commands::get_game_state,
|
||||||
])
|
])
|
||||||
|
|||||||
Reference in New Issue
Block a user