Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

The one wizard help

#1

Is there something wrong with my code?

# Defeat as many ogres as you can.
# Use 'cast' and 'canCast' for spells.
while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        if hero.canCast("chain-lightning"):
            hero.cast("chain-lightning", enemy)
    elif enemy:
        if hero.canCast("lightning-bolt"):
            hero.cast("lightning-bolt", enemy)
    else:
        hero.moveXY(28, 16)


#2

Why are you using elifs and ifs to check for an enemy? Merge those two into one if statement

1 Like