What I am I doing wrong here Backwoods Brawl? (Javascript)


#1

Hi guys,

I am trying to utilise an if statement within an if statement, I would like the hero to cleave if ready, but if not to sheild himself and if not to both, then attack.

while(true) {
var enemy = hero.findNearestEnemy();
var distance = hero.distanceTo(enemy);
if (distanc < 5) {
if (hero.isReady(“cleave”)) {
hero.cleave(enemy);
}
else {
hero.shield();

    }
}
else {
    hero.attack(enemy);
}

}


#2

I don’t do javascript as my main langue but I think you’re missing a few brackets and you spelled distance wrong

while(true) {
    var enemy = hero.findNearestEnemy();
    var distance = hero.distanceTo(enemy);
    if (distance < 5) {
        if (hero.isReady("cleave")) {
            hero.cleave(enemy);
        }
    }
else {
    hero.shield();
}
else {
    hero.attack(enemy);
}
}

And also in python before you can find the distance you’re from the enemy you have to do

if enemy:

first for else the code will have nothing to find the distance from.
I am not sure though because this is in JavaScript so don’t quote me on this


#3

hi im stuck on the wizards door and i need help could you help me


#4

Please create a separate topic for this