{label: "Asymmetric random", value: 2}
]
}],
- check: [
+ input: [
{
label: "Capture king",
- defaut: false,
- variable: "taking"
+ variable: "taking",
+ type: "checkbox",
+ defaut: false
},
{
label: "Falling pawn",
- defaut: false,
- variable: "pawnfall"
+ variable: "pawnfall",
+ type: "checkbox",
+ defaut: false
}
],
// Game modifiers (using "elementary variants"). Default: false
};
const mouseup = (e) => {
- const newR = chessboard.getBoundingClientRect();
- if (newR.width != r.width || newR.height != r.height) {
- this.rescale();
- return;
- }
if (!start)
return;
const [x, y] = [start.x, start.y];
curPiece.remove();
};
- const wheelResize = (e) => {
- this.rescale(e.deltaY < 0 ? "up" : "down");
- };
-
if ('onmousedown' in window) {
document.addEventListener("mousedown", mousedown);
document.addEventListener("mousemove", mousemove);
document.addEventListener("mouseup", mouseup);
- document.addEventListener("wheel", wheelResize);
+ document.addEventListener("wheel",
+ (e) => this.rescale(e.deltaY < 0 ? "up" : "down"));
}
if ('ontouchstart' in window) {
// https://stackoverflow.com/a/42509310/12660887
const attacks = specs.attack || specs.moves;
for (let a of attacks) {
outerLoop: for (let step of a.steps) {
- let [i, j] = [x + step[0], this.computeY(y + step[1])];
+ let [i, j] = [x + step[0], this.getY(y + step[1])];
let nbSteps = 1;
while (this.onBoard(i, j) && this.board[i][j] == "") {
if (a.range <= nbSteps++)
continue outerLoop;
i += step[0];
- j = this.computeY(j + step[1]);
+ j = this.getY(j + step[1]);
}
if (
this.onBoard(i, j) && this.getColor(i, j) == oppCol &&
}
};
- if ('onmousedown' in window)
+ if ('onmousedown' in window) {
document.addEventListener("mousedown", mousedown);
+ document.addEventListener("wheel",
+ (e) => this.rescale(e.deltaY < 0 ? "up" : "down"));
+ }
if ('ontouchstart' in window)
document.addEventListener("touchstart", mousedown, {passive: false});
}