X-Git-Url: https://git.auder.net/js/rpsls.js?a=blobdiff_plain;f=base_rules.js;h=4ee389fe7d451f28ef9c68e62f6cfd5c028aa527;hb=7bd7cba41f9c2222a29c62ddf8d83fbb46646a1d;hp=2d08bd614d0123a7c69a05475606696dd80e87c3;hpb=518bfb7a260f95e282f763878c2e9cf5ba58ef86;p=xogo.git diff --git a/base_rules.js b/base_rules.js index 2d08bd6..4ee389f 100644 --- a/base_rules.js +++ b/base_rules.js @@ -1013,11 +1013,10 @@ export default class ChessRules { // TODO: onpointerdown/move/up ? See reveal.js /controllers/touch.js } + // NOTE: not called if isDiagram, or genFenOnly removeListeners() { let container = document.getElementById(this.containerId); this.windowResizeObs.unobserve(container); - if (this.isDiagram) - return; //no listeners in this case if ('onmousedown' in window) { this.mouseListeners.forEach(ml => { document.removeEventListener(ml.type, ml.listener); @@ -1341,7 +1340,13 @@ export default class ChessRules { } getStepSpec(color, x, y, piece) { - return this.pieces(color, x, y)[piece || this.getPieceType(x, y)]; + let pieceType = piece; + const allSpecs = this.pieces(color, x, y); + if (!piece) + pieceType = this.getPieceType(x, y); + else if (allSpecs[piece].moveas) + pieceType = allSpecs[piece].moveas; + return allSpecs[pieceType]; } // Can thing on square1 capture thing on square2?