Purge ALL_VALUES from rank/file enums
This commit is contained in:
@@ -87,7 +87,6 @@ where
|
|||||||
Self: Sized,
|
Self: Sized,
|
||||||
Self: Clone,
|
Self: Clone,
|
||||||
{
|
{
|
||||||
const ALL_VALUES: [Self; 8];
|
|
||||||
fn incr(&self) -> Option<Self>;
|
fn incr(&self) -> Option<Self>;
|
||||||
fn decr(&self) -> Option<Self>;
|
fn decr(&self) -> Option<Self>;
|
||||||
fn delta(&self, direction: &Direction) -> Option<Self> {
|
fn delta(&self, direction: &Direction) -> Option<Self> {
|
||||||
@@ -100,16 +99,6 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl GridAxis for Rank {
|
impl GridAxis for Rank {
|
||||||
const ALL_VALUES: [Rank; 8] = [
|
|
||||||
Rank::_1,
|
|
||||||
Rank::_2,
|
|
||||||
Rank::_3,
|
|
||||||
Rank::_4,
|
|
||||||
Rank::_5,
|
|
||||||
Rank::_6,
|
|
||||||
Rank::_7,
|
|
||||||
Rank::_8,
|
|
||||||
];
|
|
||||||
fn incr(&self) -> Option<Self> {
|
fn incr(&self) -> Option<Self> {
|
||||||
match self {
|
match self {
|
||||||
Rank::_1 => Some(Rank::_2),
|
Rank::_1 => Some(Rank::_2),
|
||||||
@@ -137,16 +126,6 @@ impl GridAxis for Rank {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl GridAxis for File {
|
impl GridAxis for File {
|
||||||
const ALL_VALUES: [File; 8] = [
|
|
||||||
File::A,
|
|
||||||
File::B,
|
|
||||||
File::C,
|
|
||||||
File::D,
|
|
||||||
File::E,
|
|
||||||
File::F,
|
|
||||||
File::G,
|
|
||||||
File::H,
|
|
||||||
];
|
|
||||||
fn incr(&self) -> Option<Self> {
|
fn incr(&self) -> Option<Self> {
|
||||||
match self {
|
match self {
|
||||||
File::A => Some(File::B),
|
File::A => Some(File::B),
|
||||||
@@ -180,21 +159,35 @@ pub enum PieceType {
|
|||||||
|
|
||||||
impl PieceType {
|
impl PieceType {
|
||||||
fn initial_setup(&self) -> Vec<(Piece, Position)> {
|
fn initial_setup(&self) -> Vec<(Piece, Position)> {
|
||||||
match &self {
|
fn pawn(color: Color, file: File) -> (Piece, Position) {
|
||||||
PieceType::Pawn => [Color::Black, Color::White]
|
let pos = Position::new(file, color.get_pawn_rank());
|
||||||
.iter()
|
|
||||||
.flat_map(|color| {
|
|
||||||
File::ALL_VALUES.iter().map(|&file| {
|
|
||||||
(
|
(
|
||||||
Piece {
|
Piece {
|
||||||
piece_type: self.clone(),
|
piece_type: PieceType::Pawn,
|
||||||
color: color.clone(),
|
color,
|
||||||
},
|
},
|
||||||
Position::new(file, color.get_pawn_rank()),
|
pos,
|
||||||
)
|
)
|
||||||
})
|
}
|
||||||
})
|
match &self {
|
||||||
.collect(),
|
PieceType::Pawn => vec![
|
||||||
|
pawn(Color::White, File::A),
|
||||||
|
pawn(Color::White, File::B),
|
||||||
|
pawn(Color::White, File::C),
|
||||||
|
pawn(Color::White, File::D),
|
||||||
|
pawn(Color::White, File::E),
|
||||||
|
pawn(Color::White, File::F),
|
||||||
|
pawn(Color::White, File::G),
|
||||||
|
pawn(Color::White, File::H),
|
||||||
|
pawn(Color::Black, File::A),
|
||||||
|
pawn(Color::Black, File::B),
|
||||||
|
pawn(Color::Black, File::C),
|
||||||
|
pawn(Color::Black, File::D),
|
||||||
|
pawn(Color::Black, File::E),
|
||||||
|
pawn(Color::Black, File::F),
|
||||||
|
pawn(Color::Black, File::G),
|
||||||
|
pawn(Color::Black, File::H),
|
||||||
|
],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user