mirror of
https://github.com/szymon-jozef/checkers.git
synced 2026-10-27 19:20:44 +01:00
chore: add pawns_positions to board
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
use crate::logic::{
|
use crate::logic::{
|
||||||
pawn::{Pawn, PawnState},
|
pawn::{self, Pawn, PawnState},
|
||||||
player::Player,
|
player::Player,
|
||||||
utils::{Field, Position},
|
utils::{Field, Position},
|
||||||
};
|
};
|
||||||
@@ -9,6 +9,7 @@ use log::{debug, info, warn};
|
|||||||
|
|
||||||
pub struct Board {
|
pub struct Board {
|
||||||
board: Vec<Field>,
|
board: Vec<Field>,
|
||||||
|
pawns_positions: Vec<Position>,
|
||||||
pub size: usize,
|
pub size: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +60,16 @@ impl Board {
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Board { board, size }
|
let pawns_positions: Vec<Position> = board
|
||||||
|
.iter()
|
||||||
|
.filter_map(|field| field.pawn.as_ref().map(|_| field.position))
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
Board {
|
||||||
|
board,
|
||||||
|
size,
|
||||||
|
pawns_positions,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if move from position to position is valid.
|
/// Checks if move from position to position is valid.
|
||||||
|
|||||||
Reference in New Issue
Block a user