private void AppendIfCanCapture( BoardSquare destSquare, MoveBuilder moveBuilder, Board.Board board, List <Move> moves, Action <MoveBuilder, List <Move> > moveAppender) { if (board.IsEmpty(destSquare)) { return; } var pieceAtDestSquare = board.GetPieceAt(destSquare); if (pieceAtDestSquare.player != player) { moveAppender( moveBuilder.SetDestSquare(destSquare).SetCapture(pieceAtDestSquare.piece), moves); } }