The reason you are failing the level is because you are using hero.moveXY(item.pos.x, item.pos.y). That means that until you reach the item, all other code will not be executed. To solve this, replace hero.moveXY(item.pos.x, item.pos.y) with hero.move(item.pos). Also, in the for-loop with your soldiers, you should make sure that hero.findNearestEnemy() is returning an enemy before you command your soldiers to attack the enemy.
Learned
41
Related topics
| Topic | Replies | Views | Activity | |
|---|---|---|---|---|
| Vital Powers Help plz | 17 | 3765 | April 16, 2020 | |
| [SOLVED]Two Flowers codecombat help | 17 | 621 | August 27, 2020 | |
| [SOLVED] Two flowers (Python) | 19 | 3585 | July 14, 2020 | |
| [SOLVED] Two Flowers Python | 10 | 4028 | April 26, 2020 | |
| [SOLVED] The Two Flowers(python) | 7 | 410 | January 22, 2021 |