/// <summary> /// Initializes a new instance of the <see cref="Piece"/> class. /// </summary> /// <param name="name"> /// The piece name e.g. bishop, queen. /// </param> /// <param name="player"> /// The player that owns the piece. /// </param> /// <param name="file"> /// Board file that the piece starts on. /// </param> /// <param name="rank"> /// Board rank that the piece starts on. /// </param> /// <param name="identifier"> /// Piece identifier. /// </param> public Piece(PieceNames name, Player player, int file, int rank, PieceIdentifierCodes identifier) { this.LastMoveTurnNo = -1; this.IsInPlay = true; Square square = Board.GetSquare(file, rank); this.Player = player; this.StartLocation = this.Square = square; square.Piece = this; this.IdentifierCode = identifier; switch (name) { case PieceNames.Pawn: this.Top = new PiecePawn(this); break; case PieceNames.Bishop: this.Top = new PieceBishop(this); break; case PieceNames.Knight: this.Top = new PieceKnight(this); break; case PieceNames.Rook: this.Top = new PieceRook(this); break; case PieceNames.Queen: this.Top = new PieceQueen(this); break; case PieceNames.King: this.Top = new PieceKing(this); break; } }
/// <summary> /// Initializes a new instance of the <see cref="Piece"/> class. /// </summary> /// <param name="name"> /// The piece name e.g. bishop, queen. /// </param> /// <param name="player"> /// The player that owns the piece. /// </param> /// <param name="file"> /// Board file that the piece starts on. /// </param> /// <param name="rank"> /// Board rank that the piece starts on. /// </param> /// <param name="identifier"> /// Piece identifier. /// </param> public Piece(PieceNames name, Player player, int file, int rank, PieceIdentifierCodes identifier) { this.LastMoveTurnNo = -1; this.IsInPlay = true; Square square = Board.GetSquare(file, rank); this.Player = player; this.StartLocation = this.Square = square; square.Piece = this; this.IdentifierCode = identifier; switch (name) { case PieceNames.Pawn: this.Top = new PiecePawn(this); break; case PieceNames.Bishop: this.Top = new PieceBishop(this); break; case PieceNames.Knight: this.Top = new PieceKnight(this); break; case PieceNames.Rook: this.Top = new PieceRook(this); break; case PieceNames.Queen: this.Top = new PieceQueen(this); break; case PieceNames.King: this.Top = new PieceKing(this); break; } }