Grim determination - please help

# Your goal is to protect Reynaldo

# Find the paladin with the lowest health.
def lowestHealthPaladin():
    lowestHealth = 99999
    lowestFriend = None
    friends = hero.findFriends()
    for friend in friends:
        if friend.type != "paladin":
            continue
        if friend.health < lowestHealth and friend.health < friend.maxHealth:
            lowestHealth = friend.health
            lowestFriend = friend

    return lowestFriend

def commandPaladin(paladin):
    # Heal the paladin with the lowest health using lowestHealthPaladin()
    # You can use paladin.canCast("heal") and command(paladin, "cast", "heal", target)
    # Paladins can also shield: command(paladin, "shield")
    # And don't forget, they can attack, too!
    lowestHealthPaladin()
    if paladin.canCast("heal"):
        if lowestFriend:
            hero.command(paladin, "cast", "heal", lowestFriend)
    hero.command(paladin, "shield")
    pass

def commandFriends():
    # Command your friends.
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "peasant":
            #commandPeasant(friend)
            pass
        elif friend.type == "griffin-rider":
            #commandGriffin(friend)
            pass
        elif friend.type == "paladin":
            commandPaladin(friend)

while True:
    commandFriends()
    if hero.gold>hero.costOf("griffin-rider"):
        hero.summon("griffin-rider")
    for friend in hero.findFriends():
        if friend.type == "griffin-rider":
            enemy = friend.findNearestEnemy()
            if enemy:
                hero.command(friend, "attack", enemy)
            else:
                hero.command(friend, "move", {"x": 62, "y": 37})    

I get that my code is not complete but I don’t understand what the issue is.

You have to make a variable called lowestFriend and store the value of the function lowestHealthPaladin() inside it. If the function has a return inside it, it means you need to put it to the right of an equals sign like with hero.findNearestEnemy().

1 Like

Ahhh, thank you (20)

1 Like