I can’t figure out what the problem is! It looks good, and it kinda works, but I can’t survive!
This my code:
def lowestHealthPaladin():
friends = hero.findByType(“paladin”)
if len(friends) == 0:
return None
for friend in friends:
lowest = friends.pop()
if friend.health < lowest.health:
lowest = friend
return lowest
def commandPaladin(paladin):
# Heal the paladin with the lowest health using lowestHealthPaladin()
friends = hero.findFriends()
for friend in friends:
enemy = friend.findNearestEnemy()
if friend.type == 'paladin':
if paladin.canCast('heal'):
hero.command(friend, "cast",'heal', lowestHealthPaladin())
else:
hero.command(friend, "move", {'x': friend.pos.x + 5, 'y': friend.pos.y})
if friend.pos.x > 80:
hero.command(friend, "shield")
if friend.health < friend.maxHealth/2:
hero.command(friend, "attack", enemy)
# 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!