This is my code for lvl 1 of cloudrip brawl, I collect the coins and summon my soldiers, but mosst of them just stand still and get killed. I would like all of them to attack the same enemie, and then go on to the next enemie, but I haven’t figure it out now. I understand the problem, but I just can’t find the solution, I have tried a lot of possible solutions with the while loop, but none of them seems to work.
loop:
enemies = self.findEnemies()
enemy = self.findNearest(enemies)
coins = self.findItems()
coin = self.findNearest(coins)
friends = self.findFriends()
friend = self.findNearest(friends)
if coin:
self.move(coin.pos)
if self.gold > 20:
self.summon("soldier")
if enemy:
self.command(friend, "attack", enemy)
if enemy:
self.command(friend, "attack", enemy)