I’m stuck in Reaping Fire. Although no errors occur, my griffin-riders do not move and I suppose something is wrong with how “enumerate” is used. Could someone please tell me where I’m wrong? Thank you for your knowledge.
def chooseStrategy():
enemy = hero.findNearestEnemy()
# If you can summon a griffin-rider, return "griffin-rider"
if hero.gold > hero.costOf("griffin-rider"):
return "griffin-rider"
# If there is a fangrider on your side of the mines, return "fight-back"
elif enemy and enemy.type == "fangrider" and enemy.pos.x < 37:
return "fight-back"
# Otherwise, return "collect-coins"
else:
return "collect-coins"
def commandAttack():
# Command your griffin riders to attack ogres.
enemies = hero.findEnemies()
friends = hero.findFriends()
for enemy, friend in enumerate (enemies, friends):
if enemy and enemy.type == "ogre":
hero.command(friend, "attack", enemy)
def pickUpCoin():
# Collect coins
coin = hero.findNearestItem()
if coin:
hero.move(coin.pos)
pass
def heroAttack():
# Your hero should attack fang riders that cross the minefield.
enemies = hero.findEnemies()
enemy = hero.findNearestEnemy(enemies)
if enemy and enemy.type == "fangrider" and enemy.pos.x < 37:
hero.attack(enemy)
pass
while True:
commandAttack()
strategy = chooseStrategy()
# Call a function, depending on what the current strategy is.
if strategy == "griffin-rider":
hero.summon("griffin-rider")
elif strategy == "fight-back":
heroAttack()
elif strategy == "collect-coins":
pickUpCoin()