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

[SOLVED] Help With ice hunter please

hi. i’m completely confused as to what to do on this level. here is my code:

def isSubstring(word, substring):
    rightEdge = len(word) - len(substring)
    for i in range(rightEdge + 1):
        for j in range(len(substring)):
            shiftedIndex = i + j
            if word[shiftedIndex] != substring[j]:
                break
            if j == len(substring) - 1:
                return True
    return False

enemies = hero.findEnemies()
for e  in range(len(enemies)):
    enemy = enemies[e]
    if isSubstring(enemy, "bos"):
        hero.attack(enemy)

Here put instead of enemy enemy.id and it should work fine.

1 Like

To add to what @AnSeDra said, you may need to loop your attacking (until the yak is dead) unless you’ve got a sword like the rune sword with very high damage in each attack. Otherwise (as you may find out) your hero attacks the yak once, then moves on to the next, even if the previous one is still alive.
Danny

2 Likes

Yes, sorry that I forgot telling you that.

1 Like

hi @AnSeDra and @Deadpool198. i beat the level. i have ritic and use the precision rifle. i accidentally hit a big yak though, while targeting a smaller one. :rofl:

1 Like

Congratulations! :partying_face:

2 Likes

for some reason i can’t edit the title :thinking:

1 Like