# Protect the cage.
# Put a soldier at each X.
points = []
points[0] = {"x": 33, "y": 42}
points[1] = {"x": 47, "y": 42}
points[2] = {"x": 33, "y": 26}
points[3] = {"x": 47, "y": 26}
while hero.gold <=80:
coin = hero.findNearest(hero.findItems())
if coin:
hero.move(coin.pos)
for i in range(4):
hero.summon("soldier")
while True:
friends = hero.findFriends()
for j in range(len(friends)):
point = points[j]
friend = friends[j]
enemy = friend.findNearestEnemy()
if enemy and enemy.team == "ogres" and friend.distanceTo(enemy) < 5:
hero.command(friend, "attack", enemy)
if friend:
hero.command(friend, "move", point)
I’m having some issues learning how to control troops. I’ve used “hero.command(friend, “move”, point)” to correctly move all of the troops, but like some other post I found, I was having the issue where my if loop never ends, thus my troops never being able to attack. using a break only moves one of my troops. If you could explain how to use break (or give me the level where it was explained) and a solution to that part of the code that would be great. Thanks!
(just a note im not asking for a solved code just what would end the if-loop after 4 runs through it)