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()
lowestFriend = lowestHealthPaladin()
# You can use paladin.canCast(“heal”) and command(paladin, “cast”, “heal”, target)
if lowestFriend and paladin.canCast(‘heal’):
hero.command(paladin, ‘cast’, ‘heal’, lowestFriend)
else:
hero.command(paladin, ‘shield’)
# Paladins can also shield: command(paladin, “shield”)
# And don’t forget, they can attack, too!
def commandPeasant(friend):
if friend:
coin = friend.findNearest(friend.findItems())
if coin:
hero.command(friend, ‘move’, coin.pos)
def commandGriffin(friend):
if friend:
enemy = friend.findNearest(friend.findEnemies())
if enemy:
hero.command(friend, ‘attack’, enemy)
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’)
``` problem is when warlock comes out he pushes my paladins to mines with his spells :cry: