Resource quality determines the evolution of resistance and its genetic basis