示例#1
0
        /// <summary>
        /// 内部方法:移动棋子,并更改FEN记录
        /// </summary>
        /// <param name="piece">被移动的棋子</param>
        /// <param name="srcPos">源棋格</param>
        /// <param name="tgtPos">目标棋格</param>
        private void PieceMoveIn(Piece piece, Enums.ActionCollection actions, Position srcPos, Position tgtPos)
        {
            switch (piece.PieceType)
            {
                #region case 王车易位,过路兵,升变
            case Enums.PieceType.WhiteKing:
            case Enums.PieceType.BlackKing:
            {
                //TODO:在这里实现王车易位
                break;
            }

            case Enums.PieceType.WhitePawn:
            case Enums.PieceType.BlackPawn:
            {
                //移走被吃的过路兵
                if (_piecePawnByEnPassanted != null)
                {
                    if (tgtPos.X == _piecePawnByEnPassanted.Position.X)
                    {
                        actions.Add(Enums.Action.EnPassant);
                        PieceMoveOut(_piecePawnByEnPassanted.Position);
                    }
                }
                //TODO:在这里实现“升变”
                break;
            }

            case Enums.PieceType.WhiteQueen:
            case Enums.PieceType.WhiteRook:
            case Enums.PieceType.WhiteBishop:
            case Enums.PieceType.WhiteKnight:
            case Enums.PieceType.BlackQueen:
            case Enums.PieceType.BlackRook:
            case Enums.PieceType.BlackBishop:
            case Enums.PieceType.BlackKnight:
            case Enums.PieceType.AllKings:
            case Enums.PieceType.AllQueens:
            case Enums.PieceType.AllRooks:
            case Enums.PieceType.AllBishops:
            case Enums.PieceType.AllKnights:
            case Enums.PieceType.AllPawns:
            case Enums.PieceType.All:
            case Enums.PieceType.None:
            default:
                break;
                #endregion
            }
            piece.Position = tgtPos;
            this.SetByPosition(srcPos.Dot, '1');
            this.SetByPosition(tgtPos.Dot, Enums.FromPieceType(piece.PieceType)[0]);
            this.GameSide = Enums.GetOtherGameSide(this.GameSide);
            if (this.GameSide == Enums.GameSide.White)
            {
                this.FullMoveNumber++;
            }
            this.HalfMoveClock++;
        }
示例#2
0
 /// <summary>
 /// 重写。生成该棋子的字符表示。
 /// </summary>
 /// <returns>大写表示为白棋,小写表示黑棋</returns>
 public override string ToString()
 {
     return(Enums.FromPieceType(this.PieceType));
 }