From b3c472fbce32c878b86352ec79e00cbcd001542d Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Fri, 26 Apr 2024 09:50:42 -0400 Subject: [PATCH] Fix some imports in the moves package Castle and EnPassant moved to the board package. Reference these types there. Add the board packages as a dependency to the moves package. --- Cargo.lock | 1 + board/src/lib.rs | 2 +- moves/Cargo.toml | 3 ++- moves/src/builder.rs | 3 ++- moves/src/en_passant.rs | 54 ----------------------------------------- moves/src/lib.rs | 4 --- moves/src/moves.rs | 3 ++- 7 files changed, 8 insertions(+), 62 deletions(-) delete mode 100644 moves/src/en_passant.rs diff --git a/Cargo.lock b/Cargo.lock index 50995a7..3049c76 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,6 +86,7 @@ name = "chessfriend_moves" version = "0.1.0" dependencies = [ "chessfriend_bitboard", + "chessfriend_board", "chessfriend_core", ] diff --git a/board/src/lib.rs b/board/src/lib.rs index 67f2c6f..e599040 100644 --- a/board/src/lib.rs +++ b/board/src/lib.rs @@ -1,10 +1,10 @@ // Eryn Wells +pub mod castle; pub mod en_passant; mod board; mod builder; -mod castle; mod display; mod flags; mod macros; diff --git a/moves/Cargo.toml b/moves/Cargo.toml index 3c9e6cf..b042344 100644 --- a/moves/Cargo.toml +++ b/moves/Cargo.toml @@ -6,5 +6,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -chessfriend_core = { path = "../core" } chessfriend_bitboard = { path = "../bitboard" } +chessfriend_board = { path = "../board" } +chessfriend_core = { path = "../core" } diff --git a/moves/src/builder.rs b/moves/src/builder.rs index 5f02364..0ead866 100644 --- a/moves/src/builder.rs +++ b/moves/src/builder.rs @@ -1,6 +1,7 @@ // Eryn Wells -use crate::{castle, defs::Kind, EnPassant, Move, PromotionShape}; +use crate::{defs::Kind, Move, PromotionShape}; +use chessfriend_board::{castle, en_passant::EnPassant}; use chessfriend_core::{Color, File, PlacedPiece, Rank, Square}; use std::result::Result as StdResult; diff --git a/moves/src/en_passant.rs b/moves/src/en_passant.rs deleted file mode 100644 index 9a0f972..0000000 --- a/moves/src/en_passant.rs +++ /dev/null @@ -1,54 +0,0 @@ -// Eryn Wells - -use chessfriend_core::{Rank, Square}; - -/// En passant information. -#[derive(Clone, Copy, Debug, Eq, PartialEq)] -pub struct EnPassant { - target_square: Square, - capture_square: Square, -} - -impl EnPassant { - fn _capture_square(target: Square) -> Option { - let (file, rank) = target.file_rank(); - match rank { - Rank::THREE => Some(Square::from_file_rank(file, Rank::FOUR)), - Rank::SIX => Some(Square::from_file_rank(file, Rank::FIVE)), - _ => None, - } - } - - /// Return en passant information for a particular target square. The target - /// square is the square a pawn capturing en passant will move to. - /// - /// Return `None` if the square is not eligible for en passant. - /// - /// ## Examples - /// - /// ``` - /// use chessfriend_core::Square; - /// use chessfriend_moves::EnPassant; - /// assert!(EnPassant::from_target_square(Square::E3).is_some()); - /// assert!(EnPassant::from_target_square(Square::B4).is_none()); - /// ``` - pub fn from_target_square(target: Square) -> Option { - match Self::_capture_square(target) { - Some(capture) => Some(Self { - target_square: target, - capture_square: capture, - }), - None => None, - } - } - - /// The square the capturing piece will move to. - pub fn target_square(&self) -> Square { - self.target_square - } - - /// The square on which the captured pawn sits. - pub fn capture_square(&self) -> Square { - self.capture_square - } -} diff --git a/moves/src/lib.rs b/moves/src/lib.rs index 297f82e..e43a61d 100644 --- a/moves/src/lib.rs +++ b/moves/src/lib.rs @@ -3,13 +3,9 @@ pub mod testing; mod builder; -mod castle; mod defs; -mod en_passant; mod moves; pub use builder::{Builder, Error as BuildMoveError, Result as BuildMoveResult}; -pub use castle::Castle; pub use defs::PromotionShape; -pub use en_passant::EnPassant; pub use moves::Move; diff --git a/moves/src/moves.rs b/moves/src/moves.rs index 5348306..8e7c926 100644 --- a/moves/src/moves.rs +++ b/moves/src/moves.rs @@ -1,6 +1,7 @@ // Eryn Wells -use crate::{castle::Castle, defs::Kind}; +use crate::defs::Kind; +use chessfriend_board::castle::Castle; use chessfriend_core::{Rank, Shape, Square}; use std::fmt;