Example #1
0
        private void PawnPromotion(IMove move, Piece pieceWhoMoves)
        {
            Piece wp = null;

            wp = GetPawnByColor(pieceWhoMoves, wp);
            if (wp.IsPromoted)
            {
                IArmy army = board.GetArmy(color);
                army.CapturedPiece(wp);
                var piece = move.CreatePiece(move.MoveAN.PromovatedTo, color, move.TargetPosition);
                army.AlivePieces.Add(piece);
            }
        }
Example #2
0
        public void MakeMove(IMove move)
        {
            if (move.TargetPosition.Piece != null)
            {
                IArmy army = board.GetArmy(GetOpponent());
                army.CapturedPiece(move.TargetPosition.Piece);
            }
            Piece pieceWhoMoves = move.InitialPosition.Piece;

            pieceWhoMoves.Cell         = move.TargetPosition;
            move.TargetPosition.Piece  = pieceWhoMoves;
            move.InitialPosition.Piece = null;
            pieceWhoMoves.IsMoved      = true;
            if (pieceWhoMoves is WhitePawn || pieceWhoMoves is BlackPawn)
            {
                PawnPromotion(move, pieceWhoMoves);
            }
        }