I have written the code below, but I could not clear the stage.
# Incoming munchkins! Defend the town! enemy = hero.findNearestEnemy() distance = hero.distanceTo(enemy) # Define your own function to fight the enemy! def cleaveOrAttack(): # In the function, find an enemy, then cleave or attack it. if enemy: if hero.isReady("cleave"): hero.cleave(enemy) else: hero.attack(enemy) pass # Move between patrol points and call the function. while True: hero.moveXY(35, 34) # Use cleaveOrAttack function you defined above. cleaveOrAttack() hero.moveXY(47, 27) # Call the function again. cleaveOrAttack() hero.moveXY(60, 31) # Call the function again. cleaveOrAttack()
Could you kindly tell me how should I need modify the code.