[SOLVED] on Summit's Gate

Hi i am stuck on summits gate and i am using Ritic with best armor and weapon.
the title looks funky because all the names are taken

my code

# Fight your way into the Inner Sanctum of the ogre chieftain, and defeat her.
while True:
    enemy = hero.findNearestEnemy()
    friend = hero.findNearest(hero.findFriends())
    flag = hero.findFlag("green")
    if flag:
        hero.pickUpFlag(flag)
    elif enemy:
        distance = hero.distanceTo(enemy)
        if hero.distanceTo(enemy) < 20:
            
            if friend:
                hero.command(friend, "attack", enemy)
            if hero.canCast("chain-lightning", enemy):
                hero.cast("chain-lightning", enemy)
            else:
                hero.attack(enemy)
            if friend:
                hero.command(friend, "defend", hero.pos)
    if hero.gold >= hero.costOf("soldier"):
        hero.summon("soldier")
    if hero.canCast("earthskin", hero):
        hero.cast("earthskin", hero)

do i need an equipment check

i solved it

[en_US.composer.my_button_text]