implemented conversion method to_index for enum PieceType

This commit is contained in:
Varga Dávid Lajos
2025-11-21 14:07:27 +01:00
parent e1d51fe291
commit f29298731b

View File

@@ -35,4 +35,20 @@ impl PieceType {
_ => panic!("invalid piece index! should NEVER appear")
}
}
pub(in super) fn to_index(&self) -> u8 {
return match self {
&PieceType::WhitePawn => 0,
&PieceType::WhiteKnight => 1,
&PieceType::WhiteBishop => 2,
&PieceType::WhiteRook => 3,
&PieceType::WhiteQueen => 4,
&PieceType::WhiteKing => 5,
&PieceType::BlackPawn => 6,
&PieceType::BlackKnight => 7,
&PieceType::BlackBishop => 8,
&PieceType::BlackRook => 9,
&PieceType::BlackQueen => 10,
&PieceType::BlackKing => 11
}
}
}