Ok, so my code is:
while True:
hazards = hero.findHazards()
hazardIndex = 0
hazard = hazards[hazardIndex]
if hazard and hazard.type == "bear-trap" and hero.distanceTo(hazard) < 10:
while hero.gold > hero.costOf("archer"):
hero.summon("archer")
enemy = hero.findNearest(hero.findEnemies())
if enemy and enemy.type != "sand-yak":
soldiers = hero.findFriends()
# Loop over all your soldiers and order them to attack.
for soldier in soldiers:
if soldier.type != "decoy":
hero.command(soldier, "attack", enemy)
enemy = hero.findNearestEnemy()
if hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
else:
hero.attack(enemy)
else:
enemy = hero.findNearest(hero.findEnemies())
hero.buildXY("bear-trap", enemy.pos.x, enemy.pos.y)
@Eric_Tang or @milton.jinich help please.