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

Mission "Brittle Morale" can be completed in possibly unintended way

The goal of the exercise, according to the commented text on the first line, is that the archer can only fire once, and that I have to correctly identify the enemy leader without mistakes. However, this solution completes the level while allowing the archer to fire twice:

function findStrongestEnemy(enemies) {
    var strongest = null;
    var strongestHealth = 0;
    var enemyIndex = 0;
    while (enemyIndex < enemies.length) {
        var enemy = enemies[enemyIndex];
        strongest = enemy;
        strongestHealth =;
        return strongest;
var enemies = hero.findEnemies();
var leader = findStrongestEnemy(enemies);
if (leader) {

Here’s how it plays out:
The hero says the name of an enemy
The archer shoots, killing the enemy
Nothing moves for a few seconds, but little numbers start to pop up on the enemies (presumably related to their relative positions in the array)
The archer shoots a different enemy just as they all start to run in
The enemies run away
This counts as a victory

Yeah, I see what you mean.
Even if the archer doesn’t kill the leader, once they all run in then the archer can kill them all anyway.
@Chaboi_3000 is this enough of a problem to change the level? In my opinion you should have to do it right to win.
Good find @SPennLUE, welcome to the CodeCombat discourse. (Also, good job formatting you code.)
:lion: :lion: :lion:

Interesting. It does let you shoot more than once. A few issues with your function though.

  1. The function isn’t looking for the strongest enemy. Your code is just assigning the indexed enemy to strongest.
  2. I noticed that your return is not set up correctly in the function and will return the first enemy since it is buried in the while loop.

After the initial attack, it appears that the archer reverts to the base code after the delayed time: shoot at nearest target. He just gets lucky and takes out the leader in time.

Deadpool : “you should have to do it right to win”
It’s easy to mod the level to “do it right to win”. The archer has ridiculously high damage , I changed attackDamage from 9000 it to 50
You can see the effect of the change at: for python or for javascript
No obvious bad code will pass…
You don’t need even to log with your account - the level is one of the many where you don’t have to own boots, items or books to complete it.

Might be a reasonable request, but it’s probably low in my list. There’s other things I need to do first. :slight_smile:

1 Like

Assigned to @Chaboi_3000

Found an easy fix to this. I had to set the specific cooldown of the archer to a high value. Patch sent. :slight_smile:

1 Like

Unassigned @Chaboi_3000