X-Git-Url: https://git.auder.net/?p=xogo.git;a=blobdiff_plain;f=base_rules.js;h=d9adc0d93f3c131e7d8015f60fac63d8bbe51a8c;hp=4296ec5866485f44232666f3584cc02b41df9c07;hb=901d9d44ae85571ea671f3f2dbe26f81f0d90d66;hpb=9ac672172c605f9f5ea4355b8f743bcf189601fe diff --git a/base_rules.js b/base_rules.js index 4296ec5..d9adc0d 100644 --- a/base_rules.js +++ b/base_rules.js @@ -2580,12 +2580,31 @@ export default class ChessRules { this.animateFading(arr, () => targetObj.increment()); } } + targetObj.target += + this.tryAnimateCastle(move, () => targetObj.increment()); targetObj.target += this.customAnimate(move, segments, () => targetObj.increment()); if (targetObj.target == 0) callback(); } + tryAnimateCastle(move, cb) { + if ( + this.hasCastle && + move.vanish.length == 2 && + move.appear.length == 2 && + this.isKing(0, 0, move.vanish[0].p) && + this.isKing(0, 0, move.appear[0].p) + ) { + const start = {x: move.vanish[1].x, y: move.vanish[1].y}, + end = {x: move.appear[1].x, y: move.appear[1].y}; + const segments = [ [[start.x, start.y], [end.x, end.y]] ]; + this.animateMoving(start, end, null, segments, cb); + return 1; + } + return 0; + } + // Potential other animations (e.g. for Suction variant) customAnimate(move, segments, cb) { return 0; //nb of targets