Implement board setup
This commit is contained in:
@@ -25,6 +25,7 @@ impl Color {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct Position {
|
||||
row: Row,
|
||||
column: Column,
|
||||
@@ -203,4 +204,26 @@ impl Piece {
|
||||
}
|
||||
}
|
||||
|
||||
struct Board {
|
||||
state: [[Option<Piece>; Column::ALL_VALUES.len()]; Row::ALL_VALUES.len()],
|
||||
}
|
||||
|
||||
impl Board {
|
||||
fn set_at(&mut self, position: &Position, piece: Piece) {
|
||||
self.state[position.row.get_index() as usize]
|
||||
[position.column.get_index() as usize] = Some(piece);
|
||||
}
|
||||
fn new() -> Board {
|
||||
let mut board = Board {
|
||||
state: Default::default(),
|
||||
};
|
||||
for piece_type in &[PieceType::Pawn] {
|
||||
for piece in piece_type.initial_setup() {
|
||||
board.set_at(&piece.position.clone(), piece);
|
||||
}
|
||||
}
|
||||
board
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
Reference in New Issue
Block a user