chore: add pawns_positions to board

This commit is contained in:
2026-08-12 18:19:17 +02:00
parent be542d9b72
commit e36fb92632

View File

@@ -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.