Possible bug on Sarven Brawl

I’ve hit a problem and I’m not sure if it’s me or a bug.

On the Lurkers level, you are able to use the following code snipped to dispatch the baddies:

while enemy.health > 0:
self.attack(enemy)

After you kill each shaman, the while loop stops and the script moves you onto the next target.

Experimenting with similiar code on the Sarven Brawl level, I tried using the following snippet (similiar to the one used on the Lurkers level):

loop:
    drop = self.findNearest(self.findItems())
    enemy = self.findNearest(self.findEnemies())
    
    if enemy:
        while enemy.health > 0:        
            self.say(enemy.health)        
            self.say(enemy.type)
            self.attack(enemy)
    else:
        self.moveXY(drop.pos.x, drop.pos.y)

What happens is not what I expected. When my hero goes after the Ogre whose near where you start, he says “120” (the enemy health) and starts to attack. However, despite hitting and eventually killing the Ogre, my hero keeps repeating “120” and just stands over the corpse, stuck in that while loop.

I’ve checked and there’s no other active Ogre on the screen. At first, I thought this might be because the health attibute(?) doesn’t automatically update. However, I went back and checked on Lurkers, using the exact same loop, and it’s clear that the health attribute of each Shaman is dynamically updating in that level.

Any thoughts?

1 Like

I feel like you’re probably stuck in that loop. Give this a try:

loop:
    drop = self.findNearest(self.findItems())
    enemy = self.findNearest(self.findEnemies())

    if enemy:     
        self.say(enemy.health)        
        self.say(enemy.type)
        self.attack(enemy)
    else:
        self.moveXY(drop.pos.x, drop.pos.y)

Huh, that’s weird; it sounds like an API protection bug where the enemy object isn’t properly being updated. I thought I had gotten all of those a while back. I really don’t know when I can muster the courage to debug that one again, so although I’ll get it at some point, it may be a while. I’d use the non-nested version for now until I can get it.

davidispizza: that’s exactly what I did in the end.

nick: no rush on debugging. There are plenty of other solutions. I just thought you’d like to know that was an issue.

Tracking the bug here: https://github.com/codecombat/codecombat/issues/2079

1 Like

for me too. I achieved “sarven brawl” and behind the level name mention “1” but they didn’t show me complete level. why? and it become really hard after that.