Need help on cleave?


#1

Hi,
I am a complete noob to coding. I just started because of the Hour of Code this year and i got interested because of it. I have beat about 15 levels now, i am learning the basics of Python. I am currently on the level Woodland Cleaver but i just find it so difficult to do. I don’t understand the self.isReady(“cleave”) action??? It says to type it down BUT when i do it just says the code is wrong. I am just puzzled and i simply don’t know what to do. I really want to continue this but i am not giving up until i figure this out. I have been trying it for about 20 minutes but can someone just give me an explanation of this code in noob language?

Thanks, i appreciate it


Munchkin Swarm : Help!
Error in level 17 in Backwoods Wald - Munchkin Ernte (Backwoods Forest - Munchkin Harvest)
#2

Can you tell me what the error is exactly? Maybe with a screenshot?

I can give a basic thought, first of all, you have to have the correct sword in order for cleave to be an option, so maybe you are getting the error “cleave is not an available action” in which case you need to equip the longsword.

If you have the longsword then I really need to see your code in order to help you understand what is wrong. Basically that statement is checking to see if you are ready to cleave or not. The idea would be to have something like:

if self.isReady('cleave'):
  self.cleave(enemy)

#3

No, i think i found out what was wrong. You were right it was the sword. I had gotten to fancy and picked another sword that didn’t have the cleave action. But one more question, for the self.isReady(“cleave”) action do i have to have a colon after it? ex: self.isReady(“cleave”):


#4

You need a colon at the end of every if statement. In this case self.isReady() is at the end of an if statement so you need to put a colon after it and indent the code that follow the if statement that’s supposed to be executed when the if statement is true.


#5

i tried loop:
enemy123= self.findNearestEnemy()
if self.isReady(“cleave”):
self.cleave(enemy123)
else:
self.attack(enemy123)
but else will not work!
it says fix your code
help!


#6

Please format your code as specified in the FAQ. All you have to do is highlight the code and click the </> button.

What does the error message say?


#7

I have read all the forums and watched the video many times and still can’t figure out what I’m doing wrong.

Can someone please tell me what is wrong with this code?

Use your new “cleave” skill as often as you can.

self.moveXY(23, 23)
loop:
enemy = self.findNearestEnemy()
if self.isReady(“cleave”):
self.cleave(enemy)

else:
    self.attack(enemy)

I keep getting that “self.attack(enemy)” is not a function.


#8

That seems odd. Do you have a sword equipped?


#9

I figured it out. My sword was fancy, but didn’t have the cleaving action. I switched to the long sword and everything went fine.


#10

Probably the sample code should mention that you need the longsword… how about it, @nick?