This repository has been archived on 2025-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
SeaBattle/src/data/play_config.rs

46 lines
1.2 KiB
Rust

use crate::consts::*;
/// Specifies the kind of boat to use
#[derive(serde::Serialize, serde::Deserialize, Debug, Copy, Clone)]
pub enum BotType {
Random,
}
#[derive(serde::Serialize)]
pub struct BotDescription {
r#type: BotType,
description: String,
}
#[derive(serde::Serialize)]
pub struct PlayConfiguration {
pub min_boat_len: usize,
pub max_boat_len: usize,
pub min_map_width: usize,
pub max_map_width: usize,
pub min_map_height: usize,
pub max_map_height: usize,
pub min_boats_number: usize,
pub max_boats_number: usize,
pub bot_types: Vec<BotDescription>,
}
impl Default for PlayConfiguration {
fn default() -> Self {
Self {
min_boat_len: MIN_BOATS_LENGTH,
max_boat_len: MAX_BOATS_LENGTH,
min_map_width: MIN_MAP_WIDTH,
max_map_width: MAX_MAP_WIDTH,
min_map_height: MIN_MAP_HEIGHT,
max_map_height: MAX_MAP_HEIGHT,
min_boats_number: MIN_BOATS_NUMBER,
max_boats_number: MAX_BOATS_NUMBER,
bot_types: vec![BotDescription {
r#type: BotType::Random,
description: "Random strike. All the time.".to_string(),
}],
}
}
}