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.
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.
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.