My griffin riders dont attack and my hero summons only one and my peasants just walk into each other and do nothing but try and walk into each other
# 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()
if paladin:
lowPaladin = lowestHealthPaladin()
if lowPaladin:
self.command(paladin, "cast", "heal", lowPaladin)
lowPaladin.say("paladin healed")
# You can use paladin.canCast("heal") and command(paladin, "cast", "heal", target)
# Paladins can also shield: command(paladin, "shield")
else:
self.command(paladin, "shield")
def commandFriends():
# Command your friends.
friends = self.findFriends()
for friend in friends:
if friend.type == "peasant":
commandPeasant(friend)
elif friend.type == "griffin-rider":
commandGriffin(friend)
elif friend.type == "paladin":
commandPaladin(friend)
def commandGriffin(griffin):
enemy = griffin.findNearest(griffin.findEnemies())
self.command(griffin, "attack", enemy)
def commandPeasant(peasant):
coin = peasant.findNearest(peasant.findItems())
self.command(peasant, "move", coin.pos)
loop:
commandFriends()
# Summon griffin riders!
self.summon("griffin-rider")