Ready to implement boats layout check

This commit is contained in:
2022-09-15 18:04:22 +02:00
parent 007fe3b773
commit d3d5feda4f
10 changed files with 85 additions and 23 deletions

View File

@@ -272,6 +272,12 @@ impl BoatsLayout {
pub fn number_of_boats(&self) -> usize {
self.0.len()
}
/// Check for layout invalid configuration
pub fn layouts_errors(&self, _rules: &GameRules) -> Vec<&'static str> {
//TODO : implement
vec![]
}
}
#[cfg(test)]

View File

@@ -4,13 +4,13 @@ use rand::RngCore;
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct CurrentGameStatus {
pub rules: GameRules,
// TODO
//TODO
}
impl CurrentGameStatus {
/// Check if user can fire at a given location
pub fn can_fire_at_location(&self, _location: Coordinates) -> bool {
// TODO
//TODO
true
}

View File

@@ -1,7 +1,7 @@
use crate::consts::*;
use crate::data::{BotType, PlayConfiguration};
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, Eq, PartialEq)]
pub struct GameRules {
pub map_width: usize,
pub map_height: usize,

View File

@@ -1,7 +1,7 @@
use crate::consts::*;
/// Specifies the kind of boat to use
#[derive(serde::Serialize, serde::Deserialize, Debug, Copy, Clone)]
#[derive(serde::Serialize, serde::Deserialize, Debug, Copy, Clone, Eq, PartialEq)]
pub enum BotType {
Random,
}