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

[SOLVED] Mountain Mercenaries help please [python]

My hero moves, collects coins and summons soldiers, and my soldiers attack enemies. But my soldiers get overwhelmed by enemies and die. while my hero is left running around collecting coins to eventually die to the enemies.

while True:
    coin = self.findNearestItem()
    self.move(coin.pos)
    
    
    if hero.gold > hero.costOf("soldier"):
        self.summon("soldier")
        
    enemy = hero.findNearest(hero.findEnemies())
    if enemy:
        soldiers = hero.findFriends()
        soldierIndex = 0
        soldier = soldiers[soldierIndex]
        
        while soldierIndex < len(soldiers):
            soldier = soldiers[soldierIndex]
            hero.command(soldier, "attack", enemy)
            soldierIndex +=1
            

Hi exotic, welcome to the CodeCombat discourse!
Your code works for me… The soldiers kill all the ogres. Could you show me your equipment and the level screen. (In a screenshot)
Thanks
Danny

1 Like

Thanks for the reply,
I just managed to complete it, when you asked to look at my equipment it made me question it.
I replaced my boots with faster ones and it completed.
Thanks for the help
Cameron

1 Like