use chess::Piece;
use method_shorthands::methods::*;
pub trait Name {
fn name(&self) -> String;
}
impl Name for Piece {
fn name(&self) -> String {
match self {
Piece::Pawn => "Pawn".ts(),
Piece::Knight => "Knight".ts(),
Piece::Bishop => "Bishop".ts(),
Piece::Rook => "Rook".ts(),
Piece::Queen => "Queen".ts(),
Piece::King => "King".ts()
}
}
}
pub trait Value {
fn value(&self) -> f32;
}
impl Value for Piece {
fn value(&self) -> f32 {
match self {
Piece::Pawn => 1.0,
Piece::Knight => 3.0,
Piece::Bishop => 3.25,
Piece::Rook => 5.0,
Piece::Queen => 9.0,
Piece::King => 0.0
}
}
}
pub trait IsOrthogonal {
fn is_orthogonal(&self) -> bool;
}
impl IsOrthogonal for Piece {
fn is_orthogonal(&self) -> bool {
match self {
Piece::Rook => true,
Piece::Queen => true,
_ => false
}
}
}
pub trait IsDiagonal {
fn is_diagonal(&self) -> bool;
}
impl IsDiagonal for Piece {
fn is_diagonal(&self) -> bool {
match self {
Piece::Bishop => true,
Piece::Queen => true,
_ => false
}
}
}