getMaxEnergy function from spaceship