From e7b70a6a05ff359e49ff8208bd3d5669b6124df5 Mon Sep 17 00:00:00 2001 From: juls0730 <62722391+juls0730@users.noreply.github.com> Date: Wed, 7 Feb 2024 22:03:56 -0600 Subject: [PATCH] Change mine restrictions to be more faithful --- src/main.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index d240fc3..cdc5202 100644 --- a/src/main.rs +++ b/src/main.rs @@ -311,7 +311,7 @@ fn game_loop() -> io::Result<()> { let mut stdin = String::new(); println!("Please select board size"); -gith + let boards = [ Board::new(9, 9, 10), Board::new(16, 16, 40), @@ -498,12 +498,6 @@ fn make_custom_board() -> Result { return Err(CustomBoardError::Error); } - if mines.get_num() == (cols.get_num() * rows.get_num()) - || (cols.get_num() * rows.get_num()) < mines.get_num() - { - return Err(CustomBoardError::Error); - } - // winmine minimums at least in the winmine from archive.org if cols.get_num() < 8 { cols = Input::Num(8) @@ -517,6 +511,10 @@ fn make_custom_board() -> Result { mines = Input::Num(10); } + if mines.get_num() > (rows.get_num() - 1) * (cols.get_num() - 1) { + mines = Input::Num((rows.get_num() - 1) * (cols.get_num() - 1)); + } + return Ok(Board::new(rows.get_num(), cols.get_num(), mines.get_num())); }