public void UndoMove(ChessMove move) { if(move == null) { throw new ArgumentNullException("move"); } var oldBlackLocations = this.BlackLocations; var oldWhiteLocations = this.WhiteLocations; if(move.PieceMoved.Colour == ChessColour.Black) { oldBlackLocations[move.FromIndex] = true; oldBlackLocations[move.ToIndex] = false; } else { oldWhiteLocations[move.FromIndex] = true; oldWhiteLocations[move.ToIndex] = false; } Locations[move.ToIndex].Piece = null; Locations[move.FromIndex].Piece = move.PieceMoved; if(move.PieceTaken != null) { if(move.PieceTaken.Colour == ChessColour.Black) { oldBlackLocations[move.ToIndex] = true; } else { oldWhiteLocations[move.ToIndex] = true; } Locations[move.ToIndex].Piece = move.PieceTaken; } this.BlackLocations = oldBlackLocations; this.WhiteLocations = oldWhiteLocations; }
public void MakeMove(ChessMove move) { this.MakeMove(move.FromIndex, move.ToIndex); }