Clash of the Clones


#1

Can someone please help me? My code is fine, I just can’t stay alive.
// You’ll need good strategy and good equipment to win this one!
loop {
var enemies = this.findEnemies();
var enemyArchers = this.findByType(“archer”, enemies);
var friends = this.findFriends();
var enemy = this.findNearest(enemies);
if (enemyArchers.length > 0) {
enemy = this.findNearest(enemyArchers);
while (enemy.health > 0) {
this.attack(enemy);
}
} else if (this.pos.x > 50) {
this.moveXY(50, this.pos.y);
} else if (this.health < 1500 && friends.length > 6) {
this.shield();
} else if ((enemy.type != “sand-yak”)) {
while (enemy.health > 0) {
this.attack(enemy);
}
}
}


#2

Never mind… I did it.