Adding question comportament

This commit is contained in:
2020-11-07 23:56:37 -03:00
parent 414ca8b7eb
commit 46627f1dd1
3 changed files with 15 additions and 2 deletions

View File

@@ -72,7 +72,10 @@ function App() {
return;
}
const cell = document.getElementById(`cell_${row}_${col}`);
if (cell.classList.contains('flagged')) {
if (
cell.classList.contains('flagged') ||
cell.classList.contains('question')
) {
return;
}
@@ -109,9 +112,12 @@ function App() {
return;
}
if (cell.classList.contains('flagged')) {
if (cell.classList.contains('question')) {
cell.classList.remove('question');
} else if (cell.classList.contains('flagged')) {
cell.classList.remove('flagged');
setFlags(flags + 1);
cell.classList.add('question');
} else if (flags > 0) {
cell.classList.add('flagged');
setFlags(flags - 1);