Start to build game grid
This commit is contained in:
@ -172,7 +172,7 @@ impl BoatPosition {
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, Default)]
|
||||
pub struct BoatsLayout(Vec<BoatPosition>);
|
||||
pub struct BoatsLayout(pub Vec<BoatPosition>);
|
||||
|
||||
impl BoatsLayout {
|
||||
/// Generate a new invalid (empty) boats layout
|
||||
@ -331,6 +331,10 @@ impl BoatsLayout {
|
||||
errors
|
||||
}
|
||||
|
||||
pub fn is_valid(&self, rules: &GameRules) -> bool {
|
||||
self.errors(rules).is_empty()
|
||||
}
|
||||
|
||||
pub fn find_boat_at_position(&self, pos: Coordinates) -> Option<&BoatPosition> {
|
||||
self.0.iter().find(|f| f.all_coordinates().contains(&pos))
|
||||
}
|
||||
|
Reference in New Issue
Block a user