Help me! My hero.command(paladin, "cast", "heal", lhealth)
line is not working properly somehow and I do not know how to fix it.
here is my code:
# 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!
if paladin.canCast('heal'):
lhealth = lowestHealthPaladin()
if lhealth and lhealth.health < 525 and paladin.type == "paladin":
hero.command(paladin, "cast", "heal", lhealth)
if paladin.health < 200:
hero.command(paladin, "shield")
else:
enemy = paladin.findNearestEnemy()
if enemy:
hero.command(paladin, "attack", enemy)
pass
def commandPeasant(peasant):
coin = peasant.findNearestItem()
if (peasant.id == 'Hector' and coin.pos.y >= 38) or (peasant.id == 'Rose' and coin.pos.y <= 38):
hero.command(peasant, "move", coin.pos)
def commandGriffin(griffin):
enemy = hero.findNearestEnemy()
if enemy:
hero.command(griffin, "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()
# Summon griffin riders!
while hero.gold >= hero.costOf('griffin-rider'):
hero.summon('griffin-rider')