Ok, I have beat the level, but my code is not performing as expected. There are four types of enemies, and a total nine enemies. 1 - Ogre Hero, 2 - sand-yaks, 2 - archers, 4 - soldiers. I confirmed this enemy types with:
enemies = self.findEnemies
for next in enemies:
self.say(next.type)
The code returned Knight, sand-yak, archer and soldier though not in that order.
I have tried several sorting strategies to attack the soldiers, but my Hero always ignores them. I tried sorting with ‘soldiers’ and I tried sorting with exclusoin. The exclusion code is listed below. Why is my code ignoring the soldiers?
# Use your cleverest programming tricks to outwit and overpower your opponent!
enemies = self.findEnemies()
archers = []
others = []
booger = None
for enemy in enemies:
if enemy.type is 'archer':
archers.append(enemy)
# This should have create an array with 6 elements - 2 archers and 4 soldiers.
elif enemy.type is not 'sand-yak' and enemy.id is not "Hero Placeholder 1":
others.append(enemy)
elif enemy.id is "Hero Placeholder 1":
booger = enemy
for next in archers:
while next.health > 0:
self. attack(next)
for next in others:
while next.health > 0:
self.attack(next)
if booger:
while booger.health > 0:
self.attack(booger)
self.say("I picked my Booger")