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
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -86,6 +86,7 @@ name = "chessfriend_moves"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chessfriend_bitboard",
|
"chessfriend_bitboard",
|
||||||
|
"chessfriend_board",
|
||||||
"chessfriend_core",
|
"chessfriend_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
// Eryn Wells <eryn@erynwells.me>
|
// Eryn Wells <eryn@erynwells.me>
|
||||||
|
|
||||||
|
pub mod castle;
|
||||||
pub mod en_passant;
|
pub mod en_passant;
|
||||||
|
|
||||||
mod board;
|
mod board;
|
||||||
mod builder;
|
mod builder;
|
||||||
mod castle;
|
|
||||||
mod display;
|
mod display;
|
||||||
mod flags;
|
mod flags;
|
||||||
mod macros;
|
mod macros;
|
||||||
|
|
|
@ -6,5 +6,6 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chessfriend_core = { path = "../core" }
|
|
||||||
chessfriend_bitboard = { path = "../bitboard" }
|
chessfriend_bitboard = { path = "../bitboard" }
|
||||||
|
chessfriend_board = { path = "../board" }
|
||||||
|
chessfriend_core = { path = "../core" }
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// Eryn Wells <eryn@erynwells.me>
|
// 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 chessfriend_core::{Color, File, PlacedPiece, Rank, Square};
|
||||||
use std::result::Result as StdResult;
|
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;
|
pub mod testing;
|
||||||
|
|
||||||
mod builder;
|
mod builder;
|
||||||
mod castle;
|
|
||||||
mod defs;
|
mod defs;
|
||||||
mod en_passant;
|
|
||||||
mod moves;
|
mod moves;
|
||||||
|
|
||||||
pub use builder::{Builder, Error as BuildMoveError, Result as BuildMoveResult};
|
pub use builder::{Builder, Error as BuildMoveError, Result as BuildMoveResult};
|
||||||
pub use castle::Castle;
|
|
||||||
pub use defs::PromotionShape;
|
pub use defs::PromotionShape;
|
||||||
pub use en_passant::EnPassant;
|
|
||||||
pub use moves::Move;
|
pub use moves::Move;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// Eryn Wells <eryn@erynwells.me>
|
// 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 chessfriend_core::{Rank, Shape, Square};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue