From: H.G. Muller Date: Sat, 8 Jan 2011 23:05:38 +0000 (+0100) Subject: Fix Spartan promotion to King X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=6076ddce2ec3b939ebc4b9cfdbae52c2476ab17d;p=xboard.git Fix Spartan promotion to King Promotions toKing were refused when in check, because XBoard thought they would not resolve the check. Now the promotion is actually performed before doing the check test. --- diff --git a/moves.c b/moves.c index 594bb12..17c1239 100644 --- a/moves.c +++ b/moves.c @@ -723,10 +723,15 @@ void GenLegalCallback(board, flags, kind, rf, ff, rt, ft, closure) { register GenLegalClosure *cl = (GenLegalClosure *) closure; - if (!(flags & F_IGNORE_CHECK) && - CheckTest(board, flags, rf, ff, rt, ft, + if (!(flags & F_IGNORE_CHECK) ) { + int check, promo = (gameInfo.variant == VariantSpartan && kind == BlackPromotion); + if(promo) board[rf][ff] = BlackKing; // [HGM] spartan: promote to King before check-test + check = CheckTest(board, flags, rf, ff, rt, ft, kind == WhiteCapturesEnPassant || - kind == BlackCapturesEnPassant)) return; + kind == BlackCapturesEnPassant); + if(promo) board[rf][ff] = BlackLance; + if(check) return; + } if (flags & F_ATOMIC_CAPTURE) { if (board[rt][ft] != EmptySquare || kind == WhiteCapturesEnPassant || kind == BlackCapturesEnPassant) { @@ -1167,6 +1172,8 @@ if(appData.debugMode)fprintf(debugFP,"SHOGI promoChar = %c\n", promoChar ? promo if (cl.kind == WhitePromotion || cl.kind == BlackPromotion) { if(CharToPiece(flags & F_WHITE_ON_MOVE ? ToUpper(promoChar) : ToLower(promoChar)) == EmptySquare) cl.kind = ImpossibleMove; // non-existing piece + if(gameInfo.variant == VariantSpartan && cl.kind == BlackPromotion && promoChar != PieceToChar(BlackKing) && + CheckTest(board, flags, rf, ff, rt, ft, FALSE)) cl.kind = IllegalMove; // [HGM] spartan: only promotion to King was possible } else { cl.kind = IllegalMove; }