Clash of Clones Solution

I need help with Clash of Clones. It says my code is really slow. Here is my code:

var enemies = hero.findEnemies();
var enemyIndex = 0;
while (enemyIndex < enemies.length) {
var enemy = enemies[enemyIndex];
if (enemy) {
while (enemy.health >= 0) {
if (hero.canCast("chain-lightning", enemy)) {
hero.cast("chain-lightning", enemy);
} else {
hero.attack(enemy);
}
}
}
enemyIndex++;
}

Well your indentation is wrong.

1 Like

Its better to have indented code but I dont think you really have to keep it indented like python does

he doesn’t have boss star

clash of clones is desert boss star is cloudrip

:man_facepalming:
Sorry I am so dumb
I thought this was summits gate
(yes I know the title says clash of clones)

so @BMoney you should use a cleave sword or just a shield that can bash

What equipment do you have

Try to cleave near enemy archers.

chain lightning basically does that…

But it’s more expensive.

true but @BMoney has the gloves since his code has the cast chain-lightning code

Try to chain lightning to enemy archers.
Ok @Falcons118

but wont the chain lightning bounce of the enemy to the archers anyway?