I am having trouble with this level. The problem is that the paladins can’t heal. I don’t know what it is because I can’t find an answer on the discourse. I have tried on different computers and it still doesn’t work.
# Your goal is to protect Reynaldo
# Find the paladin with the lowest health.
def lowestHealthPaladin():
lowestHealth = 99999
lowestFriend = None
friends = self.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!
enemy = paladin.findNearestEnemy()
if paladin.canCast('heal'):
self.command(paladin, "cast", "heal", lowestHealthPaladin())
elif enemy:
self.command(paladin, "attack", enemy)
def commandFriends():
# Command your friends.
friends = self.findFriends()
for friend in friends:
if friend.type == "peasant":
#commandPeasant(friend)
coin = friend.findNearestItem()
if coin:
self.command(friend, "move", coin.pos)
elif friend.type == "griffin-rider":
#commandGriffin(friend)
enemy = friend.findNearestEnemy()
if enemy:
self.command(friend, "attack", enemy)
elif friend.type == "paladin":
commandPaladin(friend)
loop:
commandFriends()
# Summon griffin riders!
if self.gold > self.costOf('griffin-rider'):
self.summon('griffin-rider')
return lowestFriend