Solve miscellaneous out-of-range bug

Occurs sometimes when the number of open squares is less than the number of neighbouring covered squares.
This commit is contained in:
Florine W. Dekker 2020-08-01 00:18:51 +02:00
parent 0affcd0675
commit 9bb75784a8
Signed by: FWDekker
GPG Key ID: B1B567AF58D6EE0F
2 changed files with 5 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "minesweeper",
"version": "0.0.40",
"version": "0.0.41",
"description": "Just Minesweeper!",
"author": "Felix W. Dekker",
"browser": "dist/bundle.js",

View File

@ -173,7 +173,10 @@ export class Matrix {
return range(this.colCount - 1)
.map(it => {
const row = this.getRow(this.getCol(it).findIndex(it => it === 1));
const rowPivotIndex = this.getCol(it).findIndex(it => it === 1);
if (rowPivotIndex < 0) return undefined;
const row = this.getRow(rowPivotIndex);
if (row.slice(0, it).every(it => it === 0) && row.slice(it + 1, -1).every(it => it === 0))
return row.slice(-1)[0];