Constellations/js/Mode/Play.js
2022-08-11 09:58:57 +02:00

28 lines
455 B
JavaScript

import Grid;
import GUI;
import at from Grid.Util;
return {
events: {
onClick: onClick
}
};
function onClick(e, cell) {
if(Grid.get().missing.isEmpty()) {
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');
}
}