Summits Gate help python

Here is my code:

def soldier_attack(enemy):
    hero.summon("soldier")
    soldier = hero.getNEarestFriend()
    hero.command(soldier, "attack", enemy)
def archer_attack(enemy):
    hero.summon("archer")
    archer = hero.getNEarestFriend()
    hero.command(archer, "attack", enemy)
def paladin_attack(enemy):
    hero.summon("paladin")
    paladin = hero.getNEarestFriend()
    hero.command(paladin, "attack", enemy)
def griffin_rider_attack(enemy):
    hero.summon("griffin-rider")
    griffin-rider = hero.getNEarestFriend()
    hero.command(griffin-rider, "attack", enemy)

while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        soldier_attack(enemy)
        archer_attack(enemy)
        paladin_attack(enemy)
        griffin_rider_attack(enemy)

Here is the link to the code:

The problem:

@JoPro_8000 or @Eric_Tang or @Falcons118 or @abc or @Anonym or @Lydia_Song or @milton.jinich or @PeterPalov or @thebagel?

for your code u should check if the hero has enough gold to summon the troops cuz he cant summon anyone without gold


so I havent done this in python yet but for JS what i did was

  1. not summon any troops till i got close to the warlocks
  2. used the paladin ring thing to heal myself
  3. Used flags
  4. made paladins heal me
  5. summoned like 50 billion archers for the end fight
    my loadout

    this is just what i did…

You should use flags
and try using the paladins to heal you

idk if this affects anything but you should fix this (the E in Nearest shouldn’t be capitalized)

and if you have a hero that has a special power or a weapon that has a special power, you should use it

2 Likes

Some sample code for you.


while True:
    sold()
    arch
    pal()
    att()
    gr()
def att():
   if hero.gold > 49:
        hero.say("Griffins please!")
   else:
       hero.say("I should attack!")
def gr():
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "griffin-rider":
            enemies = hero.findEnemies()
            enemy = friend.findNearest(enemies)
            if enemy:
                hero.say("Y U NO ATTACK???")

def pal():
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "paladin":
            enemies = hero.findEnemies()
            enemy = friend.findNearest(enemies)
            if enemy:
                hero.say("Bruh. Attack.")
def arch():
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "archer":
            enemies = hero.findEnemies()
            enemy = friend.findNearest(enemies)
            if enemy:
                hero.say("Cmon attack.")
def sold():
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "soldier":
            targets = hero.findByType("catapult")
            target = friend.findNearest(targets)
            if target:
                hero.say("Please attack the catapults.")
            else:
                enemies = hero.findEnemies()
                enemy = friend.findNearest(enemies)
                if enemy:
                    hero.say("Please attack.")

@I_Luv_Clash_Royale is the code that you gave me for summit’s gate?

Wdym? I gave you some sample code. It’s not the solution, it’s part of my code, but I got rid of some stuff, and replaced it with hero.say stuff

1 Like

Yes this is some sample code I made for summits gate

1 Like