Just starting up playing again after a lengthy layoff and this level is kicking my butt. I’m sure that I can’t see the forest through the trees and I’m just overlooking the obvious, but I’ve tried about 30 different combinations of everything I can think of and it’s just not working. I’m pretty sure that the problem is in the function.
# Defeat shamans to survive.
# The function find the weakest enemy.
def findWeakestEnemy():
enemies = hero.findEnemies()
weakest = None
leastHealth = 99999
enemyIndex = 0
# Loop through enemies:
while enemyIndex < len(enemies):
enemy = enemies[enemyIndex]
# If an enemy's health is less than leastHealth:
if enemy.health < leastHealth:
# Make it the weakest
weakest = enemy
# and set leastHealth to its health.
leastHealth = enemy.health
return weakest
while True:
# Find the weakest enemy with the function:
weakest = findWeakestEnemy()
# If the weakest enemy here:
if weakest:
# Attack it!
hero.attack(weakest)
pass