[Solved] Help Needed with Siege of Stonehold


#1

This is my code:
while True:
enemy = self.findNearestEnemy()
flag = self.findFlag(“green”)
if flag:
self.pickUpFlag(flag)
elif enemy:
if self.isReady(“cleave”):
self.cleave(enemy)
else:
self.attack(enemy)
But for some reason, it doesn’t work


#2

Could you pls format your code with 3 backticks


#3


#4

I fixed it, it was just where i was placing my flag


#5

Oh i got the problem . You have to say if enemy: then attack.


#6

Actually when all of the enemies are dead you will get a problem or if there are no enemy’s @Garv_Jain


#7

In the else loop you have to put an if enemy:
then you have to put under it hero.attack(enemy)