How hero.hasEffect("effect") method supposed to work?


#1

Hi, everyone!
I searched forum for more information or examples of hero.hasEffect(“effect”) method usage, but didn’t found any helpful topic.
Am I understand wrong something about this method or my code is bad or something else?
The level is “Backwoods treasure” in Backwood forest, language is Python and my code is:

`def RingOn():
    if self.canCast("invisibility", self):
        self.cast("invisibility", self)

loop:
    item = hero.findNearest(hero.findItems())
    RingOn()
    if hero.hasEffect("invisibility"):
        if item:
            hero.move(item.pos)
`

I supposed that hero would became invisible and pick up coins while invisibility effect duration, but Anya does only the first part)) She became invisible and stands still till running out of time.

Any hint or advice would be highly appreciated.


#2

That is because when you read about the ring of invisibility, it tells you to use the effect “hide”


#3

Oh my gosh( Thank you very much! I feel terribly ashamed for my inattention( As an excuse I could say that I bought ring of invisibility very, very long time ago and didn’t remember about “hide” parameter for checking invisibility effect and my logic circumvents me(
Again, I am very grateful for you, @Harry_the_Wanderer!


#4

No problem. I understand. I have made a few of these mistakes myself. I got into the habit of going back and re-reading the documentation and hints to find out where I went wrong.

Nothing like trying to “attack” an enemy when you have a hammer equipped.

“Why doesn’t hero.attack(); work!?! … oh I need a sword.”

:slight_smile:


#5

Oh, as far as my job doesn’t concern to IT at all and I have no programmer skills and play codecombat as hobby, I used to read documentation and hints carefully too, and also to search forum for more information in difficult cases. It helps me to get to “Kelvintaph Defiler” level in Kelvintaph Glacier location without posting asking for help on forum, and I am a little bit proud of it. :slight_smile: But now I was totally sure that “invisibility spell” should cast “invisibility effect”:confused: Sometimes specifications are very important )