level 2
wondermax
楼主
# 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 commandBuilt():
if self.gold>self.costOf("griffin-rider"):
self.summon("griffin-rider")
def findbadEnemy():
enemies=self.findEnemies()
bad=None
health=9999999
i=0
while i<len(enemies):
enemy=enemies[i]
if enemy.health<health:
bad=enemy
health=bad.health
i+=1
if bad:
return bad
else:
return None
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")
lowestF=lowestHealthPaladin()
enemy=findbadEnemy()
if paladin.canCast("heal"):
if lowestF:
self.command(paladin,"cast","heal",lowestF)
elif enemy:
self.command(paladin,"shield")
def commandPeasant(friend):
coin=friend.findNearest(friend.findItems())
if coin:
self.command(friend,"move",coin.pos)
def commandGriffin(friend):
enemy=findbadEnemy()
if enemy:
self.command(friend,"attack",enemy)
def commandFriends():
# Command your friends.
friends = self.findFriends()
for friend in friends:
if friend.type == "peasant":
#commandPeasant(friend)
commandPeasant(friend)
elif friend.type == "griffin-rider":
#commandGriffin(friend)
commandGriffin(friend)
elif friend.type == "paladin":
commandPaladin(friend)
def helps():
if self.canCast("summon-fangrider"):
self.cast("summon-fangrider")
if self.isReady("reset-cooldown"):
self.resetCooldown("summon-fangrider")
loop:
commandBuilt()
commandFriends()
helps()
# Summon griffin riders!
2016年02月12日 10点02分
1
# 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 commandBuilt():
if self.gold>self.costOf("griffin-rider"):
self.summon("griffin-rider")
def findbadEnemy():
enemies=self.findEnemies()
bad=None
health=9999999
i=0
while i<len(enemies):
enemy=enemies[i]
if enemy.health<health:
bad=enemy
health=bad.health
i+=1
if bad:
return bad
else:
return None
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")
lowestF=lowestHealthPaladin()
enemy=findbadEnemy()
if paladin.canCast("heal"):
if lowestF:
self.command(paladin,"cast","heal",lowestF)
elif enemy:
self.command(paladin,"shield")
def commandPeasant(friend):
coin=friend.findNearest(friend.findItems())
if coin:
self.command(friend,"move",coin.pos)
def commandGriffin(friend):
enemy=findbadEnemy()
if enemy:
self.command(friend,"attack",enemy)
def commandFriends():
# Command your friends.
friends = self.findFriends()
for friend in friends:
if friend.type == "peasant":
#commandPeasant(friend)
commandPeasant(friend)
elif friend.type == "griffin-rider":
#commandGriffin(friend)
commandGriffin(friend)
elif friend.type == "paladin":
commandPaladin(friend)
def helps():
if self.canCast("summon-fangrider"):
self.cast("summon-fangrider")
if self.isReady("reset-cooldown"):
self.resetCooldown("summon-fangrider")
loop:
commandBuilt()
commandFriends()
helps()
# Summon griffin riders!