while True:
flag = hero.findFlag()
enemy = hero.findNearestEnemy()
item = hero.findNearestItem()
distance = hero.distanceTo(item)
if flag:
# What happens when I find a flag?
hero.pickUpFlag(flag)
elif enemy:
# What happens when I find an enemy?
if hero.isReady("cleave"):
hero.cleave(enemy)
else:
hero.attack(enemy)
elif item:
# What happens when I find an item?
if item.distance <=6:
hero.moveXY(item.pos.x,item.pos.y)
Why my code is not working after the first pile of coins?