From: Benjamin Auder Date: Wed, 20 Jan 2021 17:45:35 +0000 (+0100) Subject: [Otage] fix black pawn promoting with white pawn in hostage X-Git-Url: https://git.auder.net/doc/html/%3C?a=commitdiff_plain;h=259035ec507062fdfc7158ac62b68c722404bfdf;p=vchess.git [Otage] fix black pawn promoting with white pawn in hostage --- diff --git a/client/src/variants/Otage.js b/client/src/variants/Otage.js index 6c2b1ec0..9eb900a4 100644 --- a/client/src/variants/Otage.js +++ b/client/src/variants/Otage.js @@ -255,7 +255,14 @@ export class OtageRules extends ChessRules { // Transformation computed without taking union into account const up = this.getUnionPieces(initColor, initPiece); let args = [tr.p, up[oppCol]]; - if (['a', 'v'].includes(initColor)) args = args.reverse(); + if ( + ['a', 'v'].includes(initColor) || + // HACK: "ba" piece = two pawns, black controling. + // If promoting, must artificially imagine color was 'a': + (initPiece == 'a' && initColor == 'b') + ) { + args = args.reverse(); + } const capturer = (['a', 'b'].includes(initColor) ? 'b' : 'w'); const cp = this.getUnionCode(args[0], args[1], capturer); tr.c = cp.c;