hi there,
I´m new to coding and i wanted to learn coding with this game.
I have made alot of progress i think, but i cannot figure out why this piece of code is not working.
Plz have a look at it and maybe one of you guys can help me out.
hero.enemyInRange = function(enemy) {
// Return true if the enemy is less than 5 units away.
if (enemy) {
hero.distanceTo(enemy) < 5;
}
return false;
};
hero.cleaveOrAttack = function(enemy) {
if (hero.isReady("cleave")) {
hero.cleave(enemy);
} else {
hero.attack(enemy);
}
};
while(true) {
var enemy = hero.findNearestEnemy();
if(enemy) {
// Check the distance of the enemy by calling enemyInRange.
if (hero.enemyInRange(enemy)) {
hero.cleaveOrAttack(enemy);
}
}
}