From 635418a5af6d4bf3f497d319a235bf72e40c5683 Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Mon, 9 May 2022 09:50:13 +0200 Subject: [PATCH] Debugging --- base_rules.js | 17 ++++++++++++----- variants/Absorption/class.js | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/base_rules.js b/base_rules.js index d743c0e..2d95f6c 100644 --- a/base_rules.js +++ b/base_rules.js @@ -2180,6 +2180,9 @@ export default class ChessRules { const [i2, j2] = move.segments[index][1]; const dep = this.getPixelPosition(i1, j1, r); const arr = this.getPixelPosition(i2, j2, r); + +console.log(dep,arr); //TODO: this seems right, but translations don't work well. + // Start from i1, j1: movingPiece.style.transform = `translate(${dep[0] - ix}px, ${dep[1] - iy}px)`; @@ -2192,12 +2195,15 @@ export default class ChessRules { movingPiece.style.transitionDuration = duration + "s"; setTimeout(cb, duration * 1000); }; - if (!move.segments) - move.segments = [[move.start.x, move.start.y], [move.end.x, move.end.y]]; + if (!move.segments) { + move.segments = [ + [[move.start.x, move.start.y], [move.end.x, move.end.y]] + ]; + } let index = 0; - animateSegment(index, () => { + const animateSegmentCallback = () => { if (index < move.segments.length) - animateSegment(++index); + animateSegment(index++, animateSegmentCallback); else { if (move.drag) movingPiece.remove(); @@ -2207,7 +2213,8 @@ export default class ChessRules { } callback(); } - }); + }; + animateSegmentCallback(); } playReceivedMove(moves, callback) { diff --git a/variants/Absorption/class.js b/variants/Absorption/class.js index 3979662..9fe43aa 100644 --- a/variants/Absorption/class.js +++ b/variants/Absorption/class.js @@ -143,7 +143,7 @@ export default class AbsorptionRules extends ChessRules { m.appear[0].p = V.Fusion(m.vanish[0].p, m.vanish[1].p); } }); - super.postProcessPotentialMoves(moves); + return super.postProcessPotentialMoves(moves); } }; -- 2.44.0