From 259035ec507062fdfc7158ac62b68c722404bfdf Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Wed, 20 Jan 2021 18:45:35 +0100 Subject: [PATCH] [Otage] fix black pawn promoting with white pawn in hostage --- client/src/variants/Otage.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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; -- 2.44.0