+
+ if (
+ this.options["cannibal"] &&
+ this.options["rifle"] &&
+ this.pawnSpecs.promotions
+ ) {
+ // In this case a rifle-capture from last rank may promote a pawn
+ const lastRank = (color == "w" ? 0 : this.size.x - 1);
+ let newMoves = [];
+ moves.forEach(m => {
+ if (
+ m.start.x == lastRank &&
+ m.appear.length >= 1 &&
+ m.appear[0].p == "p" &&
+ m.appear[0].x == m.start.x &&
+ m.appear[0].y == m.start.y
+ ) {
+ const promotionPiece0 = this.pawnSpecs.promotions[0];
+ m.appear[0].p = this.pawnSpecs.promotions[0];
+ for (let i=1; i<this.pawnSpecs.promotions.length; i++) {
+ let newMv = JSON.parse(JSON.stringify(m));
+ newMv.appear[0].p = this.pawnSpecs.promotions[i];
+ newMoves.push(newMv);
+ }
+ }
+ });
+ Array.prototype.push.apply(moves, newMoves);
+ }
+