X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=moves.c;h=769604d4613b3338c5eac1f1b1f0cf874c71a9aa;hb=50834a5d1deb1fa3f3edd73c61be0e55b89a637d;hp=594bb124edf60047676fadfd4e3f6d13683b8dca;hpb=e3e3615246633473d0ea262f6d3974d6a49cfd01;p=xboard.git diff --git a/moves.c b/moves.c index 594bb12..769604d 100644 --- a/moves.c +++ b/moves.c @@ -5,7 +5,7 @@ * Massachusetts. * * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006, - * 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + * 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. * * Enhancements Copyright 2005 Alessandro Scotti * @@ -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) { @@ -1165,8 +1170,23 @@ if(appData.debugMode)fprintf(debugFP,"SHOGI promoChar = %c\n", promoChar ? promo if (promoChar != NULLCHAR) { if(promoChar == '=') cl.kind = IllegalMove; else // [HGM] shogi: no deferred promotion outside Shogi if (cl.kind == WhitePromotion || cl.kind == BlackPromotion) { - if(CharToPiece(flags & F_WHITE_ON_MOVE ? ToUpper(promoChar) : ToLower(promoChar)) == EmptySquare) + ChessSquare piece = CharToPiece(flags & F_WHITE_ON_MOVE ? ToUpper(promoChar) : ToLower(promoChar)); + if(piece == EmptySquare) cl.kind = ImpossibleMove; // non-existing piece + if(gameInfo.variant == VariantSpartan && cl.kind == BlackPromotion ) { + if(promoChar != PieceToChar(BlackKing)) { + if(CheckTest(board, flags, rf, ff, rt, ft, FALSE)) cl.kind = IllegalMove; // [HGM] spartan: only promotion to King was possible + if(piece == BlackLance) cl.kind = ImpossibleMove; + } else { // promotion to King allowed only if we do not haave two yet + int r, f, kings = 0; + for(r=0; r