mbkarle / mind-the-fog

Roguelike JavaScript game--mind the fog!
2 stars 1 forks source link

Chasing a fog tail can leave you cleared #71

Closed akarle closed 7 years ago

akarle commented 7 years ago

If you end up in your fog tail (or rather visibility tail) before its timeout gets executed and it is deleted, you will be obscured...

Need to add safeguards for the current position of the character... Or maybe have a sort of way to reset the timer?

mbkarle commented 7 years ago

I haven't looked into this yet in depth but you might be able to reset the timer with window.clearTimeout and then starting it again... Or is the problem more complicated than that?

akarle commented 7 years ago

It's slightly more complicated, BUT, I thought of a potential solution:

Each Location has the ability to know it's HTML ID ("rowxcol"), so instead of making the timeout a general thing that the method triggers, each Location should have a timeout property which gets reset each time a location is touched!

Boom, we win. I think.

akarle commented 7 years ago

So I guess, with this new update to fog, (#53), really Location.fog is no longer a true/false questions, its more of a "when is it coming back" question, ya feel?

I branched and plan to remove all fog true/false-ness for this update. It will involve each Location having a setTimeout at which point the fog gets turned back on.

In other words, we shouldn't directly set fog (except for maybe a safe room) and instead we should reset the timer. Ill make a function to reset the timer every time you touch a square.