X-Git-Url: https://git.auder.net/?p=xogo.git;a=blobdiff_plain;f=base_rules.js;h=07084bf1df622b0126883aa3537c52847b25868f;hp=df49f841d1bbce53205e4d09db153c594809f0af;hb=082e639a3ed0a38a91fbe8d0e8bfa7b262b5227d;hpb=9db5050a189571c9f3018d4d25c7d304ca1a22dc diff --git a/base_rules.js b/base_rules.js index df49f84..07084bf 100644 --- a/base_rules.js +++ b/base_rules.js @@ -1521,26 +1521,29 @@ export default class ChessRules { if (specialAttack) findAddMoves("attack", stepSpec.attack); findAddMoves(specialAttack ? "moveonly" : "all", stepSpec.moves); - if (this.options["zen"]) - Array.prototype.push.apply(moves, this.findCapturesOn([x, y], true)); + if (this.options["zen"]) { + Array.prototype.push.apply(moves, + this.findCapturesOn([x, y], {zen: true})); + } return moves; } - findCapturesOn([x, y], zen) { + // Search for enemy (or not) pieces attacking [x, y] + findCapturesOn([x, y], args) { let moves = []; - // Find reverse captures (opponent takes) - const color = this.getColor(x, y); - const oppCol = C.GetOppCol(color); + if (!args.oppCol) + args.oppCol = C.GetOppCol(this.getColor(x, y) || this.turn); for (let i=0; i= 1); + return ( + this.findCapturesOn([x, y], {oppCol: oppCol, one: true}).length >= 1 + ); } // Stop at first king found (TODO: multi-kings) @@ -2158,6 +2171,12 @@ export default class ChessRules { let container = document.getElementById(this.containerId) const r = container.querySelector(".chessboard").getBoundingClientRect(); + if (typeof move.start.x == "string") { + // Need to bound width/height (was 100% for reserve pieces) + const pieceWidth = this.getPieceWidth(r.width); + movingPiece.style.width = pieceWidth + "px"; + movingPiece.style.height = pieceWidth + "px"; + } const maxDist = this.getMaxDistance(r.width); const pieces = this.pieces(); if (move.drag) {