aboutsummaryrefslogtreecommitdiffstats
path: root/frontend/ts/gameBoard.ts
diff options
context:
space:
mode:
authorMaks Jopek <maksymilian.jopek@prym-soft.pl>2021-04-26 14:43:25 +0200
committerMaks Jopek <maksymilian.jopek@prym-soft.pl>2021-04-26 14:43:25 +0200
commit6baaa14bde032afa363dbdd50119a20e9f47df1c (patch)
tree82e7ba81f36e725e282eadd5c8c61f4304b1bf85 /frontend/ts/gameBoard.ts
parent013319d7a4651d1708280f556e39c2f03839426a (diff)
downloadfia-6baaa14bde032afa363dbdd50119a20e9f47df1c.tar.gz
fia-6baaa14bde032afa363dbdd50119a20e9f47df1c.tar.zst
fia-6baaa14bde032afa363dbdd50119a20e9f47df1c.zip
Bugfixes: to home, [40] -> [1], not destroying old chequer
Diffstat (limited to 'frontend/ts/gameBoard.ts')
-rw-r--r--frontend/ts/gameBoard.ts17
1 files changed, 9 insertions, 8 deletions
diff --git a/frontend/ts/gameBoard.ts b/frontend/ts/gameBoard.ts
index da5e8d6..14ccac6 100644
--- a/frontend/ts/gameBoard.ts
+++ b/frontend/ts/gameBoard.ts
@@ -41,7 +41,7 @@ export default class gameBoardClass {
}
static removeChequer(coords: Coordinates, all: boolean) {
let td = gameTable.getTd(coords);
- gameBoardClass.hideChequer(coords);
+ gameBoardClass.hideChequer(coords, all);
td.onmouseenter = () => null;
td.onmouseleave = () => null;
td.onclick = () => null;
@@ -51,31 +51,32 @@ export default class gameBoardClass {
let td = gameTable.getTd(coords);
if (td.dataset.count === undefined)
throw new Error("td.dataset.count is undefined!!!")
-
+
+ if(td.className === '')
+ td.classList.add("chequer");
+
if (td.dataset.count === '0') {
td.classList.add("chequer-" + StartGame.colors[color]);
td.dataset.count = '1';
td.innerHTML = '';
} else {
td.dataset.count = (parseInt(td.dataset.count) + 1).toString();
- td.innerHTML = 'x' + td.dataset.count;
+ td.innerHTML = td.dataset.count === '1' ? '' : 'x' + td.dataset.count;
}
}
static hideChequer(coords: Coordinates, all = false) {
let td = gameTable.getTd(coords);
- if (td.dataset.count === '0')
- return;
if (td.dataset.count === undefined)
throw new Error("td.dataset.count is undefined!!!")
- if (td.dataset.count === '1' || all === true) {
- td.className = td.className.replace(/chequer-.*/, '');
+ if (all === true || ['0', '1'].includes(td.dataset.count)) {
+ td.className = 'chequer';
td.dataset.count = '0';
td.innerHTML = '';
} else {
td.dataset.count = (parseInt(td.dataset.count) - 1).toString();
- td.innerHTML = 'x' + td.dataset.count;
+ td.innerHTML = td.dataset.count === '1' ? '' : 'x' + td.dataset.count;
}
}
} \ No newline at end of file