Constellations/js/Mode/Play.js

29 lines
456 B
JavaScript
Raw Normal View History

import Grid;
import GUI;
2022-08-10 21:12:39 +02:00
import at from Grid.Util;
return {
events: {
onClick: onClick
}
};
2022-08-10 21:12:39 +02:00
function onClick(e, cell) {
if(Grid.get().missing.size() < 1) {
2022-08-10 21:12:39 +02:00
rotateState(at(Grid.get().cells, cell));
}
}
function rotateState(cell) {
if(cell.classList.contains('off')) {
if(cell.textContent == '*') {
cell.classList.remove('off');
cell.textContent = '';
} else {
cell.textContent = '*';
}
} else {
cell.classList.add('off');
}
}