[SOLVED] Burlbole grove trouble


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
        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:


You may need an if enemy.


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":


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