ondras / rot.js

ROguelike Toolkit in JavaScript. Cool dungeon-related stuff, interactive manual, documentation, tests!
https://ondras.github.io/rot.js/hp/
BSD 3-Clause "New" or "Revised" License
2.33k stars 254 forks source link

Fixed destructiveness of Array.prototype.randomize() #100

Closed jakofranko closed 8 years ago

jakofranko commented 8 years ago

Hi there @ondras ! Fixed the problem where using .randomize() on an array destroyed the array's value. I'm not sure if I need to compile rot.js as well? Let me know if you need me to tweak anything or if you think this will cause any problems...

By the way, thank you so much for this tool! I have stumbled across roguelikes within the last few years, and as a web developer I was thrilled to find such a useful framework that uses my 'bread and butter' language: Javascript!

ondras commented 8 years ago

Hi @jakofranko,

thanks for your code and sorry for my late reply (just returned from vacation).

As far as the cloning goes, you can prehaps simplify the whole operation to

var clone = this.slice();

?

jakofranko commented 8 years ago

Good idea, I didn't realize you could use slice to make shallow copies like that. Handy! I'll update and re-push.

ondras commented 8 years ago

Cool, thanks!

jakofranko commented 8 years ago

Thanks for the framework! Glad I could contribute.