# Forest Shadow Bug or just me?

**URL:** https://discourse.codecombat.com/t/forest-shadow-bug-or-just-me/9352
**Category:** Bugs
**Created:** [October 15, 2016, 8:52pm UTC](https://discourse.codecombat.com/t/forest-shadow-bug-or-just-me/9352 "2016-10-15T20:52:56Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![anon71151045](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@anon71151045](https://discourse.codecombat.com/u/anon71151045)
#### Post date: [October 15, 2016, 8:52pm UTC](https://discourse.codecombat.com/t/forest-shadow-bug-or-just-me/9352/1 "2016-10-15T20:52:56Z")

</div>

I did my code correctly but my hero keeps targeting an ogre instead of a thrower or a munchkin.  
This is my code:

// Attack only the small ogres in the forest.  
// Collect coins and gems only.  
// Don’t leave the forest and don’t eat/drink anything.

```python

`var enemy = hero.findNearestEnemy();`

var item = hero.findNearestItem();

while(true) {
    // Find the nearest enemy.
    // Attack it only if its type is "thrower" or "munchkin".
    if (enemy.type == "thrower" || "munchkin") {
      hero.attack(enemy);

```

```
}
}
// Find the nearest item.
// Collect it only if its type is "gem" or "coin".
if (item.type == "gem" || "coin") {
    var pos = item.pos;
    var x = pos.x;
    var y = pos.y;
}

```

```python

```

---

<div class="post-metadata">

### Author: ![juraj\_pechac](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/juraj_pechac/32/4987_2.png) [@juraj\_pechac](https://discourse.codecombat.com/u/juraj_pechac)
#### Post date: [October 15, 2016, 9:04pm UTC](https://discourse.codecombat.com/t/forest-shadow-bug-or-just-me/9352/2 "2016-10-15T21:04:28Z")

</div>

Put these lines inside while-loop:

```python
var enemy = hero.findNearestEnemy();
var item = hero.findNearestItem();

```

---

<div class="post-metadata">

### Author: ![anon71151045](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@anon71151045](https://discourse.codecombat.com/u/anon71151045)
#### Post date: [October 15, 2016, 9:05pm UTC](https://discourse.codecombat.com/t/forest-shadow-bug-or-just-me/9352/3 "2016-10-15T21:05:52Z")

</div>

I’m going to do it. Doing codecombat while checking on this discourse

---

<div class="post-metadata">

### Author: ![anon71151045](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@anon71151045](https://discourse.codecombat.com/u/anon71151045)
#### Post date: [October 15, 2016, 9:07pm UTC](https://discourse.codecombat.com/t/forest-shadow-bug-or-just-me/9352/4 "2016-10-15T21:07:11Z")

</div>

It just ran out of time

---

<div class="post-metadata">

### Author: ![Harry\_the\_Wanderer](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/harry_the_wanderer/32/5369_2.png) [@Harry\_the\_Wanderer](https://discourse.codecombat.com/u/Harry_the_Wanderer)
#### Post date: [October 16, 2016, 5:59pm UTC](https://discourse.codecombat.com/t/forest-shadow-bug-or-just-me/9352/5 "2016-10-16T17:59:14Z")

</div>

> [@anon71151045](#):
>
> It just ran out of time

There is an requirement with the loops where you need to do something each iteration or it causes an issue.

So the statement:

```
if (enemy.type == "thrower" || "munchkin") {
  hero.attack(enemy);
}

```

Should have an else clause that does something like `hero.say(“No enemies available”);

---

<div class="post-metadata">

### Author: ![Tom\_Kohler](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/tom_kohler/32/4762_2.png) [@Tom\_Kohler](https://discourse.codecombat.com/u/Tom_Kohler)
#### Post date: [October 25, 2016, 7:43pm UTC](https://discourse.codecombat.com/t/forest-shadow-bug-or-just-me/9352/7 "2016-10-25T19:43:16Z")

</div>

[please, don’t post solutions]

---

<div class="post-metadata">

### Author: ![MonsterByMistake](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/monsterbymistake/32/10186_2.png) [@MonsterByMistake](https://discourse.codecombat.com/u/MonsterByMistake)
#### Post date: [May 2, 2019, 8:52am UTC](https://discourse.codecombat.com/t/forest-shadow-bug-or-just-me/9352/8 "2019-05-02T08:52:42Z")

</div>

There’s really a **bug** in the level.

And the way to reveal it is to use

> if enemy.type == “thrower” or “munchkin”:

But right before attacking, have the Hero say the enemy type, like so:

> ```
> hero.say(enemy.type)
> hero.attack(enemy)
> 
> ```

Now the Hero says **“Ogre”** , and attacks the ogre.

The Python is disobedient, but there’s a way around it 😉

Instead of using

> if enemy.type == “thrower” or “munchkin”:

Use

> if enemy.type != “ogre”:

_(If enemy type is not equal to Ogre, then attack)_

Issue fixed.

---

<div class="post-metadata">

### Author: ![brooksy125](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/brooksy125/32/9966_2.png) [@brooksy125](https://discourse.codecombat.com/u/brooksy125)
#### Post date: [May 2, 2019, 2:32pm UTC](https://discourse.codecombat.com/t/forest-shadow-bug-or-just-me/9352/9 "2019-05-02T14:32:07Z")

</div>

I’ll agree that it definitely does not like to check the combination of types in this arrangement. I can’t say that I’ve ever seen an “or” statement shortened like that in Python.

> [@MonsterByMistake](#):
>
> if enemy.type == “thrower” or “munchkin”:

I made it work by checking for both separately.

```python
if enemy.type == "thrower" or enemy.type == "munchkin":

```

But now I’m curious, is there a more condensed way to check these with an “or” statement?

---

<div class="post-metadata">

### Author: ![xython](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/xython/32/7269_2.png) [@xython](https://discourse.codecombat.com/u/xython)
#### Post date: [May 2, 2019, 2:57pm UTC](https://discourse.codecombat.com/t/forest-shadow-bug-or-just-me/9352/10 "2019-05-02T14:57:40Z")

</div>

[Fizz buzz help with modulo](https://discourse.codecombat.com/t/fizz-buzz-help-with-modulo/16506/12)?

---

<div class="post-metadata">

### Author: ![brooksy125](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/brooksy125/32/9966_2.png) [@brooksy125](https://discourse.codecombat.com/u/brooksy125)
#### Post date: [May 2, 2019, 3:41pm UTC](https://discourse.codecombat.com/t/forest-shadow-bug-or-just-me/9352/11 "2019-05-02T15:41:28Z")

</div>

Nicely done! 👏 Have you been able to test it much? I’ll have to get familiar with the \*args and \*\*kwargs usage. That looks handy.

---

<div class="post-metadata">

### Author: ![xython](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/xython/32/7269_2.png) [@xython](https://discourse.codecombat.com/u/xython)
#### Post date: [May 2, 2019, 8:51pm UTC](https://discourse.codecombat.com/t/forest-shadow-bug-or-just-me/9352/12 "2019-05-02T20:51:48Z")

</div>

No, didn’t test it. Posted the same function written in java-script in the old topic.
