X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FAbsorption.js;h=33c8351789925a1e71a906a41c8d49168e8ccdd4;hb=ded43c88fad60fd8f9bb46aabd67f3f2092f65f3;hp=efa01036cfe87c3fcf06d54c578acb436772dac8;hpb=107dc1bd5361e2538b1551bdcc37c1e90a444b83;p=vchess.git diff --git a/client/src/variants/Absorption.js b/client/src/variants/Absorption.js index efa01036..33c83517 100644 --- a/client/src/variants/Absorption.js +++ b/client/src/variants/Absorption.js @@ -1,6 +1,7 @@ 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; @@ -49,8 +50,8 @@ export class AbsorptionRules extends ChessRules { // 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("")]; } @@ -80,11 +81,23 @@ export class AbsorptionRules extends ChessRules { default: moves = super.getPotentialMovesFrom(sq); } + // Filter out capturing promotions (except one), + // because they are all the same. + moves = moves.filter(m => { + return ( + m.vanish.length == 1 || + m.vanish[0].p != V.PAWN || + [V.PAWN, V.QUEEN].includes(m.appear[0].p) + ); + }); 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; @@ -124,6 +137,13 @@ export class AbsorptionRules extends ChessRules { ); } + static get VALUES() { + return Object.assign( + { a: 12, e: 7, s: 5 }, + ChessRules.VALUES + ); + } + getNotation(move) { let notation = super.getNotation(move); if (move.vanish[0].p != V.PAWN && move.appear[0].p != move.vanish[0].p) @@ -131,4 +151,5 @@ export class AbsorptionRules extends ChessRules { notation += "=" + move.appear[0].p.toUpperCase(); return notation; } + };