Hello,
I’m very stuck in Clash of Clones and I’m not sure how to solve it. I tried different ways but nothing seems to be working.
In the last iteration, I wanted to use “chain-lightning” which it works, but I’m having an issue where the hero says “but it’s dead”. I think what’s happening is that when I use the chain-lightning, I’m killing multiiple enemies, so my enemyIndext gets thrown off, so he’s trying to kill someone that’s already dead. I’m not quite sure how to fix that. Any ideas?
This is my code.
def attackArchers():
enemies = hero.findByType("archer", hero.findEnemies())
archerIndex = 0
if enemies:
archer = enemies[archerIndex]
while archerIndex < len(enemies):
killed = []
if hero.canCast("chain-lightning", archer):
hero.cast("chain-lightning", archer)
enemies = hero.findByType("archer", hero.findEnemies())
else:
hero.attack(archer)
archerIndex += 1
# enemies = hero.findByType("archer", hero.findEnemies())
while True:
attackArchers()