I have a confession to make…
This level almost makes me want to give up. I just really do not understand what to do and what i am doing
function chooseTarget(){
var friend = hero.findNearest(hero.findFriends());
var enemy = hero.findNearest(hero.findEnemies());
if (friend.type == "solider" && enemy.type =="witch"){
return "witch";
}if(friend.type == "archers" && enemy.type !="witch"){
return "archers";
}
}
while(true) {
var friends = hero.findFriends();
for(var i=0; i < friends.length; i++) {
// Use your chooseTarget function to decide what to attack.
var friend =friends[i];
var target = chooseTarget();
if(target == "witch"){
hero.command(friend,'attack',enemy);
}
if(target == "archers"){
hero.command(friend,'attack',enemy);
}
}
}