[Solved] Clash of clones python


#1

to help people who are stuck on clash of clones code combat like me


#2

here is my code pls help:
while True:
enemyIndex = 0
enemies = self.findEnemies()
while enemyIndex < len(enemies) and self.health > self.maxHealth / 4:
enemy = enemies[enemyIndex]
enemyIndex += 1
if enemy.type != ‘sand-yak’:
while enemy.health > 0:
if self.isReady(“electrocute”):
hero.electrocute(enemy)
if self.isReady(“bash”):
hero.bash(enemy)
if self.isReady(“cleave”):
hero.cleave(enemy)
else:
self.attack(enemy)
if self.health <= self.maxHealth / 4:
enemy = enemies[enemyIndex]
enemy=hero.findNearestEnemy()
distance=hero.distanceTo(enemy)
enemyIndex += 1
while enemy.health>0 :

        if distance < 4:
            if self.isReady("cleave"):
                self.cleave(enemy)
            else:
                self.attack(enemy)
        else:
            self.attack(enemy)

#3

So are you posting a solution? If so please remove.

If not, (since you said pls help under that so idk whether you’re posting a solution or you need help with your code)

Please follow the Community Guidelines and post the code in a beautifully formatted fashion tyvm


#4

it is not a solution it is just that i need help


#5

have you tried shielding?


#6

and I suggest not using your amazing armor because then the clone has it. I also suggest that if you have more abilities, use them


#7

here is my new code
it kills all the archers


#8

while True:
enemyIndex = 0
enemies = self.findEnemies()
while enemyIndex < len(enemies) and self.health > self.maxHealth / 4:
enemy = enemies[enemyIndex]
enemyIndex += 1
if enemy.type != ‘sand-yak’:
while enemy.health > 0:
if self.isReady(“electrocute”):
hero.electrocute(enemy)
if self.isReady(“bash”):
hero.bash(enemy)
if self.isReady(“cleave”):
hero.cleave(enemy)
if self.isReady(“power up”):
self.powerUp()
else:
self.attack(enemy)
if self.health <= self.maxHealth / 4:
enemy = enemies[enemyIndex]
enemy=hero.findNearestEnemy()
distance=hero.distanceTo(enemy)
enemyIndex += 1
while enemy.health>0 :
if distance < 4:
if self.isReady(“cleave”):
self.cleave(enemy)
else:
self.attack(enemy)
else:
self.attack(enemy)


#9

i tried shielding but it just got worse


#10

please format your code, I have done it for you this time

while True:
enemyIndex = 0
enemies = self.findEnemies()
while enemyIndex < len(enemies) and self.health > self.maxHealth / 4:
enemy = enemies[enemyIndex]
enemyIndex += 1
if enemy.type != ‘sand-yak’:
while enemy.health > 0:
if self.isReady(“electrocute”):
hero.electrocute(enemy)
if self.isReady(“bash”):
hero.bash(enemy)
if self.isReady(“cleave”):
hero.cleave(enemy)
if self.isReady(“power up”):
self.powerUp()
else:
self.attack(enemy)
if self.health <= self.maxHealth / 4:
enemy = enemies[enemyIndex]
enemy=hero.findNearestEnemy()
distance=hero.distanceTo(enemy)
enemyIndex += 1
while enemy.health>0 :
if distance < 4:
if self.isReady(“cleave”):
self.cleave(enemy)
else:
self.attack(enemy)
else:
self.attack(enemy)


#11

ok
while True:
enemyIndex = 0
enemies = self.findEnemies()
while enemyIndex < len(enemies) and self.health > self.maxHealth / 4:
enemy = enemies[enemyIndex]
enemyIndex += 1
if enemy.type != ‘sand-yak’:
while enemy.health > 0:
if self.isReady(“electrocute”):
hero.electrocute(enemy)
if self.isReady(“bash”):
hero.bash(enemy)
if self.isReady(“cleave”):
hero.cleave(enemy)
if self.isReady(“power up”):
self.powerUp()
else:
self.attack(enemy)
if self.health <= self.maxHealth / 4:
enemy = enemies[enemyIndex]
enemy=hero.findNearestEnemy()
distance=hero.distanceTo(enemy)
enemyIndex += 1
while enemy.health>0 :
if distance < 4:
if self.isReady(“cleave”):
self.cleave(enemy)
else:
self.attack(enemy)
else:
self.attack(enemy)


#12

To format, use triple backticks above and below your code,


#13

sorry give me a second


#14

but my question is, do you really need to slow down your enemies if you are going into their range anyways?


#15

what items are you using also, it might be an equipment issue


#16

Take a look around the forum, there are several topics on Clash of Clones already.

It is not your equipment. This level is not about equipment, but about being clever.

Your enemy hero has all the same equipment as you, but your enemy hero doesn’t know how to use any special abilities. You do – so use them in clever ways.

Also, when you post code, use three backticks (the character on the key to the left of the 1 on most English keyboards) before and after your code so it is properly formatted.

if enemy:
    doThing()

The code you’ve posted has no tabs/spacing, which means it won’t work.


#17

i changed my code and finished the level


#18

that was a few day ago the i finished the level but thanks for the comments