Level: Peasant Protection


hey yall i love this game challenges your brain who constucted the game if i may ask


my charecter keeps killingthe peasant no matter what code i put in


Well, what are you telling your hero to “attack”?


i am telling my hero to attack enemy and to shield Victor.


Nevermind i was usin g a purchased sword instead of cleaver! hah…not really


I need help with my code
enemy = self.findNearestEnemy()
distance = self.distanceTo(enemy)
if distance < 10:

    self.moveXY(40, 33)

It says that there is an “Unexpected Token” on the “Else” line. I’ve just started getting into programming ,besides (Q Basic) and it’s probably some easy mistake, but i’m not really great at python so plz help! :pray:


Tip: To format your code correctly, use three of the `, or backticks, instead of ', the quotation marks.


Your problem is that you have not indented the line self.attack(enemy) inside your if-statement.


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


plz help me~~~

Solved already … but…

Why there are some codes don’t work on my game when I pasted the correct codes I found online?


Maybe the code you found online wasn’t correct in the first place? We have many “solutions” that are bugged, are untested ect.

Generally I advise strongly against using or even searching solutions online. You really just hurt yourself. Try to solve it yourself. If you really can’t get it, search in this forum or in the online documentation of your chosen language. Google is your friend here. If you still can’t solve it and there is no topic here about this problem, then open a new topic. Post your code correctly formatted (***!!!***) as described in the FAQ, write exactly what your problem is and what you have tried to solve it and we will try to solve your problem.


re-check your Looping your looping something that may not exist because there may not always be a distance if there is no enemy try:

enemy = self.findNearestEnemy()
if enemy and distanceTo(enemy) < 10
self.attack enemy


Hi I need help here and for Info I don’t use Java.Thanks!


Tell us what are you trying to do and the error message you are receiving. If no error, your observed code behavior and why it is different from what you intended. Format your code by surrounding it by 3 back-quotes (top-left on your keyboard)



As @AdrianCgw mentioned, please post your code with radiant and harmonious formatting, as described in the FAQ. Phrases like ''i need help" or “i can’t figure it out” don’t help us help you. Please post your code (with formatting according to the FAQ) , what happens, and anything else that would be helpful.

Cheers! @Luke10


enemy = self.findNearestEnemy()
if enemy:
distance = self.distanceTo(enemy)
if distance <6:
self.moveXY(40, 35)
self.say(“Come closer”)
Here is my code.My problem is that every time I go and attack the Ogres, other Ogres will attack the Peasent


Thanks I just can’t get through the level.


Change distance<10 (you allow them to come too near)

if distance<10:

Remove the last line: self.say(“come closer”) , makes your hero idle for 1 second while talking


Thank you so much for the code!It work like genius


Glad to hear that you beat the level. Just remember that from now on, post your code with formatting by reading the FAQ.
Here’s the link:


No problem but still one thing are you one of their staff @Luke10?