[SOLVED] Cloudrip Montain The Two Flowers

i don’t understand where i’m wrong. some one help me

// If the peasant is damaged, the flowers will shrink!

function summonSoldiers() {
    if (hero.gold >= hero.costOf("soldier")) {
        hero.summon("soldier");
        
    }
}

// Define the function: commandSoldiers


function commandSoldiers() {
    let soldiers = hero.findFriends();
    for(let i = 0; i < soldiers.length; i++) {
        let enemy = soldiers[i].findNearestEnemy();
        if(enemy) {
            hero.command(soldiers[i],"attack", enemy.pos);
        }
    }
}
// Define the function: pickUpNearestCoin
function pickUpNearestCoin() {
    let item = hero.findItems();
    let coin = hero.findNearest(item);
    if (coin) {
        hero.move(coin.pos);
    }
}
var peasant = hero.findByType("peasant")[0];

while(true) {
    summonSoldiers();
    commandSoldiers();
    pickUpNearestCoin();  
}

It means what the error says. Read it carefully. Remember that the peasant is included in your friends loop. Maybe you should only commands what you can: “soldier” and “archer”.
Danny

thank you very much)

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.