import { ChessRules } from "@/base_rules";
export class AbsorptionRules extends ChessRules {
+
getPpath(b) {
if ([V.BN, V.RN, V.QN].includes(b[1])) return "Absorption/" + b;
return b;
// p1 or p2 already have knight + other piece
return (p1 == V.KNIGHT ? p2 : p1);
}
+ if ([p1, p2].includes(V.QN)) return V.QN;
for (let p of [p1, p2]) {
- if (p == V.QN) return V.QN;
if ([V.BN, V.RN].includes(p))
return V.MergeComposed[[p1, p2].sort().join("")];
}
);
});
moves.forEach(m => {
- if (m.vanish.length == 2) {
+ if (
+ m.vanish.length == 2 &&
+ m.appear.length == 1 &&
+ piece != m.vanish[1].p
+ ) {
// Augment pieces abilities in case of captures
- const piece2 = m.vanish[1].p;
- if (piece != piece2) m.appear[0].p = V.Fusion(piece, piece2);
+ m.appear[0].p = V.Fusion(piece, m.vanish[1].p);
}
});
return moves;
notation += "=" + move.appear[0].p.toUpperCase();
return notation;
}
+
};