Merge pull request 'Fix some clippy nits' (#5) from asonix/clippy into kumu
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
Reviewed-on: #5
This commit is contained in:
commit
bb61a9464c
|
@ -468,7 +468,7 @@ impl GameState {
|
|||
let mut possible_moves = HashSet::new();
|
||||
for (pos, piece) in &self.board {
|
||||
if &piece.color == color {
|
||||
possible_moves.extend(piece.get_possible_moves(&pos, &self));
|
||||
possible_moves.extend(piece.get_possible_moves(pos, self));
|
||||
}
|
||||
}
|
||||
possible_moves
|
||||
|
@ -489,15 +489,7 @@ impl GameState {
|
|||
return Some(GameOutcome::WhiteWin);
|
||||
}
|
||||
|
||||
if !self.player_in_check(&Color::White)
|
||||
&& self.get_possible_moves(&Color::White).is_empty()
|
||||
&& self.allowed_turn == Color::White
|
||||
{
|
||||
return Some(GameOutcome::Draw);
|
||||
} else if !self.player_in_check(&Color::Black)
|
||||
&& self.get_possible_moves(&Color::Black).is_empty()
|
||||
&& self.allowed_turn == Color::Black
|
||||
{
|
||||
if self.is_stalemate() {
|
||||
return Some(GameOutcome::Draw);
|
||||
}
|
||||
|
||||
|
@ -506,18 +498,16 @@ impl GameState {
|
|||
if self.board.len() <= 4 {
|
||||
let mut white_pieces = 0;
|
||||
let mut black_pieces = 0;
|
||||
for (_, piece) in &self.board {
|
||||
for piece in self.board.values() {
|
||||
if piece.kind == PieceKind::Rook
|
||||
|| piece.kind == PieceKind::Queen
|
||||
|| piece.kind == PieceKind::Pawn
|
||||
{
|
||||
is_insufficient = false;
|
||||
} else if piece.color == Color::White {
|
||||
white_pieces += 1;
|
||||
} else {
|
||||
if piece.color == Color::White {
|
||||
white_pieces += 1;
|
||||
} else {
|
||||
black_pieces += 1;
|
||||
}
|
||||
black_pieces += 1;
|
||||
}
|
||||
}
|
||||
if white_pieces > 2 || black_pieces > 2 {
|
||||
|
@ -531,6 +521,11 @@ impl GameState {
|
|||
None
|
||||
}
|
||||
|
||||
fn is_stalemate(&self) -> bool {
|
||||
!self.player_in_check(&self.allowed_turn)
|
||||
&& self.get_possible_moves(&self.allowed_turn).is_empty()
|
||||
}
|
||||
|
||||
fn apply_move(&mut self, board_move: &Move) {
|
||||
let from = board_move.from.clone();
|
||||
let to = board_move.to.clone();
|
||||
|
|
Loading…
Reference in a new issue