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.
This commit is contained in:
parent
1d82d27f84
commit
b3c472fbce
7 changed files with 8 additions and 62 deletions
|
@ -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" }
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
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;
|
||||
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
// Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
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<Square> {
|
||||
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<Self> {
|
||||
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
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Eryn Wells <eryn@erynwells.me>
|
||||
|
||||
use crate::{castle::Castle, defs::Kind};
|
||||
use crate::defs::Kind;
|
||||
use chessfriend_board::castle::Castle;
|
||||
use chessfriend_core::{Rank, Shape, Square};
|
||||
use std::fmt;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue