i need help with this level
this is the code:
while True:
paladins = []
enemies = hero.findNearestEnemy()
greenFlag = hero.findFlag("green")
blackFlag = hero.findFlag("black")
violetFlag = hero.findFlag("violet")
if violetFlag:
friends = hero.findFriends()
if friends:
for friend in friends:
if friend:
hero.command(friend, "move", violetFlag.pos)
if greenFlag:
hero.pickUpFlag(greenFlag)
if blackFlag:
hero.pickUpFlag(blackFlag)
hero.attack(enemy)
if hero.canCast("invisibility", hero):
hero.cast("invisibility", hero)
friends = hero.findFriends()
for enemy in hero.findEnemies():
friends = hero.findFriends()
for friend in friends:
e = friend.findNearestEnemy()
if e:
hero.command(friend, "attack", e)
fire = hero.findNearestEnemy()
if fire:
while fire.health > 0:
if hero.canCast("invisibility", hero):
hero.cast("invisibility", hero)
hero.attack(fire)
hero.shield()
if fire.type == "tower":
pass
if hero.gold > hero.costOf("soldier"):
hero.summon("soldier")
if hero.health < 3000:
for friend in friends:
if friend and friend.type == "paladin":
if friend.canCast("heal"):
hero.command(friend, "cast", "heal" , hero)