# 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", "soldier", "soldier"]
def summonTroops():
# Use % to wrap around the summonTypes array based on len(hero.built)
#type = summonTypes[???]
type = summonTypes[len(hero.built) % len(summonTypes)]
if hero.gold > hero.costOf(summonTypes[type]):
hero.summon(summonTypes[type])
def Item():
item = hero.findNearestItem()
if item:
hero.moveXY(item.pos.x, item.pos.y)
def Attack():
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
while True:
summonTroops()
Item()
Attack()
I don’t seem to be able to summon any troops? Thanks