Improve game rules configuration screen

This commit is contained in:
2022-10-02 19:17:29 +02:00
parent c9f643e224
commit 17a4edf417
9 changed files with 51 additions and 28 deletions

View File

@ -91,18 +91,28 @@ impl GameRules {
let mut errors = vec![];
if self.map_width < config.min_map_width || self.map_width > config.max_map_width {
errors.push("Map width is outside bounds!");
if self.map_width < config.min_map_width {
errors.push("Map width is too small!");
}
if self.map_height < config.min_map_height || self.map_height > config.max_map_height {
errors.push("Map height is outside bounds!");
if self.map_width > config.max_map_width {
errors.push("Map width is too big!");
}
if self.boats_list().len() < config.min_boats_number
|| self.boats_list().len() > config.max_boats_number
{
errors.push("The number of boats is invalid!");
if self.map_height < config.min_map_height {
errors.push("Map height is too small!");
}
if self.map_height > config.max_map_height {
errors.push("Map height is too big!");
}
if self.boats_list().len() < config.min_boats_number {
errors.push("There is not enough boats!");
}
if self.boats_list().len() > config.max_boats_number {
errors.push("There are too many boats!");
}
for boat in self.boats_list() {