diff options
| author | Aiden Woodruff <aiden.woodruff@gmail.com> | 2018-04-14 17:56:39 -0500 |
|---|---|---|
| committer | Aiden Woodruff <aiden.woodruff@gmail.com> | 2018-04-14 17:56:39 -0500 |
| commit | 3d5f20dae68c49a5e46ecba948e3bf7eca8d03c6 (patch) | |
| tree | 52f10a4fb599915d1ac5c81b03a65bb0b4f7a95a | |
| parent | 8841a18cb69f9753307f78d89fbf8fc53be3bdc0 (diff) | |
| download | sweeper-3d5f20dae68c49a5e46ecba948e3bf7eca8d03c6.tar.gz sweeper-3d5f20dae68c49a5e46ecba948e3bf7eca8d03c6.tar.bz2 sweeper-3d5f20dae68c49a5e46ecba948e3bf7eca8d03c6.zip | |
Fixes issue in boards with less than 20 tiles
Default mine value is not 20, but a math function.
Signed-off-by: Aiden Woodruff <aiden.woodruff@gmail.com>
| -rw-r--r-- | sweeper.js | 4 |
1 files changed, 2 insertions, 2 deletions
| @@ -156,8 +156,8 @@ if (!dimensions["width"] || dimensions["width"] < 1) { | |||
| 156 | if (!dimensions["height"] || dimensions["height"] < 1) { | 156 | if (!dimensions["height"] || dimensions["height"] < 1) { |
| 157 | dimensions["height"] = 10; | 157 | dimensions["height"] = 10; |
| 158 | } | 158 | } |
| 159 | if (!dimensions["mines"] || dimensions["mines"] > dimensions["width"] * dimensions["height"]) { | 159 | if (!dimensions["mines"] || parseInt(dimensions["mines"], 10) > parseInt(dimensions["width"], 10) * parseInt(dimensions["height"], 10)) { |
| 160 | dimensions["mines"] = 20; | 160 | dimensions["mines"] = Math.floor(Math.sqrt(dimensions["width"] * dimensions["height"])) * 2; |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | class Coordinates { | 163 | class Coordinates { |
