Hello, Ive been attempting Reaping fire continuously for a week now and simply cant seem to fix every problem, a new problem always appears.
My current problem is my person won’t attack the fangrider until they collect enough coins to summon a griffin
def chooseStrategy():
enemies = hero.findEnemies()
# If you can summon a griffin-rider, return "griffin-rider"
if hero.gold >= hero.costOf("griffin-rider"):
hero.summon("griffin-rider")
return "griffin-rider"
# If there is a fangrider on your side of the mines, return "fight-back"
for enemy in enemies:
if enemy and enemy.type is "fangrider":
return "fight-back"
# Otherwise, return "collect-coins"
else:
return "collect-coins"
def commandAttack():
# Command your griffin riders to attack ogres.
friend = hero.findNearest(hero.findFriends())
enemy = hero.findNearest(hero.findEnemies())
if enemy and enemy.type != "fangrider" :
hero.command(friend, "attack", enemy)
def pickUpCoin():
# Collect coin
item = hero.findNearestItem()
hero.moveXY(item.pos.x, item.pos.y)
def heroAttack():
# Your hero should attack fang riders that cross the minefield.
enemy = hero.findNearest(hero.findEnemies())
if enemy and enemy.type is "fangrider":
hero.attack(enemy)
while True:
commandAttack()
strategy = chooseStrategy()
# Call a function, depending on what the current strategy is.
if strategy == "fight-back":
heroAttack()
if strategy == "griffin-rider":
commandAttack()
if strategy == "collect-coins":
pickUpCoin()