My code works but i don’t have enough health
You should buy better armor.
As @Serg mentioned. You should probably buy better armor.
If you have subscribed for codecombat, you should get a certain amount of gems every month.
What is wrong with my code
enemy = hero.findNearestEnemy()
pass # Replace this with your own code.
# Find the distance to the enemy with distanceTo.
ifdistance = hero.distanceTo(“enemy”)
# If the distance is less than 5 meters…
hero.distanceTo(“enemy”) < 5
# … if “cleave” is ready, cleave!
ready = hero.isReady(“cleave”)
# … else, just attack.
did you store the distance value in
In the code above you are just creating a logic statement. A logic statement by itself will not do anything. The comments ask you to create an if…then…else statement.
Do you remember how to do that?
Your code needs this control logic to make use of your logic statements.
Right now you are most likely doing everything each round:
- calculating the distance (but not using this calculation)
- trying to cleave the enemy
- trying to attack the enemy