Show all mines if the user fails

This commit is contained in:
2020-11-08 00:30:40 -03:00
parent 3d1c1637f3
commit 5710193580
2 changed files with 17 additions and 0 deletions

View File

@@ -79,6 +79,19 @@ function App() {
})
);
}
if (activeGame && activeGame.win === false) {
console.log(activeGame);
// search for all mines on board
activeGame.board.map((row, rowId) =>
row.map((col, colId) => {
if (col === -1) {
const cell = document.getElementById(`cell_${rowId}_${colId}`);
cell.classList.add('mined');
}
})
);
}
});
const handleCellClick = (row, col) => {
@@ -107,6 +120,7 @@ function App() {
cell.innerHTML = points;
} else {
cell.classList.add('mined');
cell.classList.add('mined-red');
document.getElementsByClassName('reset')[0].innerHTML = '👻';
}

View File

@@ -68,6 +68,9 @@
background-repeat: no-repeat;
background-position: center center;
background-size: 90%;
}
&-cell.mined-red {
background-color: rgba(255, 0, 0, 0.6);
}