Hi everyone,
I need a help for summit’s gate …
Thank a lot
I need the code
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 notdoor(friend):
enemies=self.findEnemies()
maxdistance=0
target=None
for enemy in enemies:
distance= friend.distanceTo(enemy)
if distance < maxdistance and enemy.type is not "door":
maxdistance=distance
focus=enemy
if focus:
self.say(focus)
return focus
else:
return False
def itempeasant(peasant):
item=peasant.findNearest(self.findItems())
if item:
return item
else:
return False
def pickUpitem():
for peasant in self.findByType("pesant",self.findFriends()):
while itempeasant(peasant):
item=itempeasant(peasant)
self.command(peasant, "attack", item.pos)
# Fight your way into the Inner Sanctum of the ogre chieftain, and kill her.
waiting={"x":7,"y":26}
waiting2={"x":7,"y":47}
points=[{"x":96,"y":34},{"x":248,"y":34},{"x":266,"y":34},{"x":248,"y":34}]
Up=False
loop:
catapult = self.findByType("catapult", self.findEnemies())
tower = self.findByType("tower", self.findEnemies())
nb_catapult=len(catapult)
nb_tower=len(tower)
#Command Troop
friends=self.findFriends()
i=1
for foo,friend in enumerate(friends):
#CHOIX DE LA CIBLE
#SI catapult existe encore -> Target
if nb_catapult > 0:
index=i % nb_catapult
target=catapult[index]
if friend.type is "soldier":
i+=1
elif friend.pos.x > 240:
target=notdoor(friend)
#Si plus de catapul target enemy
elif friend.pos.x < 85 or self.pos.x > 110 :
target=friend.findNearest(self.findEnemies())
target2=self.findNearest(self.findEnemies())
if not target and target2:
target=target2
#Sinon pas de cible
else:
target=False
target2=False
#Gestion des Paladins
if friend.type is "paladin":
mostHurt=lowestHealthPaladin()
if self.now() > 75 and self.now() < 80:
self.command(friend, "move", {"x":180,"y":9})
elif len(catapult) > 0 and Up:
self.command(friend, "move", waiting)
Up=False
elif len(catapult) > 0 and not Up:
self.command(friend, "move", waiting2)
Up=True
elif friend.pos.x < 94 and friend.pos.x < self.pos.x-5 and self.pos.x < 340:
self.command(friend, "move", {"x":friend.pos.x+1,"y":34})
elif mostHurt and friend.canCast("heal"):
self.command(friend, "cast", "heal", self)
elif friend.pos.x < self.pos.x -25 and self.pos.x > 140:
self.command(friend, "move", {"x":self.pos.x-20,"y":self.pos.y})
elif friend.pos.x > 240:
self.command(friend, "attack", target)
else:
self.command(friend, "shield")
#Gestion des Archers
if friend.type is "archer":
mostHurt=lowestHealthPaladin()
warlock=self.findNearest(self.findByType("warlock"))
if warlock:
target=warlock
if self.now() > 75 and friend.pos.x < 175:
self.command(friend, "move", {"x":180,"y":9})
elif len(catapult) > 0 and Up:
self.command(friend, "move", waiting)
Up=False
elif len(catapult) > 0 and not Up:
self.command(friend, "move", waiting2)
Up=True
elif friend.pos.x < self.pos.x -20 and self.pos.x > 140:
self.command(friend, "move", {"x":self.pos.x-7,"y":self.pos.y})
elif friend.pos.x < 75 and target and friend.pos.x < self.pos.x:
self.command(friend, "attack", target)
elif target and friend.pos.x > 247:
self.command(friend, "attack", target)
elif target and self.pos.x > 118 and friend.pos.x < self.pos.x:
self.command(friend, "attack", target)
elif friend.pos.x > 247 and target :
self.command(friend, "attack", target)
else:
self.command(friend, "defend", {"x":self.pos.x-15,"y":self.pos.y-5})
#Gestion des Soldats
if friend.type is "soldier":
if len(catapult) > 0:
if friend.pos.x < 97 and i > 3:
self.command(friend, "move", {"x":97,"y":34})
elif target:
self.command(friend, "attack", target)
else:
self.command(friend, "move", {"x":97,"y":34})
elif friend.pos.x < 95 and friend.pos.x > self.pos.x :
self.command(friend, "move", {"x":75,"y":34})
elif target and self.now() > 90:
self.command(friend, "attack", target)
#Command Hero
enemy=self.findNearest(self.findEnemies())
warlock=self.findNearest(self.findByType("warlock"))
if len(catapult) < 1:
if self.pos.x < 130:
self.move({"x":self.pos.x+1,"y":32})
elif nb_tower > 0:
self.shield()
elif self.pos.x < 240:
self.move(points[1])
elif self.pos.x < 275:
self.move(points[2])
elif warlock and self.health > self.maxHealth/2 and self.now()> 80:
self.attack(warlock)
else:
self.shield()
if self.gold > self.costOf("archer") and (self.pos.x < 94 or nb_tower < 1) and self.now() < 120:
self.summon("archer")