Wow… I can’t believe it…
My code works entirely, no bugs, I attack the shamans first (thank you SO much CryptiCrystal!! I figured it out!), but STILL… I run out of time!!!
Here is my code:
# Pender wants to test you on a series of trials. Use your boss star to clear off the ogres! Remember, you cannot move or attack in this level.
def summonTroops():
# These are just an example. Feel free to use griffin riders and/or other units!
if hero.gold >= 40:
hero.summon("soldier")
hero.summon("archer")
while True:
summonTroops()
friends = hero.findFriends()
# Iterate over all troops using a for loop. Make peasants collect coins. Combat troops fight.
#item = hero.findNearestItem()
enemy = hero.findNearestEnemy()
flag = hero.findFlag("green")
for friend in friends:
peasants = hero.findByType("peasant")
for peasant in peasants:
item = peasant.findNearestItem()
if friend.type == "peasant":
if item:
hero.command(friend, "move", item.pos)
if friend.type != "peasant":
if enemy:
hero.command(friend, "attack", enemy)
shamans = friend.findByType("shaman")
for shaman in shamans:
if shaman:
hero.command(friend, "attack", shaman)
#else:
# hero.command(friend, "attack", enemy)
else:
hero.command(friend, "move", Vector(30, 36))
# elif enemy and enemy.type == "shaman":
# hero.command(friend, "attack", enemy)