mirror of
https://github.com/szymon-jozef/checkers.git
synced 2026-10-28 11:10:44 +01:00
feat: implement get_current_player_moves for game_master and move_path struct
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
use crate::logic::{
|
||||
board::{board::Board, pawn::CapturePath},
|
||||
board::{
|
||||
board::Board,
|
||||
pawn::{CapturePath, MovePath},
|
||||
},
|
||||
math::position::Position,
|
||||
player::Player,
|
||||
};
|
||||
|
||||
@@ -53,4 +57,16 @@ impl GameMaster {
|
||||
.flatten()
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn get_current_player_moves(&self) -> Vec<MovePath> {
|
||||
self.board
|
||||
.get_player_pawns_positions(self.players.get_current_turn())
|
||||
.into_iter()
|
||||
.filter_map(|pos| {
|
||||
self.board
|
||||
.get_available_moves(pos, self.players.get_current_turn())
|
||||
})
|
||||
.flatten()
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user