Zoo Keeper stuck

What is the name of the cage. I need to know so I can not attack it.

No worries–the cage is not on the Ogres team, thus the if enemy and enemy.team == "ogres" in the code. :slight_smile:

1 Like

Yay!!! I got it! Thank you for your help.

points = []
points[0] = {"x": 33, "y": 42}
points[1] = {"x": 47, "y": 42}
points[2] = {"x": 33, "y": 26}
points[3] = {"x": 47, "y": 26}

while hero.gold <=80:
    coin = hero.findNearest(self.findItems())
    if coin:
        self.move(coin.pos)
for i in range(4):
    self.summon("soldier")

while True:
    
    friends = hero.findFriends()
    for j in range(len(friends)):
        point = points[j]
        friend = friends[j]
        enemy =  friend.findNearestEnemy()
        if enemy and enemy.team == "ogres" and friend.distanceTo(enemy) < 5:
            hero.command(friend, "attack", enemy)
                
        if friend:
            hero.command(friend, "move", point)


I am having a problem with my code. Everything works fine except that the soldiers don’t attack. Please help!

Nevermind, I fixed it.

Hi @Awesome000000000, Welcome to the CodeCombat discourse.
I’m glad you’ve solved the level, but please could you not post the answer (e.g. saying how you fixed it.) because it can ruin it for other people and it’s not the forum’s purpose. If you could delete your post, or edit it to remove the solution that would be great. :grin:
Thank you very much,
Danny

Ok, sorry. I didn’t know that.

Ok.the code is fixed, but will someone explain why the previous if: if: code didn’t work?

I’m not sure but I think it might see it as a different section or something and it doesn’t include it.