[Solved] Help with format of my code on: Challenge: The One Wizard

hello, i am trying to use definitions in my code so that my character can attack, however the code i have does not seem to be doing anything my hero just stands there any help would be great!

def regen(enemy):
    if hero.canCast("regen") == True and hero.findNearestEnemy == False:
        hero.cast("regen", hero)
    else:
        pass

def chain(enemy):
    if hero.canCast("chain-lightning"):
        hero.cast("chain-lightning", hero.findNearestEnemy())
    else:
        pass
    



while-True:
    enemy = hero.findNearestEnemy()
    if enemy:
        chain()
    else:
        regen()

I’m sure i have made a mistake somewhere however i just am not getting this concept.

Please learn to post your code correctly. The way it is now, we can’t see the structure. Help us help you. It’s very easy to do and just takes a tiny bit of effort. Please read this topic and format your code again correctly

1 Like

For starters, you have a hyphen between while and True. This is causing an infinite loop.

1 Like

Thank you! I completely forgot about that! :slight_smile: so much information bit of an overload. I’ve tweaked the code and managed to complete the level. I’m aware that it is against the rules to post a solution. So thank you, been sat staring at the screen for hours!