# 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"):
target = lowestHealthPaladin()
if target:
hero.command(paladin, "cast", "heal", target)
else:
hero.command(paladin, "shield", hero)
pass
def commandFriends():
# Command your friends.
friends = hero.findFriends()
enemy = hero.findNearestEnemy()
for friend in friends:
if friend.type == "peasant":
#commandPeasant(friend)
item = friend.findNearestItem()
hero.command(friend, "move", item.pos)
pass
elif friend.type == "griffin-rider":
#commandGriffin(friend)
hero.command(friend, "attack", enemy)
pass
elif friend.type == "paladin":
commandPaladin(friend)
while True:
commandFriends()
# Summon griffin riders!
if hero.gold >= hero.costOf("griffin-riders"):
hero.summon("griffin-rider")
else:
pass
I keep getting an error on line 49:
if hero.gold >= hero.costOf(“griffin-riders”):
It keeps saying the argument should have type object but got string. I can’t see what’s wrong with my code though?