Added texture and board

This commit is contained in:
cool-mist
2025-01-27 00:24:28 +05:30
parent 90a6ae7716
commit a7ada984c5
32 changed files with 664 additions and 276 deletions
+40
View File
@@ -0,0 +1,40 @@
use super::{piece::Piece, square::Square};
#[derive(PartialEq, Hash, Eq, Clone)]
pub struct CMove {
pub from_piece: Piece,
pub from: Square,
pub to_piece: Piece,
pub to: Square,
// Used to disambiguate when looking at notation
disambig: String,
}
impl CMove {
pub fn new(from: Square, to: Square) -> Self {
let disambig = String::from("");
let from_piece = from.piece.expect("Trying to move a blank");
let to_piece = to.piece.expect("Trying to capture a blank");
CMove {
from_piece,
from,
to_piece,
to,
disambig
}
}
pub fn notation(&self) -> String {
let piece_qualifier = match &self.from_piece {
Piece::Pawn => self.from.file_notation(),
p => p.notation(),
};
format!(
"{}{}x{}",
piece_qualifier,
self.disambig,
self.to.notation()
)
}
}