I am constantly getting an error saying i need an object
here is my code.
# Practice using modulo to loop over an array
# Choose the mix and order of units you want to summon by populating this array:
summonTypes = ["soldier", "archer", "soldier", "archer", "soldier", "archer"]
def summonTroops():
# Use % to wrap around the summonTypes array based on len(hero.built)
type = summonTypes[len(hero.built) % len(summonTypes)]
coin = hero.findNearest(hero.findItems())
if hero.gold >= hero.costOf(type):
hero.summon(type)
else:
hero.move(coin.pos)
def commandTroops():
friends=hero.findFriends()
for friend in friends != 'palisade':
enemies=hero.findEnemies()
enemy=soldier.findNearestEnemy()
if enemy:
hero.command(friend, "attack", enemy)
while True:
summonTroops()
commandTroops()
I have no idea what i did wrong.