I complete the level but dont defeat the ogres becous hero move to x red …
there is a time metod? like to
if enemy <0:
hero.wait(30sec)
There is my code:
def scappa():
enemy = hero.findNearestEnemy()
if enemy and enemy.health > 0:
hero.attack(enemy)
else:
hero.moveXY(redX.x, redX.y)
whiteX = {'x':27, 'y':42}
redX = {'x':151 , 'y': 118}
hazards = hero.findHazards()
hero.moveXY(whiteX.x, whiteX.y)
max = 0
min = 999
index= 0
while index < len (hazards):
item = hazards[index]
if item.value > max:
max= item.value
if item.value < min:
min = item.value
index +=1
hero.say(max+min)
scappa()
See The new boots and move vs moveXY for explanation of your question. Replace loop: with while True: and self with hero in the old post.
So while using moveXY(x, y) you block all other actions and using move(position) you are much more flexible. Because move(position) works only within a loop the changes in your code will be:
def scappa():
# code...
hero.move(redX)
# code...
while True:
scappa()