Make more readability refactorings
This commit is contained in:
@@ -30,7 +30,7 @@ pub struct MoveParameters {
|
||||
pub captured_piece: Option<PieceType>,
|
||||
pub promoted_piece: Option<PieceType>,
|
||||
pub castling_ability: Option<[Castle; 2]>,
|
||||
pub en_passant_target_square: Option<usize>,
|
||||
pub en_passant_square: Option<usize>,
|
||||
pub halfmove_clock: Option<u8>,
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ impl MoveParameters {
|
||||
captured_piece: None,
|
||||
promoted_piece: None,
|
||||
castling_ability: None,
|
||||
en_passant_target_square: None,
|
||||
en_passant_square: None,
|
||||
halfmove_clock: None,
|
||||
}
|
||||
}
|
||||
@@ -54,25 +54,25 @@ impl MoveParameters {
|
||||
self.captured_piece = board.piece_type_at(dst, color);
|
||||
}
|
||||
|
||||
pub fn add_promoted_piece(&mut self, piece_type: Promote) {
|
||||
self.promoted_piece = Some(piece_type.into_piece_type())
|
||||
pub fn add_promoted_piece(&mut self, promote: Promote) {
|
||||
self.promoted_piece = Some(promote.into_piece_type())
|
||||
}
|
||||
|
||||
pub fn add_irreversible_parameters(&mut self, state: State) {
|
||||
self.castling_ability = Some(state.castling_ability);
|
||||
self.en_passant_target_square = state.en_passant_target_square;
|
||||
self.en_passant_square = state.en_passant_square;
|
||||
self.halfmove_clock = Some(state.halfmove_clock)
|
||||
}
|
||||
|
||||
pub fn add_capture_and_promotion_piece(&mut self, board: &Board, mv: Move, color: Color) {
|
||||
match mv.move_type {
|
||||
MoveType::Capture => {
|
||||
self.add_captured_piece(&board, mv.dst, Color::opponent_color(color))
|
||||
self.add_captured_piece(board, mv.dst, Color::opponent_color(color))
|
||||
}
|
||||
MoveType::Promotion(piece) => self.add_promoted_piece(piece),
|
||||
MoveType::PromotionCapture(piece) => {
|
||||
self.add_promoted_piece(piece);
|
||||
self.add_captured_piece(&board, mv.dst, Color::opponent_color(color));
|
||||
self.add_captured_piece(board, mv.dst, Color::opponent_color(color));
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user