mirror of
https://github.com/szymon-jozef/checkers.git
synced 2026-10-27 19:20:44 +01:00
fix: formatting again
This commit is contained in:
@@ -72,7 +72,6 @@ struct ClientContext {
|
|||||||
pub available_moves: Option<Vec<MovePath>>,
|
pub available_moves: Option<Vec<MovePath>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async fn run_bot() {
|
async fn run_bot() {
|
||||||
let bot = Bot::new(BotDificulty::Easy).await;
|
let bot = Bot::new(BotDificulty::Easy).await;
|
||||||
bot.game_loop().await;
|
bot.game_loop().await;
|
||||||
@@ -96,10 +95,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
loop {
|
loop {
|
||||||
let mut buffer = String::new();
|
let mut buffer = String::new();
|
||||||
if stdin.read_line(&mut buffer).is_ok()
|
if stdin.read_line(&mut buffer).is_ok() && stdin_sender.blocking_send(buffer).is_err() {
|
||||||
&& stdin_sender.blocking_send(buffer).is_err() {
|
break;
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -280,31 +280,32 @@ impl Board {
|
|||||||
|
|
||||||
if let Some(target) = target_option
|
if let Some(target) = target_option
|
||||||
&& self.can_capture(current_pos, target, player, captured_enemies, pawn)
|
&& self.can_capture(current_pos, target, player, captured_enemies, pawn)
|
||||||
&& let Some(path_after_capture) = target.checked_add(direction) {
|
&& let Some(path_after_capture) = target.checked_add(direction)
|
||||||
debug!(
|
{
|
||||||
"Found possible capture: {} -> {}",
|
debug!(
|
||||||
current_pos, path_after_capture
|
"Found possible capture: {} -> {}",
|
||||||
);
|
current_pos, path_after_capture
|
||||||
|
);
|
||||||
|
|
||||||
found_any_capture = true;
|
found_any_capture = true;
|
||||||
|
|
||||||
let mut new_path = current_path.clone();
|
let mut new_path = current_path.clone();
|
||||||
new_path.push(path_after_capture);
|
new_path.push(path_after_capture);
|
||||||
|
|
||||||
let mut new_enemies = captured_enemies.clone();
|
let mut new_enemies = captured_enemies.clone();
|
||||||
new_enemies.push(target);
|
new_enemies.push(target);
|
||||||
|
|
||||||
self.find_captures(
|
self.find_captures(
|
||||||
start_pos,
|
start_pos,
|
||||||
path_after_capture,
|
path_after_capture,
|
||||||
&mut new_path,
|
&mut new_path,
|
||||||
&new_enemies,
|
&new_enemies,
|
||||||
available_directions,
|
available_directions,
|
||||||
player,
|
player,
|
||||||
all_paths,
|
all_paths,
|
||||||
pawn,
|
pawn,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !found_any_capture && !current_path.is_empty() && !captured_enemies.is_empty() {
|
if !found_any_capture && !current_path.is_empty() && !captured_enemies.is_empty() {
|
||||||
|
|||||||
@@ -187,16 +187,17 @@ impl Board {
|
|||||||
|
|
||||||
if let Some(field) = &self.get_clicked_field()
|
if let Some(field) = &self.get_clicked_field()
|
||||||
&& let Some(available_moves) = &self.available_moves
|
&& let Some(available_moves) = &self.available_moves
|
||||||
&& available_moves.iter().any(|available_move| {
|
&& available_moves.iter().any(|available_move| {
|
||||||
available_move.from == from
|
available_move.from == from
|
||||||
&& available_move.available_steps.contains(&field.pos)
|
&& available_move.available_steps.contains(&field.pos)
|
||||||
}) {
|
})
|
||||||
self.choosen_move = Some(MovePath {
|
{
|
||||||
from,
|
self.choosen_move = Some(MovePath {
|
||||||
available_steps: vec![field.pos],
|
from,
|
||||||
});
|
available_steps: vec![field.pos],
|
||||||
self.state = BoardState::View;
|
});
|
||||||
}
|
self.state = BoardState::View;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BoardState::ChooseCapture(from) => {
|
BoardState::ChooseCapture(from) => {
|
||||||
@@ -235,10 +236,11 @@ impl Board {
|
|||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}) {
|
})
|
||||||
self.current_capture_path.push(*clicked_field);
|
{
|
||||||
self.current_deepness += 1;
|
self.current_capture_path.push(*clicked_field);
|
||||||
}
|
self.current_deepness += 1;
|
||||||
|
}
|
||||||
|
|
||||||
if current_highlight.is_empty() {
|
if current_highlight.is_empty() {
|
||||||
debug!("Capture path complete!");
|
debug!("Capture path complete!");
|
||||||
|
|||||||
Reference in New Issue
Block a user