X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=base_rules.js;h=3fa4e0bf40baa5514c40315eb5f21bae97b83c16;hb=fcede3ef85cbb36a05220033cdd318af68e0084c;hp=f73700b844571d8ced5f42ef79fb914292c2e3dd;hpb=c4e9bb928964d723ee624a449c3342e2ef9140f8;p=xogo.git diff --git a/base_rules.js b/base_rules.js index f73700b..3fa4e0b 100644 --- a/base_rules.js +++ b/base_rules.js @@ -29,16 +29,18 @@ export default class ChessRules { {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 @@ -943,11 +945,6 @@ export default class ChessRules { }; 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]; @@ -972,15 +969,12 @@ export default class ChessRules { 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 @@ -2154,9 +2148,7 @@ export default class ChessRules { playVisual(move, r) { move.vanish.forEach(v => { - // TODO: next "if" shouldn't be required - if (this.g_pieces[v.x][v.y]) - this.g_pieces[v.x][v.y].remove(); + this.g_pieces[v.x][v.y].remove(); this.g_pieces[v.x][v.y] = null; }); let chessboard = @@ -2203,10 +2195,6 @@ export default class ChessRules { return; } let initPiece = this.getDomPiece(move.start.x, move.start.y); - if (!initPiece) { //TODO this shouldn't be required - callback(); - return; - } // NOTE: cloning generally not required, but light enough, and simpler let movingPiece = initPiece.cloneNode(); initPiece.style.opacity = "0";