Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[SOLVED]Reaping Fire Level Help

My character does not summon the griffin riders.

# The goal is to survive for 30 seconds, and keep the mines intact for at least 30 seconds.

def chooseStrategy():
    enemies = hero.findEnemies()
    # 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"
    enemy = hero.findNearestEnemy()
    if hero.distanceTo(enemy) < 30:
        return "fight-back"
    # Otherwise, return "collect-coins"
    else:
        return "colect-coins"

def commandAttack():
    # Command your griffin riders to attack ogres.
    friends = hero.findFriends()
    for friend in friends:
        hero.command(friend, "attack", enemy)
    pass
    
def pickUpCoin():
    # Collect coins
    item = hero.findNearestItem()
    if item:
        hero.move(item.pos)
    pass
    
def heroAttack():
    # Your hero should attack fang riders that cross the minefield.
    enemies = hero.findEnemies()
    for enemy in enemies:
        if hero.distanceTo(enemy) < 35:
            hero.scattershot(enemy)
    pass
    
while True:
    commandAttack()
    strategy = chooseStrategy()
    # Call a function, depending on what the current strategy is.
    chooseStrategy()
    pickUpCoin()
    heroAttack()
    

This here,

You’ll have to check if the enemy’s pos is on your side.
Lydia

How should I do that?

You could do it like

if enemy and enemy.pos.x < 36

Lydia

My hero still doesn’t summon griffins

Try changing

while True:
    commandAttack()
    strategy = chooseStrategy()
    # Call a function, depending on what the current strategy is.
    chooseStrategy()
    pickUpCoin()
    heroAttack()

into

while True:
    commandAttack()
    strategy = chooseStrategy()
    # Call a function, depending on what the current strategy is.
    if strategy == 'griffin-rider':
        hero.summon('griffin-rider')
    if strategy == 'fight-back':
        heroAttack()
    if strategy == 'colect-coins':    # because you returned colect not collect
        pickUpCoin()

That’s because you didn’t write hero.summon('griffin-rider') in your code

I suggest you read these very carefully.
Lydia

It works!! Thank you guys.

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.