problem:
hero ignores enemy
do I need special glasses to detect enemy health?
Here is the code that does not work:
(need to add four spaces and two blank lines to get the code to format properly!)
# Check for ogres and defeat them!
enemy = hero.findNearestEnemy()
if enemy:
if enemy.health <= 0:
hero.attack(enemy)
# Make sure to attack the ogres while their health is above 0.
If I comment out it works… again, is this a ‘glasses’ issue?
if enemy.health <= 0:
if enemy:
#if enemy.health <= 0:
hero.attack(enemy)
# Make sure to attack the ogres while their health is above 0.