Forgot to initialize maxEnergy.