Level: Peasant Protection


#21

It’s not solved for me. I reran Shield Rush, but the wooden glasses are still locked in Peasant Protection.


#22

thanks. I passed.

  1. I solved the next level called “??swarm”, using a dozen lines of repetitive ugly codes.
  2. I bought some items.
  3. Then I waited for 24 hours.
  4. Then, when I tried again, the glasses were not restricted.
  5. with the glasses, I solved the problem.

#23

How did you make it?


#24

I think did nothing . I log in yesterday,ran the Peasant Protection found the Wooden Glass was unlocked.Then I completed this level.


#25

I still have this same problem today. The new glasses are required to advance and I was supposedly given them in the previous level but they are not there for this level.
I’ve tried the “solutions” listed here but none seem to work.


#26

Sorry about this bug guys; we’re still working on tracking it down. Here’s what should allow you to play the level.

  1. Go to the the forest map.
  2. Open the Chrome JavaScript console.
  3. Paste this in your JS console: me.get('earned').items.push('53e2167653457600003e3eb3')
  4. Click on Peasant Protection, equip the wooden glasses, and play

This won’t give you the wooden glasses permanently (only the server can do that), but it will temporarily let you play the level.

Hoping to find the bug today!


#27

WHAT HAVE I DONE WRONG?
My Code:

loop:
    enemy = self.findNearestEnemy()
    distance = self.distanceTo(enemy.pos)
    if distance < 10:
        self.attack(enemy)

Please help me if you know!


#28

You need an else clause to say what to do if the distance isn’t less than ten (probably move back to near the peasant).


#29

I can’t seem to get past this level. I’ve tried different distances, using the shield and moving to slightly different positions, but nothing works. Please help.

This is my code:

 loop {
    var enemy = this.findNearestEnemy();
    var distance = this.distanceTo(enemy);
    if (distance < 10) {
        this.attack(enemy);
    } else {
        this.moveXY(41, 39);
    }
}

#30

Try 40, 37 instead of 41, 39? It should be right on the x marker.


#31

Thank you Nick!_____________


#32

im haveing some big trouble with this level i think i got the code right but it wont kill all of them and one kills the peasant
my code:

loop {
    var enemy = this.findNearestEnemy();
    var distance = this.distanceTo(enemy);
    if (distance < 20) {
        this.attack(enemy);
        this.attack(enemy);
    } else {
        this.moveXY(40, 37);
    }
}

#33

Try distance 10 instead of 20; 20 will chase too far away.


#34

play this level for continue http://codecombat.com/play/level/munchkin-swarm


#35

Please help! This is my script so far:

loop:
    enemy = self.findNearestEnemy()
    distance = self.distanceTo(enemy.pos)
    if distance < 10:
        # Attack if they get too close to the peasant.
        self.attack(enemy)
    else:
        self.move({"x":40, "y":37})
    # Else, stay close to the peasant! Use else.

But when I run it, I move, but I don’t attack. Also, 1 more thing: for the “if distance < 10:” part, it won’t work at 10, it only works at 20. Is this a glitch or did I do something wrong?


#36

It looks like I have everything working right, but when I try to kill the enemy, I only get half of them and then they kill the peasant. My this.moveXY(40, 37); is highlighted, but I don’t think it’s wrong. All of the enemy get too close to the peasant. What should I do?

Here is my code:

loop {
    var enemy = this.findNearestEnemy();
    var distance = this.distanceTo(enemy);
    if (distance < 10) {
        // Attack if they get too close to the peasant.
        this.attack(enemy);
    }
    // Else, stay close to the peasant! Use else.
    else {
        this.moveXY(40, 37);
    }
    
}

#37

And you have your code beautifully spaced, yes?


#38

That’s exactly what we intended; should work. What weapon/hero/boots are you using? Would love to get this figured out.


#39

Not sure what I need. Thank you for looking into this!!!


#40

That’s weird; I just took a look into your account and did the level with the same gear and saw victory: https://www.dropbox.com/s/e9nj2m1wp0ncpy0/Screenshot%202015-01-01%2021.24.03.png?dl=0

Are you still seeing the problem? If so, which browser?