I’ve stuck on Summit’s Gate for days and I have done nearly 70% of it. But the witches are too powerful. Can you help me to finish my code and beat the witches.
here is my code:
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):
lowestFriend = lowestHealthPaladin()
healingThreshold = 0.8 * paladin.maxHealth
if lowestFriend and paladin.canCast(‘heal’) and lowestFriend.health < healingThreshold:
self.command(paladin, ‘cast’, ‘heal’, lowestFriend)
def commandPaladin2(paladin):
self.command(paladin, ‘cast’, ‘heal’, hero)
def commandPaladin3(paladin):
self.command(paladin,‘move’,{“x”:141,“y”:36})
def commandArcher(friend):
enemies= friend.findEnemies()
enemy = friend.findNearest(enemies)
if enemy:
hero.command(friend, “attack”, enemy)
def commandFriends1():
# Command your friends.
friends = hero.findFriends()
for friend in friends:
elif friend.type == “archer”:
commandArcher(friend)
pass
elif friend.type == “paladin”:
self.command(friend, ‘move’, {“x”:85,“y”:35})
elif friend.type == “soldier”:
self.command(friend, ‘move’, {“x”:75,“y”:34})
self.command(friend, ‘move’, {“x”:83,“y”:62})
elif friend.type == “griffin-rider”:
self.command(friend, ‘move’, {“x”:75,“y”:34})
self.command(friend, ‘move’, {“x”:83,“y”:8})
def commandFriends2():
# Command your friends.
friends = hero.findFriends()
for friend in friends:
if friend.type == “paladin”:
commandPaladin(friend)
pass
else:
commandArcher(friend)
def commandFriends3():
# Command your friends.
friends = hero.findFriends()
for friend in friends:
hero.command(friend, ‘move’,{“x”:74,“y”:36} )
def commandFriends4():
# Command your friends.
friends = hero.findFriends()
for friend in friends:
if friend.type == “paladin”:
commandPaladin2(friend)
pass
else:
commandArcher(friend)
def commandFriends5():
# Command your friends.
friends = hero.findFriends()
for friend in friends:
hero.command(friend, ‘move’,{“x”:228,“y”:52} )
def commandFriends6():
# Command your friends.
friends = hero.findFriends()
for friend in friends:
if friend.type == “paladin”:
commandPaladin2(friend)
else:
commandArcher(friend)
def commandFriends8():
# Command your friends.
friends = hero.findFriends()
for friend in friends:
hero.command(friend, ‘move’,{“x”:268,“y”:35} )
def commandFriends7():
# Command your friends.
friends = hero.findFriends()
for friend in friends:
if friend.type == “paladin”:
commandPaladin3(friend)
while True:
commandFriends1()
self.moveXY(91, 35)
commandFriends2()
if hero.gold>hero.costOf(“griffin-rider”):
hero.summon(“griffin-rider”)
if hero.now()>30:
while True:
if hero.gold>hero.costOf(“griffin-rider”):
hero.summon(“griffin-rider”)
commandFriends3()
hero.moveXY(82, 36)
commandFriends4()
while True:
enemies = self.findEnemies()
enemyIndex=0
while enemyIndex< len(enemies):
enemy=enemies[enemyIndex]
commandFriends4()
if hero.now()>72:
enemyIndex+=1000
if enemy:
if enemy.type==‘tower’:
hero.attack(enemy)
distance = hero.distanceTo(enemy)
if distance<40:
while enemy.health>0:
if hero.isReady(“chain -lingtning”):
hero.cast(“chain-lightning”, target)
else:
hero.attack(enemy)
enemyIndex+=1
commandFriends6()
commandFriends4()
if hero.now()>100:
commandFriends5()
hero.moveXY(228, 60)
commandFriends6()
while enemyIndex< len(enemies):
enemy=enemies[enemyIndex]
if hero.now()>120:
enemyIndex+=1000
if enemy:
while enemy.health>0:
if hero.isReady(“chain -lingtning”):
hero.cast(“chain-lightning”, target)
else:
hero.attack(enemy)