Hey i need help to pass this one level and my character stops in the middle of the challenge
while True:
items = hero.findItems()
enemy = hero.findNearestEnemy()
bestItem = None
bestValue = 0
itemsIndex = 0
# Loop over the items array.
# Find the item with the highest valueOverDistance()
while itemsIndex < len(items):
item = items[itemsIndex]
if item.value / hero.distanceTo(item) > bestValue:
bestItem = item
bestValue = item.value / hero.distanceTo(item)
itemsIndex += 1
if enemy:
NEDistance = hero.distanceTo(enemy)
if bestItem:
BIDistance = hero.distanceTo(bestItem)
if enemy and NEDistance <= 5:
if hero.isReady("dash"):
hero.dash(enemy)
elif hero.isReady("cleave"):
hero.cleave(enemy)
elif hero.isReady("punch"):
hero.punch(enemy)
elif hero.isReady("bash"):
hero.bash(enemy)
else:
hero.attack(enemy)
elif bestItem and BIDistance >= 10 :
if hero.isReady("dash"):
hero.dash(bestItem)
else:
hero.moveXY(bestItem.pos.x, bestItem.pos.y)
elif bestItem and BIDistance <= 9 :
hero.moveXY(bestItem.pos.x, bestItem.pos.y)