Summit's Gate (Python)[SOLVED]

Hi i just passed yeti eater. And ive arrived at summits gate! I cant seem to understand the paladin’s heal command anyway…Here my code :

def summonTroops():
    if hero.gold > hero.costOf("soldier"):
        hero.summon("soldier")
    if hero.gold > hero.costOf("archer"):
        hero.summon("archer")
    if hero.gold > hero.costOf("griffin-rider"):
        hero.summon("griffin-rider")
def commandSoldier():
    soldiers = hero.findByType("soldier")
    for soldier in soldiers:
        Senemies = soldier.findEnemies()
        for Senemy in Senemies:
            if Senemy and soldier:
                hero.command(soldier, "attack", Senemy)
def commandArcher():
    archers = hero.findByType("archer")
    for archer in archers:
        Aenemies = archer.findEnemies()
        for Aenemy in Aenemies:
            if Aenemy and archer:
                hero.command(archer, "attack", Aenemy)
def commandPaladin():
    paladins = hero.findByType("paladin")
    for paladin in paladins:
        Penemies = paladin.findEnemies()
        for Penemy in Penemies:
            if Penemy and paladin:
                hero.command(paladin, "attack", Penemy)
                if paladin.isReady("cast"):
                    Pfriend = paladin.findNearest(paladin.findFriends)
                    hero.command(paladin, "cast, heal", Pfriend)
def heroAttack():
    enemies = hero.findEnemies()
    for enemy in enemies:
        if enemy:
            hero.attack(enemy)
            if hero.isReady("chain-lightning"):
                hero.cast("chain-lightning", enemy)
def pickUpFlags():
    flag = hero.findFlag("green, black, violet")
    if flag:
        hero.pickUpFlag(flag)
while True:
    summonTroops()
    commandSoldier()
    commandArcher()
    commandPaladin()
    heroAttack()
    pickUpFlags()

pls help!
link = https://codecombat.com/play/level/summits-gate?

its if paladin.canCast("heal", whatever you want to heal)

im not sure but you might have to do different variables for each flag if you can keep it as that though

these need seperate quotes like

flag = hero.findFlag("green","black","violet")

[quote="WaWa_Yang, post:1, topic:26248"]

if hero.gold > hero.costOf(“soldier”):
hero.summon(“soldier”)
if hero.gold > hero.costOf(“archer”):
hero.summon(“archer”)
if hero.gold > hero.costOf(“griffin-rider”):
hero.summon(“griffin-rider”)

[/quote]


your only gonna summon soldiers because its in the first line and you'll never get to griffin rider
Ps sorry my quotes arent working

I believe that flag = hero.findFlag() works, and it returns all colors.

That help alot but when i break the first gate no troops attack any enemy

code =

def summonTroops():
    if hero.gold > hero.costOf("soldier"):
        hero.summon("soldier")
    if hero.gold > hero.costOf("archer"):
        hero.summon("archer")
    if hero.gold > hero.costOf("griffin-rider"):
        hero.summon("griffin-rider")
def commandSoldier():
    soldiers = hero.findByType("soldier")
    for soldier in soldiers:
        Senemies = soldier.findEnemies()
        for Senemy in Senemies:
            if Senemy and soldier:
                hero.command(soldier, "attack", Senemy)
def commandArcher():
    archers = hero.findByType("archer")
    for archer in archers:
        Aenemies = archer.findEnemies()
        for Aenemy in Aenemies:
            if Aenemy and archer:
                hero.command(archer, "attack", Aenemy)
def commandPaladin():
    paladins = hero.findByType("paladin")
    for paladin in paladins:
        Penemies = paladin.findEnemies()
        Pfriend = paladin.findNearest(hero.findFriends())
        for Penemy in Penemies:
            if Penemy and paladin:
                hero.command(paladin, "attack", Penemy)
                if paladin.canCast("heal, Pfriend"):
                    hero.command(paladin, "cast, heal", Pfriend)
def heroAttack():
    enemies = hero.findEnemies()
    for enemy in enemies:
        if enemy:
            hero.attack(enemy)
            if hero.isReady("chain-lightning"):
                hero.cast("chain-lightning", enemy)
def pickUpFlags():
    flag = hero.findFlag()
    if flag:
        hero.pickUpFlag(flag)
while True:
    summonTroops()
    commandSoldier()
    commandArcher()
    commandPaladin()
    heroAttack()
    pickUpFlags()

What type of hero are you using (ranger, wizard, or warrior)? You might need to go and defeat the enemies behind the first gate as well as the beam towers yourself.

sorry for the late reply but i beat the level 17days before :rofl:

1 Like

Okay, that is good.

1 Like

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