Munchkin Swarm Python: HELP!

It says “Line 9: Object doesn’t support property or method ‘cleave’” even tho I have the long sword equip and my code is:

loop:
    enemy = self.findNearestEnemy()
    self.distanceTo(enemy.pos)
    if self.distanceTo(enemy) > 10 :
        self.attack("Chest")
    else:
        self.cleave(enemy)
        self.attack(enemy)
        self.attack(enemy)

Well one thing i see if you aren’t checking if enemy exists (it doesnt always)

loop:
    enemy = self.findNearestEnemy()
    if enemy:    
        self.distanceTo(enemy.pos)
        if self.distanceTo(enemy) > 10 :
            self.attack("Chest")
        else:
            self.cleave(enemy)
            self.attack(enemy)
            self.attack(enemy)

But you also need to put attacking the chest in an else if enemy doesn’t exist.

loop:
    enemy = self.findNearestEnemy()
    if enemy:    
        self.distanceTo(enemy.pos)
        if self.distanceTo(enemy) > 10 :
            self.attack("Chest")
        else:
            self.cleave(enemy)
            self.attack(enemy)
            self.attack(enemy)
    else:
        self.attack("Chest")

Also, you could try re-equipping the Long Sword, just in case it somehow forgot that you had equipped it.

You should also probably only use “cleave” if its ready by using the “isReady” command, because cleave has a cooldown period.

Thanks that actually did the trick