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