My code for "Clash of Clones" in Python is being wonky and I don't know why

Yeah. Unequip the runesword. And you’ll win. (If the level doesn’t let you to not have a weapon, put on a simple sword.)

XD now clone does 6 damage.

So did you win? :smiley:

Have to edit one thing to chain-lightning all archers

Shoot she attacked a yak

I told her not to attack yaks…

You don’t have to chain-lightning all of them. You can leave 1 behind, if it means that you won’t anger a yak.

After she chain-lightninged she attacked a yak. She walked up to it and hit it.

Then just 1. Delete all of your code then 2. Re-code it (line by line, no loops or anything) and make sure she doesn’t touch the yak.

Oh and don’t re-load your level (don’t refresh the page or anything) since then after you come back you can’t do control-Z (that’s what I do all the time. Life hacks.)

I think the line that does it is

if enemy.type != "sand-yak" or "anya" or "archer":

but I don’t know why

Yeah you have to do “if enemy.type !=” separately for each one.

When I ran it it said success… submitting it…

And now it’s incomplete. She still dies.

Okay what’s your code now

hero.moveXY(66, 90)
hero.moveXY(81, 87)

def defeatAllEnemies():
    enemy = hero.findNearestEnemy()
    if enemy and enemy.type == "anya":
        if hero.isReady("invisibility"):
            hero.cast("invisibility", hero)
            if hero.canCast("chain-lightning", enemy):
                hero.cast("chain-lightning", enemy)
            else:
                hero.attack(enemy)
                hero.shield()
                if enemy.health <= 0:
                    enemy = hero.findNearestEnemy()
    if enemy and enemy.type == "archer":
        if hero.canCast("chain-lightning", enemy):
            hero.cast("chain-lightning", enemy)
        else:
            hero.attack(enemy)
            hero.shield
        if enemy.health <= 0:
            enemy = hero.findNearestEnemy()
    if enemy.type != "sand-yak":
        if enemy.type != "anya":
            if hero.isReady("invisibility"):
                hero.cast("invisibility", hero)
                hero.attack(enemy)
            elif hero.isReady("bash"):
                hero.bash(enemy)
            elif hero.isReady("electrocute"):
                hero.electrocute(enemy)
            else:
                hero.attack(enemy)
                hero.shield()
                if enemy.health <= 0:
                    enemy = hero.findNearestEnemy()


while True:
    defeatAllEnemies()
    if hero.health <= 50:
        targetPos = (20, 101)
        hero.moveXY(targetPos)

/\ My code now. She almost survived, too.

Argh now it’s my little sister’s turn on the computer

I’ll check when I get back

Then don’t post so much. Instead edit your previous posts if you want to say something new.

Hm I never ran out of daily posts. Didn’t even know it’s a thing :stuck_out_tongue:

Okay. Completely de-armor yourself. Then keep spamming submit until you win :smiley:

btw you are supposed to have a 5 line solution for this level

? It doesn’t say that in the requirements

I didn’t have to spam I did it once and won

:no_mouth:

Congrats @BookFanatic while i was sleeping you did all of that ! :smile:

1 Like