# \[SOLVED\] Help with reaping fire please

**URL:** <https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306>\
**Category:** Level Help\
**Created:** [June 17, 2020, 12:21pm UTC](https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306 "2020-06-17T12:21:24Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ActualllOLLIEpop](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/actualllolliepop/32/12660_2.png) [@ActualllOLLIEpop](https://discourse.codecombat.com/u/ActualllOLLIEpop)\
**Post date:** [June 17, 2020, 12:21pm UTC](https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306/1 "2020-06-17T12:21:25Z")

</div>

hi. i’m not too sure about what to change on this level. here’s my code:

```python
`def chooseStrategy():
    enemies = hero.findEnemies()
    if hero.costOf("griffin-rider"):
        return "griffin-rider"
    enemies = hero.findEnemies()
    for enemy in enemies:
        if enemy.type == "fangrider":
            if enemy.pos.x < 34:
                return "fight-back"
    for enemy in enemies:
        if enemy.pos.x > 34 and hero.gold < hero.costOf("griffin-rider"):
            return "collect-coins"

def commandAttack():
    friends = hero.findFriends()
    giffinRider = None
    for friend in friends:
        if friend.type == "griffin-rider":
            boi = griffinRider
        if boi:
            hero.command(boi, "attack", target)
    pass

def pickUpCoin():
    # Collect coins
    coin = hero.findNearestItem()
    if coin:
        hero.move(coin.pos)
    pass

def heroAttack():
    enemies = hero.findEnemies()
    for enemy in enemies:
        if enemy.type == "fangrider" and enemy.pos.x < 34:
            hero.attack(enemy)
    pass

while True:
    commandAttack()
    strategy = chooseStrategy()
    if "griffin-rider":
        commandAttack()
    if "fight-back":
        heroAttack()
    elif "collect-coins":
        pickUpCoin()`

```

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [June 17, 2020, 12:37pm UTC](https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306/2 "2020-06-17T12:37:15Z")

</div>

> [@ActualllOLLIEpop](#):
>
> ```python
> strategy = chooseStrategy()
> if "griffin-rider":
> commandAttack()
> if "fight-back":
> heroAttack()
> elif "collect-coins":
> pickUpCoin()`
> 
> ```

Here put

```python
strategy = chooseStrategy()
    if strategy=="griffin-rider":
        #here summon a griffin-rider
    elif strategy=="fight-back":
        heroAttack()
    elif strategy=="collect-coins":
        pickUpCoin()`

```

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [June 17, 2020, 12:39pm UTC](https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306/3 "2020-06-17T12:39:50Z")

</div>

> [@ActualllOLLIEpop](#):
>
> ```python
> giffinRider = None
> for friend in friends:
> if friend.type == "griffin-rider":
> boi = griffinRider
> if boi:
> hero.command(boi, "attack", target)
> pass
> 
> ```

Instead of that put this:

```python
for friend in friends:
    if friend.type == "griffin-rider":
        enemy = friend.findNearestEnemy()
        if enemy:
            hero.command(friend, "attack", enemy)

```

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [June 17, 2020, 12:42pm UTC](https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306/4 "2020-06-17T12:42:13Z")

</div>

> [@ActualllOLLIEpop](#):
>
> ```python
> enemies = hero.findEnemies()
> for enemy in enemies:
> if enemy.type == "fangrider" and enemy.pos.x < 34:
> hero.attack(enemy)
> 
> ```

Instead of that put this:

```python
enemy = hero.findNearestEnemy()
if enemy.health > 0:
    hero.attack(enemy)

```

> [@ActualllOLLIEpop](#):
>
> `if hero.costOf("griffin-rider"):`

Instead of that, put something like this:

```python
if hero.gold >= hero.costOf("griffin-rider"):

```

Does it work now?

---

<div class="post-metadata">

**Author:** ![ActualllOLLIEpop](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/actualllolliepop/32/12660_2.png) [@ActualllOLLIEpop](https://discourse.codecombat.com/u/ActualllOLLIEpop)\
**Post date:** [June 17, 2020, 12:43pm UTC](https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306/5 "2020-06-17T12:43:24Z")

</div>

it still doesn’t work.

---

<div class="post-metadata">

**Author:** ![ActualllOLLIEpop](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/actualllolliepop/32/12660_2.png) [@ActualllOLLIEpop](https://discourse.codecombat.com/u/ActualllOLLIEpop)\
**Post date:** [June 17, 2020, 12:43pm UTC](https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306/6 "2020-06-17T12:43:47Z")

</div>

here’s the new code:

```python
def chooseStrategy():
    enemies = hero.findEnemies()
    if hero.costOf("griffin-rider"):
        return "griffin-rider"
    enemies = hero.findEnemies()
    for enemy in enemies:
        if enemy.type == "fangrider":
            if enemy.pos.x < 34:
                return "fight-back"
    for enemy in enemies:
        if enemy.pos.x > 34 and hero.gold < hero.costOf("griffin-rider"):
            return "collect-coins"

def commandAttack():
    friends = hero.findFriends()
    giffinRider = None
    for friend in friends:
        if friend.type == "griffin-rider":
            enemy = friend.findNearestEnemy()
            if enemy:
                hero.command(friend, "attack", enemy)
    pass

def pickUpCoin():
    # Collect coins
    coin = hero.findNearestItem()
    if coin:
        hero.move(coin.pos)
    pass

def heroAttack():
    enemy = hero.findNearestEnemy()
    if enemy.health > 0:
        hero.attack(enemy)
    pass

while True:
    commandAttack()
    strategy = chooseStrategy()
    if "griffin-rider":
        commandAttack()
    elif "fight-back":
        heroAttack()
    elif "collect-coins":
        pickUpCoin()

```

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [June 17, 2020, 12:44pm UTC](https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306/7 "2020-06-17T12:44:55Z")

</div>

I edited the last one. Does it work with that change?

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [June 17, 2020, 12:45pm UTC](https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306/8 "2020-06-17T12:45:58Z")

</div>

And you forgot to correct this:

> [@\[SOLVED\] Help with reaping fire please](https://discourse.codecombat.com/t/help-with-reaping-fire-please/22306/3):
>
> Instead of that put this: for friend in friends: if friend.type == "griffin-rider": enemy = friend.findNearestEnemy() if enemy: hero.command(friend, "attack", enemy)

Does it work now?

---

<div class="post-metadata">

**Author:** ![ActualllOLLIEpop](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/actualllolliepop/32/12660_2.png) [@ActualllOLLIEpop](https://discourse.codecombat.com/u/ActualllOLLIEpop)\
**Post date:** [June 17, 2020, 12:47pm UTC](https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306/9 "2020-06-17T12:47:42Z")

</div>

i’ll be back soon, i have a video conference. bye

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [June 17, 2020, 1:03pm UTC](https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306/10 "2020-06-17T13:03:26Z")

</div>

> [@ActualllOLLIEpop](#):
>
> ```python
> for enemy in enemies:
> if enemy.pos.x > 34 and hero.gold < hero.costOf("griffin-rider"):
> return "collect-coins"
> 
> ```

Delete all of this and put

```python
    return "collect-coins"

```

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [June 17, 2020, 1:03pm UTC](https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306/11 "2020-06-17T13:03:48Z")

</div>

Have you completed the level?

---

<div class="post-metadata">

**Author:** ![ActualllOLLIEpop](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/actualllolliepop/32/12660_2.png) [@ActualllOLLIEpop](https://discourse.codecombat.com/u/ActualllOLLIEpop)\
**Post date:** [June 17, 2020, 1:26pm UTC](https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306/12 "2020-06-17T13:26:41Z")

</div>

no i haven’t. here’s the new code:

```python
def chooseStrategy():
    enemies = hero.findEnemies()
    if hero.costOf("griffin-rider"):
        return "griffin-rider"
    enemies = hero.findEnemies()
    for enemy in enemies:
        if enemy.type == "fangrider":
            if enemy.pos.x < 34:
                return "fight-back"
    return "collect-coins"

def commandAttack():
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "griffin-rider":
            enemy = friend.findNearestEnemy()
            if enemy:
                hero.command(friend, "attack", enemy)
    pass

def pickUpCoin():
    # Collect coins
    coin = hero.findNearestItem()
    if coin:
        hero.move(coin.pos)
    pass

def heroAttack():
    enemy = hero.findNearestEnemy()
    if enemy.health > 0:
        hero.attack(enemy)
    pass

while True:
    commandAttack()
    strategy = chooseStrategy()
    if "griffin-rider":
        commandAttack()
    elif "fight-back":
        heroAttack()
    elif "collect-coins":
        pickUpCoin()

```

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [June 17, 2020, 1:36pm UTC](https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306/13 "2020-06-17T13:36:30Z")

</div>

You have not corrected this!!

> [@\[SOLVED\] Help with reaping fire please](https://discourse.codecombat.com/t/help-with-reaping-fire-please/22306/3):
>
> Instead of that put this: for friend in friends: if friend.type == "griffin-rider": enemy = friend.findNearestEnemy() if enemy: hero.command(friend, "attack", enemy)

---

<div class="post-metadata">

**Author:** ![ActualllOLLIEpop](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/actualllolliepop/32/12660_2.png) [@ActualllOLLIEpop](https://discourse.codecombat.com/u/ActualllOLLIEpop)\
**Post date:** [June 17, 2020, 1:38pm UTC](https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306/14 "2020-06-17T13:38:09Z")

</div>

which line, because i think i did

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [June 17, 2020, 1:41pm UTC](https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306/15 "2020-06-17T13:41:18Z")

</div>

> [@ActualllOLLIEpop](#):
>
> ```python
> if "griffin-rider":
> commandAttack()
> elif "fight-back":
> heroAttack()
> elif "collect-coins":
> pickUpCoin()
> 
> ```

Those lines. 😃

---

<div class="post-metadata">

**Author:** ![ActualllOLLIEpop](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/actualllolliepop/32/12660_2.png) [@ActualllOLLIEpop](https://discourse.codecombat.com/u/ActualllOLLIEpop)\
**Post date:** [June 17, 2020, 1:42pm UTC](https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306/16 "2020-06-17T13:42:15Z")

</div>

why? (2000000 chars)

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [June 17, 2020, 1:43pm UTC](https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306/17 "2020-06-17T13:43:11Z")

</div>

> [@AnSeDra](#):
>
> ```python
> for friend in friends:
> if friend.type == "griffin-rider":
> enemy = friend.findNearestEnemy()
> if enemy:
> hero.command(friend, "attack", enemy)
> 
> ```

Try to change the lines I showed you with this.

---

<div class="post-metadata">

**Author:** ![ActualllOLLIEpop](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/actualllolliepop/32/12660_2.png) [@ActualllOLLIEpop](https://discourse.codecombat.com/u/ActualllOLLIEpop)\
**Post date:** [June 17, 2020, 1:44pm UTC](https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306/18 "2020-06-17T13:44:02Z")

</div>

which line number? (20 chars)

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [June 17, 2020, 1:44pm UTC](https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306/19 "2020-06-17T13:44:56Z")

</div>

The last 6 lines. 😃

---

<div class="post-metadata">

**Author:** ![ActualllOLLIEpop](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/actualllolliepop/32/12660_2.png) [@ActualllOLLIEpop](https://discourse.codecombat.com/u/ActualllOLLIEpop)\
**Post date:** [June 17, 2020, 1:46pm UTC](https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306/20 "2020-06-17T13:46:23Z")

</div>

like this?:

```python
while True:
    commandAttack()
    strategy = chooseStrategy()
    for friend in friends:
        if friend.type == "griffin-rider":
            enemy = friend.findNearestEnemy()
            if enemy:
                hero.command(friend, "attack", enemy)

```

[Next page](https://discourse.codecombat.com/t/solved-help-with-reaping-fire-please/22306.md?page=2)
