Hi! My code doesn’t seem to do anything at all. I’m getting the X underneath my hero, but the duck doesn’t say why. The duck isn’t even there at all. Can someone check and see if something is wrong?
Code:
# The ogres are trapping you with their dark rituals!
# Your hero can't do anything besides command and move without angering the warlocks.
# Beware ice, robots, traps, antigravity fields, and other dark magic.
# Somehow, you'll need to defeat Nalfar and save your paladin.
# The great treasure of Kelvintaph awaits your victory.
hero.moveXY(34, 15)
hero.moveXY(34, 7)
def commandSoldiers():
soldiers = hero.findByType("soldiers")
for soldier in soldiers:
enemy = soldier.findNearestEnemy()
hero.command(archer, "move", {'x': 75, 'y': 73})
necro = hero.findNearest(hero.findByType("necromancer"))
if necro:
hero.command(soldier, "attack", necro)
elif enemy:
hero.command(soldier, "attack", enemy)
def commandArchers():
archers = hero.findByType("archer")
for archer in archers:
hero.command(archer, "move", {'x': 75, 'y': 73})
enemy = hero.findNearest(hero.findByType("necromancer"))
if necro:
hero.command(archer, "attack", necro)
elif enemy:
hero.command(archer, "attack", enemy)
def commandPaladins():
paladin = hero.findFriends()
enemy = hero.findByType("necromancer")
if enemy and paladin:
hero.command(paladin, "shield")
if paladin.health <= 400:
hero.command(paladin, "heal", paladin)
while True:
commandSoldiers()
commandPaladins()
commandArchers()