[HELP] Summits gate

Is this working code? I don’t want to format it all to find out.
If so, please delete it. I appreciate you’re trying to help others, but it doesn’t help them learn, winning from a solution someone else wrote is almost pointless.
Thanks
Danny

Ok I’m understand

Vào Th 2, 11 thg 11, 2019 vào lúc 02:38 Danny Walters via CodeCombat Discourse codecombat@discoursemail.com đã viết:

def commandArchers():
for archer in self.findByType(“archer”, self.findFriends()):
nearestEnemy = archer.findNearestEnemy()
if nearestEnemy:
self.command(archer, “attack”, nearestEnemy)
else:
hero.command(archer, “defend”, hero)

def commandSoldiers():
for soldier in self.findByType(“soldier”, self.findFriends()):
nearestEnemy = soldier.findNearestEnemy()
if nearestEnemy:
self.command(soldier, “attack”, nearestEnemy)
else:
hero.command(soldier, “defend”, hero)
def summonGriffins():
if hero.gold > hero.costOf(“griffin-rider”):
hero.summon(“griffin-rider”)
def pick():
item = hero.findNearestItem()
flag = hero.findFlag()
if item:
hero.moveXY(item.pos.x, item.pos.y)
if flag:
hero.pickUpFlag(flag)
def commandGriffins():
for griffin in self.findByType(“griffin-rider”, self.findFriends()):
enemies = griffin.findEnemies()
nearestEnemy = self.findNearest(enemies)
if nearestEnemy:
self.command(griffin, “attack”, nearestEnemy)
else:
self.command(griffin, “defend”, self)

def weakestFriend():
weakestFriend = None
weakestHealth = 999
for friend in self.findFriends():
if friend.health < friend.maxHealth and friend.health < weakestHealth:
weakestHealth = friend.health
weakestFriend = friend
if weakestFriend:
return weakestFriend

def commandPaladins():
for paladin in self.findByType(“paladin”, self.findFriends()):
if paladin.canCast(“heal”, self):
if self.health < 3000:
self.command(paladin, “cast”, “heal”, self)
else:
weakestFriend2 = weakestFriend()
if weakestFriend2:
self.command(paladin, “cast”, “heal”, weakestFriend2)
else:
hero.command(paladin, “defend”, hero)

def summonGriffin():
if self.gold >= self.costOf(“griffin-rider”):
self.summon(“griffin-rider”)

def moveForward():
targetPos = {‘x’: 328, ‘y’: 35}
self.move(targetPos)

def pickTarget():
enemies = self.findEnemies()
target = None
minDistance = 9999
for enemy in enemies:
if enemy.type is not “door”:
if enemy.type is “catapult”:
target = enemy
break
elif enemy.type is “warlock”:
target = enemy
break
elif enemy.type is “witch”:
target = enemy
break
elif enemy.type is “chieftain”:
target = enemy
break
else:
if self.distanceTo(enemy) < minDistance:
minDistance = self.distanceTo(enemy)
target = enemy
if target:
return target

def commandHero():
target = pickTarget()
if target:
while target.health > 0:
if hero.canCast(“chain-lightning”, target):
hero.cast(“chain-lightning”, target)
if hero.isReady(“stomp”):
hero.stomp()
elif hero.isReady(“throw”):
hero.throw(target)
elif hero.isReady(“bash”):
hero.bash(target)
else:
self.attack(target)
hero.shield()
else:
    moveForward()

def attackCatapults():
catapults = self.findByType(“catapult”)
if len(catapults):
for catapult in catapults:
while catapult.health > 0:
self.attack(catapult)
while True:
pick()
summonGriffins()
commandPaladins()
commandArchers()
commandSoldiers()
commandGriffins()
pickTarget()
commandHero()
attackCatapults()

Hi @lundyundy, do you need help with your code?
Danny

yeah can you help please

Can I help you in this topic:

Because they’re the same level. Although you are using different code, I’d like you to confirm which code you’re currently using.
Danny