Decoy Drill(JS)[SOLVED]

problem is that my hero just keeps colecting coins and building decys

// We are field testing a new battle unit: the decoy.
// Build 4 decoys, then report the total to Naria.
var decoysBuilt = 0;
while (true) {
    var coin = hero.findNearestItem();
    if (coin) {
        // Collect the coin!
        hero.moveXY(coin.pos.x, coin.pos.y);
    }
    // Each decoy costs 25 gold.
    // If hero.gold is greater than or equal to 25:
    if (hero.gold > 25) {
        hero.buildXY("decoy", 36, 30);
        decoysBuilt + 1;
    }
    // buildXY a "decoy"
    // Add 1 to the decoysBuilt count.
    if (decoysBuilt == 4) {
        // Break out of the loop when you have built 4.
        break;
    }
}
hero.say("Done building decoys!");
hero.moveXY(14, 36);
// Say how many decoys you built.
hero.say(decoysBuilt);

is what i found XD (20 chars)

Nope didn’t work 20 chars

change that too decoysBuilt ++ 1

Nope that just gave me a error

// We are field testing a new battle unit: the decoy.
// Build 4 decoys, then report the total to Naria.
var decoysBuilt = 0;
while (true) {
    var coin = hero.findNearestItem();
    if (coin) {
        // Collect the coin!
        hero.moveXY(coin.pos.x, coin.pos.y);
    }
    // Each decoy costs 25 gold.
    // If hero.gold is greater than or equal to 25:
    if (hero.gold > 25 || hero.gold == 25) {
        hero.buildXY("decoy", 36, 30);
        decoysBuilt ++ 1;
    }
    // buildXY a "decoy"
    // Add 1 to the decoysBuilt count.
    if (decoysBuilt == 4) {
        // Break out of the loop when you have built 4.
        break;
    }
}
hero.say("Done building decoys!");
hero.moveXY(14, 36);
// Say how many decoys you built.
hero.say(decoysBuilt);

saying things takes time and a few seconds is precious

and change

into

decoysBuilt += 1;

Thank you guys! :smile:

1 Like

Your welcome @Eric_Tang and congrats on beating the level :partying_face:

1 Like

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