Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Backwoods standoff if else


#1

On Backwoods standoff, I believe I am doing it right but it keeps telling me to add a ‘:’ What do I do? Code:
while True:
enemy = hero.findNearestEnemy()
# Use an if-statement with isReady to check “cleave”:
if “cleave” hero.isReady: {THIS IS WHERE IT SAYS I AM WRONG. This side note is not in the code}
hero.cleave(enemy)
# Cleave!
# Else, if cleave is not ready:
else:
hero.attack(enemy)
hero.attack(enemy)
# Attack the nearest ogre!


#2

Next time try to preformat your code according to the FAQ
https://discourse.codecombat.com/faq
Also it is not if "cleave" hero.isReady: but it is if hero.isReady("cleave"):


#3

Thanks for the feedback!


#4


was this the intended usage?
else wouldn’t work


#5

I just used thornpick. It was so easy.


#6

Look at your methods to see the proper use/format for is.Ready(action). Everything you need to know is there. Get in the habit of looking at these methods. You’re going to need to refer to this quite often.


#7

you need to do if hero.isReady("cleave") for it to work.


#8


muahahaha


#9

with thornprick!(20)


#13

my code looks just like that but hero wont attack indeviduals just cleave


#14

If your code is “just like that” then it’s wrong. As I stated above, look at the methods listed in the middle of the screen to see the proper format and use. Everything you need to know is there. Get in the habit of looking at these methods. You’re going to need to refer to this quite often.