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.34k stars 255 forks source link

Fix logic in ROT.Map.Rogue to use parens per #62 #63

Closed ZLester closed 9 years ago

ZLester commented 9 years ago

Changed from brackets to parens so as to prevent !this._options.hasOwnProperty["roomHeight"] from always returning true (!undefined). No other changes made.

Before:

if (!this._options.hasOwnProperty["roomHeight"]) { this._options["roomHeight"] = this._calculateRoomSize(this._height, this._options["cellHeight"]); }

After:

if (!this._options.hasOwnProperty("roomHeight")) { this._options["roomHeight"] = this._calculateRoomSize(this._height, this._options["cellHeight"]); }

ondras commented 9 years ago

Nice thanks a lot!

I think, however, that we can safely simplify the check to a plain if (!this._options.roomWidth) ....

ondras commented 9 years ago

or, if 0 is a fair value, to if (!("roomWidth" in this._options)) ....