AlexeySapsay / Python_solution_CodeCombat_2018

In that repository I will post my sollution for codecombat.com games for study Python
1 stars 0 forks source link

Mad Maxer Redemption #186

Open AlexeySapsay opened 6 years ago

AlexeySapsay commented 6 years ago
# Follow me on youtube  channel Phy Tu
# Help with programming on Python, school math, physics
# https://www.youtube.com/channel/UCP5ycahCEZ24qmRRgNnko5Q

# You can't reach your friends to defend them!
# Tell them to go home where the archer can help.
while True:
    weakestFriend = None
    leastHealth = 9999
    friendIndex = 0
    friends=hero.findFriends()

    # Find which friend has the lowest health.
    for friend in friends:
    # Tell the weakest friends to go home first.
        if leastHealth>friend.health and friend.type!="archer":
            weakestFriend=friend
            leastHealth=friend.health
    if weakestFriend:
        hero.say('Hey ' + weakestFriend.id + ', go home!')