Clash of Clones Help!


#21

can some one help me i can not unequip my sword


#22

This code worked for me-but you need to use the steel shield-with 60.4% blockage and the long sword. Here’s the code. You might need to try it a couple of times to work.

(Solution removed)


#23

Please don’t post solutions here. You will find this stated in many threads throughout this board. The purpose of Code Combat is to learn and force people to think. Simply providing the answers is not helpful and counter productive to the learning process. Thanks.


#24

Uh, I think you should put that another way, because now coding feels harsh.


#25

all you have to do is equip your weakest sword


#26

That person made that reply more than an year ago.


#27

Hi. I know the solution is to kill the archers first but i cant figure out how to prioritize the archers. Can u pls give me some tips?


#28

For killing one type of unit your code needs to look something like this:

def findArcher(units):
    for unit in units:
        if unit.type == "archer":
            return unit

while True:
    enemies = hero.findEnemies()
    archer = findArcher(enemies)
    if archer:
        hero.attack(archer)

That code will just attack archers and if there are none left your hero will stop attacking but you can add your own code. (your hero might also say “but it’s dead …” but that doesn’t matter)
Hope this helps :grin:


#29

here is my code i have been stuck for ages and i can’t take my sword :
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)

#30

please do not necropost, this is dead


#31

You have no right to blame others as you are the most prolific necroposter and you do more harm than good even when pretending to be helpful.


#32

Please format your code next time, or we can’t help, this is the last time we are going to do it for you.

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)

#33

Obviously you don’t need help and I deleted the code
Please delete all your other posts about the same topic


#34

here us my modified code
Reply

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)

#35

sos didn’t put the else:
attack


#36

################## no comment ##########


#37

please help me it kills all the soldiers and archers but not the clones and some orges


#38

########### no comment #################


#39

it dosen’t work ok u are not helping


#40

@starwars72015 this isn’t your code.

Because why would u put “if hero.isReady(“power-up”)” and “if hero.isReady(“cleave”)” in the same code? those abilities are mutually exclusive. You probably went and searched for some code and pasted it in and it doesn’t work. So no, we’re not going to help you.