[SOLVED] Burlbole grove trouble


#1

I have trouble woth my code. My hero always attack burls.

def shouldAttack(target):
	# return False if no target
    if not target:
        return False
    elif target == "burl":
	    return False
    # Otherwise, return True
    else:
        return True
    return True

while True:
    enemy = hero.findNearestEnemy()
    # Here we use shouldAttack() to decide if we should attack!
    # heroShouldAttack will be assigned the same value that shouldAttack() returns!
    heroShouldAttack = shouldAttack(enemy)
    if heroShouldAttack:
    	hero.attack(enemy)
    	pass
    pass


#2

You may need an if enemy.


#3

It looks like you deleted the comment giving you a hint about checking the target’s type:

elif target.type == "burl": not elif target == "burl":


#4

Thanks for help. Now i see this comment :wink: