# Reaping fire level, solved!

**URL:** <https://discourse.codecombat.com/t/reaping-fire-level-solved/32177>\
**Category:** Level Help\
**Created:** [February 22, 2022, 12:23pm UTC](https://discourse.codecombat.com/t/reaping-fire-level-solved/32177 "2022-02-22T12:23:06Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![qwerty](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/qwerty/32/30493_2.png) [@qwerty](https://discourse.codecombat.com/u/qwerty)\
**Post date:** [February 22, 2022, 12:23pm UTC](https://discourse.codecombat.com/t/reaping-fire-level-solved/32177/1 "2022-02-22T12:23:06Z")

</div>

I have read through the hints (which don’t really help btw) and all of the other topics about this level and i still can’t get my hero to do anything; my hero just stands there doing nothing.

> **Code**
>
> ```python
> # 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"
> if enemy.type == "fangrider" and enemy.pos.x <= 36:
> return "fight-back"
> # Otherwise, return "collect-coins"
> else:
> return "collect-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.moveXY(coin.pos.x, coin.pos.y)
> pass
>     
> def heroAttack():
> # Your hero should attack fang riders that cross the minefield.
> hero.attack(enemy)
> pass
>     
> while True:
> strategy = chooseStrategy()
> # Call a function, depending on what the current strategy is.
> if strategy == 'griffin-rider':
> commandAttack()
> if strategy == 'fight-back':
> heroAttack()
> if strategy == 'collect-coins':
> pickUpCoin()
> 
> ```

---

<div class="post-metadata">

**Author:** ![Aya](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/aya/32/42680_2.png) [@Aya](https://discourse.codecombat.com/u/Aya)\
**Post date:** [February 22, 2022, 2:50pm UTC](https://discourse.codecombat.com/t/reaping-fire-level-solved/32177/2 "2022-02-22T14:50:42Z")

</div>

you never told it to summon griffins, you can add it here:

> [@qwerty](#):
>
> ```python
> if hero.gold >= hero.costOf("griffin-rider"):
> return "griffin-rider"
> 
> ```

without returning anything, so you summon instead of return

---

<div class="post-metadata">

**Author:** ![qwerty](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/qwerty/32/30493_2.png) [@qwerty](https://discourse.codecombat.com/u/qwerty)\
**Post date:** [February 22, 2022, 3:14pm UTC](https://discourse.codecombat.com/t/reaping-fire-level-solved/32177/3 "2022-02-22T15:14:37Z")

</div>

I changed my code a bit, but now it says this:  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/3X/d/0/d05a5b3b1cb8a1ac5288aa765c2aa8b7ffb7e06d.png)

```python
# 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"):
        hero.summon("griffin-rider")
        return 'griffin-rider'
    # If there is a fangrider on your side of the mines, return "fight-back"
    fang = hero.findNearest(hero.findByType("fangrider",enemies))
    if fang and fang.pos.x <= 36:
        return "fight-back"
    # Otherwise, return "collect-coins"
    else:
        return "collect-coins"

def commandAttack():
    # Command your griffin riders to attack ogres.
    friends = hero.findFriends()
    for friend in friends:
        enemy = friend.findNearestEnemy
        if enemy:
            hero.command(friend, "attack", enemy) #This line here
        else:
            hero.command(friend, "move", {'x':80,'y':40})
        
    pass
    
def pickUpCoin():
    # Collect coins
    item = hero.findNearestItem()
    if item:
        hero.moveXY(item.pos.x, item.pos.y)
    pass
    
def heroAttack():
    fang = hero.findNearest(hero.findByType("fangrider",hero.findEnemies()))
    # Your hero should attack fang riders that cross the minefield.
    hero.attack(fang)
    pass
    
while True:
    strategy = chooseStrategy()
    # Call a function, depending on what the current strategy is.
    if strategy == 'griffin-rider':
        commandAttack()
    if strategy == 'fight-back':
        heroAttack()
    if strategy == 'collect-coins':
        pickUpCoin()

```

---

<div class="post-metadata">

**Author:** ![Aya](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/aya/32/42680_2.png) [@Aya](https://discourse.codecombat.com/u/Aya)\
**Post date:** [February 22, 2022, 4:09pm UTC](https://discourse.codecombat.com/t/reaping-fire-level-solved/32177/4 "2022-02-22T16:09:21Z")

</div>

> [@qwerty](#):
>
> ```python
> enemy = friend.findNearestEnemy
> if enemy:
> hero.command(friend, "attack", enemy) #This line here
> else:
> hero.command(friend, "move", {'x':80,'y':40})
> 
> ```

put all this part in an if statement checking if the friend exists

> [@qwerty](#):
>
> ```python
> # Your hero should attack fang riders that cross the minefield.
> hero.attack(fang)
> 
> ```

also take care of this

Edit: you forgot the parenthesis in this:

> [@qwerty](#):
>
> `enemy = friend.findNearestEnemy`

---

<div class="post-metadata">

**Author:** ![qwerty](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/qwerty/32/30493_2.png) [@qwerty](https://discourse.codecombat.com/u/qwerty)\
**Post date:** [February 22, 2022, 4:28pm UTC](https://discourse.codecombat.com/t/reaping-fire-level-solved/32177/5 "2022-02-22T16:28:07Z")

</div>

> [@Aya](#):
>
> also take care of this

wdym?  
I defined fang as `Hero.findNearest(hero.FindByType("fangrider",enemies))`

---

<div class="post-metadata">

**Author:** ![Aya](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/aya/32/42680_2.png) [@Aya](https://discourse.codecombat.com/u/Aya)\
**Post date:** [February 22, 2022, 4:32pm UTC](https://discourse.codecombat.com/t/reaping-fire-level-solved/32177/6 "2022-02-22T16:32:52Z")

</div>

you did, but you didn’t check if it exists nor if it crossed the minefields

---

<div class="post-metadata">

**Author:** ![qwerty](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/qwerty/32/30493_2.png) [@qwerty](https://discourse.codecombat.com/u/qwerty)\
**Post date:** [February 22, 2022, 5:51pm UTC](https://discourse.codecombat.com/t/reaping-fire-level-solved/32177/7 "2022-02-22T17:51:11Z")

</div>

But I know that they exist because they crossed over.

---

<div class="post-metadata">

**Author:** ![Aya](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/aya/32/42680_2.png) [@Aya](https://discourse.codecombat.com/u/Aya)\
**Post date:** [February 22, 2022, 6:46pm UTC](https://discourse.codecombat.com/t/reaping-fire-level-solved/32177/8 "2022-02-22T18:46:00Z")

</div>

Did you solve the level?

---

<div class="post-metadata">

**Author:** ![qwerty](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/qwerty/32/30493_2.png) [@qwerty](https://discourse.codecombat.com/u/qwerty)\
**Post date:** [February 22, 2022, 6:49pm UTC](https://discourse.codecombat.com/t/reaping-fire-level-solved/32177/9 "2022-02-22T18:49:51Z")

</div>

Yes I changed the stuff you told me to (other than the fang bit) and I just had to submit it; Thanks!

---

<div class="post-metadata">

**Author:** ![Aya](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/aya/32/42680_2.png) [@Aya](https://discourse.codecombat.com/u/Aya)\
**Post date:** [February 23, 2022, 6:10am UTC](https://discourse.codecombat.com/t/reaping-fire-level-solved/32177/10 "2022-02-23T06:10:34Z")

</div>

Anytime ( 20 chars )

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/a/a9445509d1a758c41b5ddcddc8c8e20a5dedb67f.png) [@system](https://discourse.codecombat.com/u/system)\
**Post date:** [February 23, 2022, 6:10pm UTC](https://discourse.codecombat.com/t/reaping-fire-level-solved/32177/11 "2022-02-23T18:10:52Z")

</div>

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