summonTypes = ["paladin","paladin","soldier","paladin"]
cummonTypes = ["archer"]
dummonTypes = ["griffin-rider"]
def lowestHealthPaladin():
lowestHealth = 99999
lowestFriend = None
friends = hero.findFriends()
for friend in friends:
if friend.health < lowestHealth and friend.health < friend.maxHealth/1.5:
if friend.type == "paladin":
lowestHealth = friend.health
lowestFriend = friend
return lowestFriend
def commandPaladin(paladin):
# 使用函数 lowestHealthPaladin() 找到生命值最低的武士,并治疗
# 你能使用 paladin.canCast("heal") 和 command(paladin, "cast", "heal", target)
# 武士也能防御:command(paladin, "shield")
# 不要忘了他们还能攻击
low = lowestHealthPaladin()
paladins = hero.findByType("paladin")
for paladin in paladins:
if low:
if paladin.canCast("heal"):
if paladin.team == hero.team:
hero.command(paladin, "cast", "heal", low)
else:
hero.command(low, "shield")
def commandFriends():
# 指挥你的队友
friends = hero.findFriends()
for friend in friends:
if friend.type == "paladin":
commandPaladin(friend)
def summonTroops():
# 用%取模来循环预设的征兵方案 len(self.built)
type = summonTypes[len(hero.built) % len(summonTypes)]
tcpe = cummonTypes[len(hero.built) % len(cummonTypes)]
ucpe = dummonTypes[len(hero.built) % len(dummonTypes)]
if hero.gold > hero.costOf(type):
if hero.time < 90:
hero.summon(type)
if hero.time > 50:
if hero.time < 65:
if hero.gold > hero.costOf("archer"):
hero.summon("archer")
if hero.time > 100:
if hero.gold > hero.costOf(ucpe):
hero.summon(ucpe)
while True:
item = hero.findNearestItem()
enemy = hero.findNearestEnemy()
enemies = hero.findEnemies()
summonTroops()
if item:
hero.move(item.pos)
if hero.isReady("jump"):
hero.jumpTo(item.pos)
friends = hero.findFriends()
for friend in friends:
if friend and friend.type != "cage":
e = friend.findNearestEnemy()
commandPaladin(friend)
if friend.type != "yeti":
if friend.type !="decoy":
if friend.type != "cage":
if friend.type != "peasant":
if e:
if e.type != "cage":
hero.command(friend, "attack", e)
if friend.type == "archer":
distance = friend.distanceTo(e)
if distance < 5:
hero.command(friend, "move", hero.pos)
else:
hero.command(friend, "attack", e)
else:
if friend.type != "peasant":
if friend.type != "paladin":
hero.command(friend, "move", hero.pos)
if friend.type == "paladin":
hero.command(friend, "shield", hero)
else:
hero.command(friend, "defend", hero.pos)
if friend.type == "peasant":
sa = friend.findNearestItem()
if sa:
hero.command(friend, "move", sa.pos)
# 你的英雄能收集金币并招募部队。
# 在站场上,她也可以命令你的盟友。
if hero.canCast("goldstorm"):
hero.cast("goldstorm")
if hero.isReady("reset-cooldown"):
hero.resetCooldown("goldstorm")
if hero.canCast("raise-dead"):
corpses = hero.findCorpses()
for b in corpses:
c = hero.distanceTo(b)
if c < 10:
if hero.canCast("raise-dead"):
hero.cast("raise-dead")
if hero.isReady("mana-blast"):
if enemy:
distance = hero.distanceTo(enemy)
if distance < 10:
hero.manaBlast()
ps(发挥首领之星的作用)