Can't pass cursed valley

to pass this level i need to kill 3 skeletons and stay alive. But my hero just can’t stay alive until the second skeleton shows up , even though he has drunk the potion
here’s my code:

while True:
enemies = hero.findEnemies()
if enemies:
for enemy in enemies:
if enemy.team == ‘ogres’ and enemy.type == ‘skeleton’:
hero.attack(enemy)

item = hero.findNearest(hero.findItems())
if item and item.type == 'potion' and hero.health < hero.maxHealth/4:
    hero.moveXY(item.pos.x, item.pos.y)

Could you show what the equipment you are using? (just a screenshot). I will try to reproduce it.

Thanks

Are you using “chain-lightning” for that level?

No, just hero.attack()

Hello,

can you send us an email at team@codecombat.com so that we can look over your session and see what may be wrong?

sure, thanks for your time

Sorry for the delay. Could you try it now? There was a problem with one of component changing and I made some rebalance things. Please tell me if you failure or success that level.

Thanks, finally it works fine.

Thanks ,i passed it . it works fine now. but i find another problem on another level… i tell u about it in a new post

Maybe there’s a new bug, but I can’t pass this either. I see three skeletons get killed, but it continues anyway and eventually fails because it times out. Here’s my code…

[Solution is correct, so it's removed]

Thanks!

1 Like

@AttackArmy Your code looks correct and I checked it with my hero - no problems. Could you sent me with direct messages your CodeCombat username or to the email team@codecombat.com? I will look at your game replay and try to find a problem.

Thanks for looking into it. It seemed very odd that it wasn’t completing. Here’s my user name…

Thanks. I see a problem, but not see where it is. Give me please some time to find it.

Ha! It was interesting. The “problem” was in “samurai + High tier damage sword”. As the result, your hero can kill a skeleton with one hit (411 damage in one hit). The level’s referee could not process that case.

Not it’s fixed (I changed the referee logic). Could you try it again? Please, use the direct link if you still have the same problem.

Thank you very much for the feedback - without it some players could stuck on this level and leave.

Hello I have a problem with my code or my aurmor my hero first get the potion but he will not attack the ogre’s skeleton

# The hot sun is draining the hero's health!

while True:
    enemy = hero.findNearestEnemy()
    # Attack if enemy exists AND enemy.team is "ogres"
    # AND enemy.type is "skeleton"
    if enemy and enemy.team == "ogres" and enemy.type == "skeleton":
        hero.attack(enemy)
    item = hero.findNearestItem()
    # Collect if item exists AND item.type is "potion"
    # AND hero.health is less than hero.maxHealth / 4
    if item and item.type == "potion" and hero.health < hero.maxHealth / 4:    
        hero.moveXY(item.pos.x, item.pos.y)

I can’t find it out :slightly_frowning_face: :slightly_frowning_face:

Hi wazi,

Check your code - you’re not quite following the instructions:

    # AND hero.health is less than hero.maxHealth / 4

Jenny