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

The one wizard help


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)
        hero.moveXY(28, 16)


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

1 Like