Hi, I’m relatively new to coding its been about a week and the websites been great. I’m having abit of trouble with Mountain Mercenaries though. As far as I know the code works the character moves through the coins to the next summons soldiers and the soldiers attack but they get overwhelmed very easily. If possible can you advise me on this?
Heres my code: (the coin while loop is indented it just doesnt show properly on the block quote)
# Move to the nearest coin.
# Use move instead of moveXY so you can command constantly.
if hero.gold < hero.costOf(“soldier”):
while hero.gold < hero.costOf(“soldier”):
items = hero.findItems()
nearest = hero.findNearest(items)
# If you have funds for a soldier, summon one. if hero.gold > hero.costOf("soldier"): hero.summon("soldier") enemy = hero.findNearest(hero.findEnemies()) if enemy: # Loop over all your soldiers and order them to attack. soldiers = hero.findFriends() soldierIndex = 0 if soldiers: while len(soldiers) > soldierIndex: soldier = soldiers[soldierIndex] hero.command(soldier, "attack", enemy) soldierIndex += 1