Gui  
                
                  
                    August 26, 2020, 12:07pm
                   
                  1 
               
             
            
              hello, I’m french, I can’t success this level …don’t know why. I don’t know what to do, every thing seem to be right…what can I do
# Votre but est de protéger Reynaldo
# Trouvez le paladin avec le moins d'énergie
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)
    blesse = lowestHealthPaladin()
    warlock = hero.findNearest(hero.findByType("warlock"))
    if blesse and paladin.canCast("heal"):
        #hero.say(paladin + " soigne " + blesse)
        hero.command(paladin, "cast", "heal", blesse)
    # Paladins can also shield: command(paladin, "shield")
    hero.command(paladin, "shield")
    # And don't forget, they can attack, too!
    if warlock :
        if paladin.health > paladin.maxhealth/4:
            hero.command(paladin, "attack", warlock)
        else:
            hero.command(paladin, "shield")
    defense = paladin.pos
    hero.command(paladin, "defend", defense)
def commandPeasant(friend):
    coin = friend.findNearest(friend.findItems())
    if coin :
        hero.command(friend, "move", coin.pos)
        
def commandGriffin(friend):
    warlock = friend.findNearestEnemy()
    if warlock :
        hero.command(friend, "attack", warlock)
def commandFriends():
    # Command your friends.
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "peasant":
            commandPeasant(friend)
            continue
        elif friend.type == "griffin-rider":
            commandGriffin(friend)
            continue
        elif friend.type == "paladin":
            commandPaladin(friend)
            continue
while True:
    commandFriends()
    # Summon griffin riders!
    while hero.gold > hero.costOf("griffin-rider"):
        hero.summon("griffin-rider")
need some help to success this level …
             
            
              1 Like 
            
            
           
          
            
              
                qjleny  
              
                  
                    August 26, 2020, 12:15pm
                   
                  2 
               
             
            
              Hello @Gui  
             
            
              
            
           
          
            
              
                qjleny  
              
                  
                    August 26, 2020, 12:28pm
                   
                  3 
               
             
            
              maybe the paladins can just shield went they have a low health(< 200) and always attack the warlocks? The griffin-rider’s can do the rest
             
            
              
            
           
          
            
              
                Gui  
              
                  
                    August 26, 2020,  1:30pm
                   
                  4 
               
             
            
              hello, thanks, that not enough … all my paladin die
             
            
              
            
           
          
            
              
                Gui  
              
                  
                    August 26, 2020,  1:31pm
                   
                  5 
               
             
            
              the fight never stop until my paladin die
             
            
              
            
           
          
            
              
                qjleny  
              
                  
                    August 26, 2020,  1:33pm
                   
                  6 
               
             
            
              Can you post your new code?
             
            
              
            
           
          
            
              
                Gui  
              
                  
                    August 26, 2020,  1:55pm
                   
                  7 
               
             
            
              # Votre but est de protéger Reynaldo
# Trouvez le paladin avec le moins d'énergie
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)
    blesse = lowestHealthPaladin()
    warlock = hero.findNearest(hero.findByType("warlock"))
    if blesse and paladin.canCast("heal"):
        #hero.say(paladin + " soigne " + blesse)
        hero.command(paladin, "cast", "heal", blesse)
        # Paladins can also shield: command(paladin, "shield")
    hero.command(paladin, "shield")
    # And don't forget, they can attack, too!
    if warlock :
        if paladin.health > 300:
            hero.command(paladin, "attack", warlock)
    hero.command(paladin, "shield")
    defense = paladin.pos
    hero.command(paladin, "defend", defense)
def commandPeasant(friend):
    coin = friend.findNearest(friend.findItems())
    if coin :
        hero.command(friend, "move", coin.pos)
        
def commandGriffin(friend):
    warlock = friend.findNearestEnemy()
    if warlock :
        hero.command(friend, "attack", warlock)
def commandFriends():
    # Command your friends.
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "peasant":
            commandPeasant(friend)
            continue
        elif friend.type == "griffin-rider":
            commandGriffin(friend)
            continue
        elif friend.type == "paladin":
            commandPaladin(friend)
            continue
while True:
    commandFriends()
    # Summon griffin riders!
    while hero.gold > hero.costOf("griffin-rider"):
        hero.summon("griffin-rider")
I intend with 100, 200, and 300
             
            
              
            
           
          
            
              
                Gui  
              
                  
                    August 26, 2020,  1:58pm
                   
                  8 
               
             
            
                  if warlock :
        hero.command(paladin, "attack", warlock)
    hero.command(paladin, "shield")
    defense = paladin.pos
    hero.command(paladin, "defend", defense)
normally, this is enough, but i don’t win …    
             
            
              
            
           
          
            
              
                qjleny  
              
                  
                    August 26, 2020,  1:58pm
                   
                  9 
               
             
            
              
I would do
else:
    hero.command(paladin, "shield")
 
            
              
            
           
          
            
              
                Gui  
              
                  
                    August 26, 2020,  2:04pm
                   
                  10 
               
             
            
              no I lose
    if warlock :
        if paladin.health > 200:
            hero.command(paladin, "attack", warlock)
        else :
            hero.command(paladin, "shield")
    hero.command(paladin, "shield")
    defense = paladin.pos
    hero.command(paladin, "defend", defense)
 
            
              
            
           
          
            
              
                jka2706  
              
                  
                    September 1, 2020,  2:30pm
                   
                  12 
               
             
            
              Hi Gui,
Congratulations on finding the solution 
However, please could you take down your code? One of the forum rules is not to post working code, so that other people coming after you can’t just copy it.
Thanks,
Jenny
             
            
              1 Like 
            
            
           
          
            
            
              we can still see it with the pencil
             
            
              
            
           
          
            
              
                Gui  
              
                  
                    September 1, 2020,  7:47pm
                   
                  14 
               
             
            
              
ok, no pb, I delete my post 
             
            
              2 Likes 
            
            
           
          
            
              
                system  
              
                  
                    September 2, 2020,  7:47am
                   
                  15 
               
             
            
              This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.