Hero wont summon and gettin an error

So basically I’m doing some of the brawl levels and I’m making code stuff but then I’m getting an error in my commandTroops() function. It’s in the paladin.canCast() but apparently it’s not defined yet?

def summonTroops():
    summonTypes = ['paladin', "archer"]
    summonType = summonTypes[len(hero.built) % len(summonTypes)]
    if hero.gold < hero.costOf(summonType):
        hero.summon(summonType)

def commandTroops(friends):
    lowest = lowestHealthUnit(friends)
    for friend in friends:
        enemy = friend.findNearestEnemy()
        #
        #Here is where I sepereate between my archers and my paladins
        #
        if friend.type == "paladin":
            paladin = friend
        if friend.type == 'archer':
            archer = friend
    if paladin.canCast("heal", lowest):
        #
        #This is where my error of paladins not being defined yet occurs
        #
        hero.command(paladin, "cast", "heal", lowest)
    if enemy:
        hero.command(archer, "attack", enemy)

def lowestHealthUnit(friends):
    lowestHealth = 999
    lowestUnit = None
    for friend in friends:
        if friend.health < lowestHealth:
            lowestUnit = friend
            lowestHealth = friend.health
    return lowestUnit

I think the command is “heal”, not “cast”, “heal”. But I’ve never worked with paladins before.
(So get rid of the cast?)

Actually, that syntax looks correct. Syntax = (who, “do what”, “do which”, to whom)

@Needs_lots_help, what level is this?

brawl stage. Pretty generic just need to survive while enmies are get u

Ok…where are you calling summonTroops? That is where a paladin would be created/summoned and therefore defined.

in my while true loop, and it’s the first function i call

heh…what while true loop? I see only definitions.

He pasted only part of his code.

I noticed :wink:

Needs, please post the whole thing.

Ok, time to step out. I’m just being stupid.

Nope…keep me honest!

@Needs_lots_help, btw, what equipment do you have? Please post a pic of your inventory.

ok coming up with them rn

full code:

def summonTroops():
    summonTypes = ['paladin', "archer"]
    summonType = summonTypes[len(hero.built) % len(summonTypes)]
    if hero.gold < hero.costOf(summonType):
        hero.summon(summonType)

def commandTroops(friends):
    lowest = lowestHealthUnit(friends)
    for friend in friends:
        enemy = friend.findNearestEnemy()
        #
        #Here is where I sepereate between my archers and my paladins
        #
        if friend.type == "paladin":
            paladin = friend
        if friend.type == 'archer':
            archer = friend
    if paladin.canCast("heal", lowest):
        #
        #This is where my error of paladins not being defined yet occurs
        #
        hero.command(paladin, "cast", "heal", lowest)
    if enemy:
        hero.command(archer, "attack", enemy)

def lowestHealthUnit(friends):
    lowestHealth = 999
    lowestUnit = None
    for friend in friends:
        if friend.health < lowestHealth:
            lowestUnit = friend
            lowestHealth = friend.health
    return lowestUnit

def pickUpCoin():
    coin = hero.findNearestItem()
    if coin:
        hero.moveXY(coin.pos.x, coin.pos.y)

while True:
    enemy = hero.findNearestEnemy()
    friends = hero.findFriends()
    summonTroops()
    commandTroops(friends)
    
    

its just my functions wrapped in a while loop and I waited for my functions to be fixed before I make my hero start to do things.

it was actually a sapphire sense stone too I accidently uneqquipped

What is the actual level name/link? I’ll try running with your code.

backwoods brawl im just getting some gems to fully equip my hero with that dragon armor.

Which level are you at in the brawl? I’m at 4, so cannot regress, but my test login may be able to do your level.

ima be real with you chief I just started doing this because Ive been neglecting most replayable levels. I just been trying to make a decent program that can last me for a bit.

No worries…but, I still need to know which level of the brawl you are on. The flag for it, on the map, will have a number…what is that number? Or, in the level itself, you will see:

the 4 is the indicator.

Sorry for being unclear. From the whole thing I said, I meant to say 0