New level : Bonemender


I’m not sure if I need to start a new thread or not…

I’m at wits end. The same code that regens Bernard is NOT working for Chandra. I checked the if nesting and the second if exp. is nested but Chandra is not getting her regen.

How sensitive to correct spacing is the python ‘emulator’ to spacing?
Is this
different from this?
hero.cast("regen", "Chandra")

Please advise.

NOTE: I was able to pass the level but Chandra never got her regen… :confused:

# Heal allied soldiers to survive the siege.
while True:
    if hero.canCast("regen"):
        #if expresssion 1
        bernardDistance = hero.distanceTo("Bernard")
        if bernardDistance < 10:
            # Bernard needs regeneration!
            hero.cast("regen", "Bernard")
            # Use "if" and "distanceTo" to regenerate "Chandra"
            # if she is closer than 10 meters away.
            chandraDistance = hero.distanceTo("Chandra")
            #if expression 2 must be nested
            if chandraDistance < 10:
            # Chandra needs regeneration!
        enemy = hero.findNearestEnemy()
        # If you aren't casting "regen", use "if" and "distanceTo"
        # to attack enemies that are closer than hero.attackRange.
        if enemy:
            distance = hero.distanceTo(enemy)
            if distance < 10:
                hero.say("Come closer my pretty")


Look at the indentation. The Chandra part is only ran if bernardDistance < 10.


This post was flagged by the community and is temporarily hidden.


This post was flagged by the community and is temporarily hidden.