Summits gate help needed

HI, sorry to interrupt. I need some help with this level. I have looked for advice in lots of other posts but I don’t really understand them. Any help or advice would be greatly appreciated.

#Fight your way into the Inner Sanctum of the ogre chieftain, and defeat her.
#KILL THE OGRES!!!THEY SHOULD BE BOILED IN FONDUE!!!!!!
def summonGriffin():
    if hero.gold > hero.costOf("griffin-rider") :
        hero.summon("griffin-rider")

def commandGriffin(friend):
    enemy = friend.findNearestEnemy()
    if enemy and enemy.type == "fangrider":
        hero.command(friend, "attack", enemy)

def commandPaladin(friend):
    target = friend.findNearestEnemy()
    if target and target.type == "ogre":
        hero.command(friend, "attack", target)
    elif friend.health > 300:
        hero.command(friend, "heal", friend)

def commandArcher(friend):
    enemy = friend.findNearestEnemy()
    if enemy and enemy.type == "thrower" or enemy.type == "scout":
        hero.command(friend, "attack", enemy)

def commandSoldier(friend):
    target = friend.findNearestEnemy()
    if target and target.type == "munchkin":
        hero.command(friend, "attack", target)

def commandFriends():
    friends = hero.findFriends()
    summonGriffin()
    for friend in friends:
        if friend.type == "griffin-rider":
            commandGriffin()
        elif friend.type == "paladin":
            commandPaladin()
        elif friend.type == "archer":
            commandArcher()
        else:
            commandSoldier()

def heroAttack(enemy):
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.attack(enemy)
    else:
        flag = hero.findFlag("black")
        if flag:
            hero.pickUpFlag(flag)


while True:
    commandFriends()
    heroAttack()
 

please post the link to the level

codecombat.com/play/level/summits-gate?

skimming over your code, i noticed that your paladin is healing if their health is greater than 300, not less than. Also, in your heroAttack function, you aren’t moving to the flag? I’m not sure if you need that, but i’m not sure

Also, I tested your code, and it looks like you run to the beam towers, but you don’t command your troops to go with you. Try and make a way to say “if there are no enemies, then come over to your hero” or something along those lines.

thank you I will try that

but the thing is that when I reach the gate… all my troops die and there’s only me left.

No one can ever interrupt here. We’re a friendly family! If you can call people who’s never seen each other a family

2 Likes

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