Forest Shadow(python)

I’m really embarrassed to be asking this, but I don’t know what’s wrong with my code. Please help!

while True:
    # Find the nearest enemy.
    enemy = hero.findNearestEnemy()
    # Attack it only if its type is "thrower" or "munchkin".
    if enemy.type == "thrower" or "munchkin":
        hero.attack(enemy)
    # Find the nearest item.
    item = hero.findNearestItem()
    # Collect it only if its type is "gem" or "coin".
    if item.type == "gem" or "coin":
        hero.moveXY(item.pos.x, item.pos.y)
    pass
1 Like

dumb edit:
the problem is here:

if enemy.type == "thrower" or "munchkin":

it should be

if enemy.type == "thrower" or enemy.type == "munchkin":

and same with the gems and coin

1 Like

yeah sorry (20 chars)

1 Like

Got it. Thanks! :smile:

3 Likes

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.