Summit's gate help please JS

here is my code, can someone please help?

// Fight your way into the Inner Sanctum of the ogre chieftain, and defeat her.
// Прорвись через святилище к вождю огров и убей её.
var enemies, enemy;

var summonTypes = ["archer"];
this.summonTroops = function() {
    var type = summonTypes[this.built.length % summonTypes.length];
    if(this.gold >= this.costOf(type)) {
        this.summon(type);
    }
};

// Найти паладина с самым низким количеством здоровья.
this.lowestHealthPaladin = function() {
    var lowestHealth = 99999;
    var lowestFriend = null;
    var friends = this.findFriends();
    for(var f=0; f < friends.length; f++) {
        var friend = friends[f];
        //if(friend.type != "paladin") { continue; }
        if(friend.health < lowestHealth && friend.health < friend.maxHealth) {
            lowestHealth = friend.health;
            lowestFriend = friend;
        }
    }
    return lowestFriend;
};

this.commandPaladin = function(paladin) {
    // Полечи паладина с низким количеством здоровья используя lowestHealthPaladin()
    // Ты можешь использовать paladin.canCast ("heal") и command(paladin, "cast", "heal", target)
    // Паладины также могут использовать щит: command(paladin, "shield")
    // And don't forget, they can attack, too!
    var healTarget = this.lowestHealthPaladin();
    enemy = paladin.findNearest(enemies);
    if (healTarget && paladin.canCast("heal")) {
        this.command(paladin, "cast", "heal", healTarget);
    } else if (enemy) {
        this.command(paladin, "attack", enemy);
    }
};

this.commandSoldier = function(soldier) {
    enemy = soldier.findNearest(enemies);
    if (enemy) {
        this.command(soldier, "attack", enemy);
    } else {
        this.command(soldier, "move", {x: soldier.pos.x+10, y: soldier.pos.y});
    }
};

this.commandArcher = function(archer) {
    enemy = archer.findNearest(enemies);
    if (enemy) {
        this.command(archer, "attack", enemy);
    } else {
        this.command(archer, "move", {x: archer.pos.x+5, y: archer.pos.y});
    }
};

this.commandGriffin = function(griffin) {
    enemy = griffin.findNearest(enemies);
    if (enemy) {
        this.command(griffin, "attack", enemy);
    } else {
        this.command(griffin, "move", {x: griffin.pos.x+10, y: griffin.pos.y});
    }
};

this.commandFriends = function() {
    // Командуй своими союзниками.
    var friends = this.findFriends();
    for(var i=0; i < friends.length; i++) {
        var friend = friends[i];
        if(friend.type == "soldier") {
            this.commandSoldier(friend);
        } else if(friend.type == "archer") {
            this.commandArcher(friend);
        } else if(friend.type == "griffin-rider") {
            this.commandGriffin(friend);
        } else if(friend.type == "paladin") {
            this.commandPaladin(friend);
        }
    }
};

this.heroPlan = function () {
    enemy = this.findNearest(enemies);
    var catapult = this.findNearest(this.findByType("catapult"));
    if (catapult) {
        enemy = catapult;
    } else {
        var nearestX = 101;
        for (var i; i < enemies.length; i++) {
            if (enemies[i].pos.x < nearestX) {
                nearestX == enemies[i].pos.x;
                enemy = enemies[i];
            }
        }
    }
    /*if (enemy && enemy.type != "tower") {
        this.attack(enemy);
    } else {
        this.moveXY(159, 34);//this.attack(enemy);
    }*/
    if (enemy) {
    this.attack(enemy);
    }
};

this.saveFriednsLeft = function () {
    var friends = this.findFriends();
    for(var i=0; i < friends.length; i++) {
        var friend = friends[i];
        if (friend) this.command(friend, "move", {x: 0, y: 40});
    }
};
while(true) {
    enemies = this.findEnemies();
    var catapult = this.findNearest(this.findByType("catapult"));
    if (catapult) {
        this.saveFriednsLeft();
    } else this.commandFriends();
    this.summonTroops();
    this.heroPlan();
}

Hi H_G,

Your code looks identical to one that’s on the internet (right down to the spelling mistakes), hmmm?

It’s a hard level, and by all means look at how other people solve it if you’re stuck, but then please write your own code - it’s much more fun, and you’ll learn a lot more by doing it like that.

We’re really happy to help you if you get part way through writing your own and then get stuck!

Jenny

7 Likes

Woah, So much writing there, fella, Have you tried hints? I personally didn’t do this level yet but do check hints!

Interesting, can you explain what’s wrong in this phrase?)

1 Like

" Прорвись через святилище к вожде огров и убей его." Is that better?
I’ve studied Russian an awful long time аgo…
Better translation from Alex: “Прорвись через святилище к предводительнице огров и убей её.”
I was wrong…

2 Likes

I PM’ed )

@H_G
Hint about learning

One of many helpful Summit’s Gate topics

Magic tool)

May the luck be with you for all the way.

2 Likes

this is a hard level I took about 2 to 3 hours here is a hint make the paladins shield if they are lower than 60 health

nah try lower than 100 or 250

I just beat it about a hour or two ago when you get to the part of the warlocks try to take them out first

also summon griffins when yo get the gems

riticmaster they can’t even summon paladins.

when I have defeated the catapults, the soldiers and archers don’t break the door open.