From e2d0290abb13270cee39783b764907e4bcd97e93 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Thu, 28 May 2020 22:41:24 +0200 Subject: [PATCH] Allow entry of shogi promotions in any variant Defining pieces as shogi-promotion partners did not cause triggering of the promotion procedure when the corresponding basic piece reached the zone for variants other than (Chu) Shogi. Now HasPromotionChoice() recognizes pieces with a partner with ID '+' as promoting in any variant. In variant fairy promotion on leaving the zone is now suppressed. (This used to be only the case in variant elven.) This allows two-stage promotions, where a Pawn first promote to a basic piece, and after leaving the zone, the basic piece can promote again to its fixed partner. (Like in Chess and a Half.) --- backend.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/backend.c b/backend.c index 048fd0a..5ad3e36 100644 --- a/backend.c +++ b/backend.c @@ -6757,6 +6757,7 @@ HasPromotionChoice (int fromX, int fromY, int toX, int toY, char *promoChoice, i if(legal[toY][toX] == 4) return FALSE; piece = boards[currentMove][fromY][fromX]; + if(PieceToChar(CHUPROMOTED(piece)) == '+') highestPromotingPiece = WhiteKing; // always obey PTC table if(gameInfo.variant == VariantChu) { promotionZoneSize = (BOARD_HEIGHT - deadRanks)/3; if(legal[toY][toX] == 6) return FALSE; // no promotion if highlights deny it @@ -6779,12 +6780,13 @@ HasPromotionChoice (int fromX, int fromY, int toX, int toY, char *promoChoice, i if((int)piece >= BlackPawn) { if(toY >= promotionZoneSize && fromY >= promotionZoneSize) return FALSE; - if(fromY < promotionZoneSize && gameInfo.variant == VariantChuChess) return FALSE; + if(fromY < promotionZoneSize && (gameInfo.variant == VariantChuChess || gameInfo.variant == VariantFairy)) return FALSE; highestPromotingPiece = WHITE_TO_BLACK highestPromotingPiece; } else { if( toY < BOARD_HEIGHT - deadRanks - promotionZoneSize && fromY < BOARD_HEIGHT - deadRanks - promotionZoneSize) return FALSE; - if(fromY >= BOARD_HEIGHT - deadRanks - promotionZoneSize && gameInfo.variant == VariantChuChess) + if(fromY >= BOARD_HEIGHT - deadRanks - promotionZoneSize && + (gameInfo.variant == VariantChuChess || gameInfo.variant == VariantFairy)) return FALSE; } -- 1.7.0.4