Munchkin swarm! i cant win!


#1

i cannot beat this level. i use Python and my hero is Anya. please post your code and how it worked for you


#2

this is the code i used

while True:

distance = hero.distanceTo(target)
hero.cleave(enemy)
else:
    hero.attack("Chest")

#3

What you have so far is correct, but you are missing a few things.

You start your code with:

distance = hero.distanceTo(target)

but you never told your code what ‘target’ means, so your code doesn’t know what you mean with that word. You need to define that first.

Then, on the next line, you want to cleave an enemy, but once again, you haven’t defined what an enemy is. (also, why do you call it target first, and enemy later? Choose one and stick with it),

Then all of a sudden you have “else:” but how can it decide what this “else:” means if you did not define an if statement?

And finally, is cleave always ready? What happens when there are enemies, but cleave is not ready? Will you just stand around and wait for cleave to be ready again?


#4

Thank you for the help! im still having a little bit of trouble though. here is my updated code.

target = "munchkin"
while True:
if “munchkin”:
distance = hero.distanceTo(target)
ready = hero.isReady(“cleave”)

else:
    hero.attack("chest")

#5

You should go back to a previous level and look at how you defined an enemy (or target) in other levels.

Also, indentation is important for block coding.


#6

I BEAT THE LEVEL!!! YESSS!!!:grinning::grinning::grin:


#7

It takes practice, but you can do it!