Backwoods Standoff: Code Promblems


#1

Hello Code Combat Community!
I am new to coding and I am having a little trouble on Backwoods Standoff.
Here is my code:

Munchkins are attacking!

The swarms will come at regular intervals.

Whenever you can, cleave to clear the mass of enemies.

while True:
enemy = hero.findNearestEnemy()
# Use an if-statement with isReady to check “cleave”:
if enemy:
ready = hero.isReady(“cleave”)
# Cleave!
hero.cleave(enemy)
# Else, if cleave is not ready:
else:
enemy = hero.findNearestEnemy()
hero.attack(enemy)
hero.attack(enemy)
hero.attack(enemy)
hero.attack(enemy)
# Attack the nearest ogre.

The problem is after my character cleaves it doesn’t attack the extra munchkins. It simply stands there and waits for the next swarm.

All help is appreciated.
Thank you!
Fellow user


#2

please format your code properly by putting triple backticks above and below your code, I have done it for you this time

while True:
enemy = hero.findNearestEnemy()
# Use an if-statement with isReady to check “cleave”:
if enemy:
ready = hero.isReady(“cleave”)
# Cleave!
hero.cleave(enemy)
# Else, if cleave is not ready:
else:
enemy = hero.findNearestEnemy()
hero.attack(enemy)
hero.attack(enemy)
hero.attack(enemy)
hero.attack(enemy)
# Attack the nearest ogre.


#3

for one, you don’t need 4 hero.attacks, one will do just fine, because if your cleave cooldown ends during your 4 attacks, you will have to wait longer. You also don’t really need 2 variables, the first one works, and if you have shield ability, that might work too, if you have shield, that is.


#4

but the variable part doesn’t affect your code,


#5

I tested your code, you should use an if statement, won’t give out free code, but the error message says to pair else with if,


#6

You forgot the indentations


#7

Thank you for your help


#8

I am still having a little trouble.


#9

See Confused on what to do . The language is Lua, but you can grasp the idea.