aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAiden Woodruff <aiden.woodruff@gmail.com>2018-05-22 10:52:54 -0500
committerAiden Woodruff <aiden.woodruff@gmail.com>2018-05-22 10:52:54 -0500
commita172b2d15e24079d6b998220d154ec70ddf96d8f (patch)
tree58d3fb7d768af16e70682db5641bab5e3ff2b12b
parent7f5c0f58a7305302f5593399fc841344169bd468 (diff)
downloadsweeper-a172b2d15e24079d6b998220d154ec70ddf96d8f.tar.gz
sweeper-a172b2d15e24079d6b998220d154ec70ddf96d8f.tar.bz2
sweeper-a172b2d15e24079d6b998220d154ec70ddf96d8f.zip
Fixed issue with mines equaling total number of tiles
Changed gt test to ge test Signed-off-by: Aiden Woodruff <aiden.woodruff@gmail.com>
-rw-r--r--sweeper.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/sweeper.js b/sweeper.js
index 9d9b56b..02caf88 100644
--- a/sweeper.js
+++ b/sweeper.js
@@ -347,7 +347,7 @@ if (!dimensions["height"] || dimensions["height"] < 1) {
347} else { 347} else {
348 height = parseInt(dimensions["height"], 10); 348 height = parseInt(dimensions["height"], 10);
349} 349}
350if (!dimensions["mines"] || parseInt(dimensions["mines"], 10) > (width * height)) { 350if (!dimensions["mines"] || parseInt(dimensions["mines"], 10) >= (width * height)) {
351 total_mines = Math.floor(Math.sqrt(width * height)); 351 total_mines = Math.floor(Math.sqrt(width * height));
352 total_mines = Math.floor((Math.random() * Math.floor(Math.sqrt(width*height))) + Math.floor(Math.sqrt(width*height))); 352 total_mines = Math.floor((Math.random() * Math.floor(Math.sqrt(width*height))) + Math.floor(Math.sqrt(width*height)));
353} else { 353} else {