This.findHazards() buggy imo

Hello
in some level, i’m building firetraps (this.buildXY(“fire-trap”,x,y)), then checking hazards (this.findHazards()) to avoid stepping on my own traps. So far all good. However, when my firetraps detonate, findHazards() still holds items.
IMO, either detonated firetraps should be removed from hazards array, or firetrap objects should have a method to check if they’re active or already detonated.
Am i missing something ?

1 Like

i think you have, but better to ask: you have asked findHazards() after the fire Trap explodes again?

yes, i’m checking this.findHazards().length and it’s !=0 even after the trap has detonated

What exactly does your code look like?

this.say(this.findHazards().length); //Returns 1
//Firetrap explodes
this.say(this.findHazards().length); //Should return 0

or

var hazards = this.findHazards();
this.say(hazards.length); //Returns 1
//Firetrap explodes
this.say(hazards.length); //Should return 1, because you didn't search for hazards again

option 1

i’m doing something around :

loop {
    //[...]
    this.buildXY("fire-trap",this.pos.x,this.pos.y);
    this.say(this.findHazards().length);
    //[...]
}

and my dude says 1, then 2, then 3, although the traps are detonating between the loops

I can confirm this:

  • Build a trap
  • this.say(this.getHazards().length) “1”
  • Walk away
  • Walk Back (It explodes)
  • this.say(this.getHazards().length) “1”
  • Build a trap
  • this.say(this.getHazards().length) “2”
  • Repeat.

And I offered a patch to solve this.

Also if you see something buggy, feel free to report it in the issues of the GitHub: https://github.com/codecombat/codecombat Helps me find problems like these.

Is there a chance this bug is fixed soon?