when user wins, mark all unrevealed as falgged

This commit is contained in:
2020-11-08 00:13:59 -03:00
parent 46627f1dd1
commit 07f10955a5

View File

@@ -64,6 +64,20 @@ function App() {
if (activeGame && activeGame.win === true) { if (activeGame && activeGame.win === true) {
document.getElementsByClassName('reset')[0].innerHTML = '😎'; document.getElementsByClassName('reset')[0].innerHTML = '😎';
// Search for all unrevealed squares to put the flag
dummyBoard.map((row, rowId) =>
row.map((col, colId) => {
const cell = document.getElementById(`cell_${rowId}_${colId}`);
if (
!cell.classList.contains('revealed') &&
!cell.classList.contains('empty') &&
!cell.classList.contains('point')
) {
cell.classList.add('flagged');
}
})
);
} }
}); });