i don’t know where i’m wrong.))))
some one help me please)
// Gather coins to summon soldiers and have them attack the enemy.
while(true) {
// Move to the nearest coin.
// Use move instead of moveXY so you can command constantly.
let find = hero.findItems();
let coins = hero.findNearest(find);
if(coins) {
hero.move(coins.pos);
}
// If you have funds for a soldier, summon one.
if (hero.gold > hero.costOf("soldier")) {
hero.summon("soldier");
}
var enemy = hero.findNearest(hero.findEnemies());
if (enemy) {
var soldiers = hero.findFriends();
var soldierIndex = 0;
var soldier = soldiers[soldierIndex];
// Loop over all your soldiers and order them to attack.
while(soldierIndex < soldiers.length) {
hero.command(soldier, "attack", enemy);
soldierIndex++;
}
}
// Use the 'attack' command to make your soldiers attack.
//hero.command(soldier, "attack", enemy);
}