Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

(solved) Keeping Time - python

I’ve been trying to complete this for days. So far I have completed everything except for keeping the other hero alive.

# Use your new skill to choose what to do: hero.time

while True:
    coin = hero.findNearestItem()
    enemy = hero.findNearestEnemy()
    cleave = hero.isReady("cleave")
    # If it's the first 10 seconds, attack.
    if hero.time < 10:
        if cleave:
            hero.cleave(enemy)
        else:
            hero.attack(enemy)
        pass
    # Else, if it's the first 35 seconds, collect coins.
    elif hero.time < 35:
        hero.moveXY(coin.pos.x, coin.pos.y)
        pass
    # After 35 seconds, attack again!
    elif hero.time > 35:
        if cleave:
            hero.cleave(enemy)
        else:
            hero.attack(enemy)
        pass

It may be that you need a better sword or better armor.

Ok, I’ll get better stuff and try again.

just use if hero.isReady("cleave"): it’s much easier

I think you should define coin again after this?

Thanks for the suggestions. I got some new armor and completed the level.

Great! then, so that others know which comments helped, could you tick the solution box at the bottom of the most helpful post?

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.