Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[SOLVED] Mountain mercenaries Level help

# Gather coins to summon soldiers and have them attack the enemy.

while True:
    # Move to the nearest coin.
    # Use move instead of moveXY so you can command constantly.
    coin = hero.findNearestItem()
    # If you have funds for a soldier, summon one.
    if > hero.costOf("soldier"):
    enemy = hero.findNearest(hero.findEnemies())
    if enemy:
        soldiers = hero.findFriends()
        soldierIndex = 0
        soldier = soldiers[soldierIndex]
        # Loop over all your soldiers and order them to attack.
        hero.command(soldier, "attack", enemy)
        # Use the 'attack' command to make your soldiers attack.
        #hero.command(soldier, "attack", enemy)

No error messages, I just don’t know what to do.

loop through your soldiers, and use if coin

Just to add to what ninjagoo said you have to loop over you soldiers like you did in earlier Sarven desert coin levels. E.g. while coinIndex < len(coins): …etc.