// getRoomId.js
(function () {
/* global AdventureJS A */
var p = AdventureJS.Assets.Tangible.prototype;
/**
* Get the ID of the room this asset is in.
* @memberOf AdventureJS.Assets.Tangible
* @method AdventureJS.Assets.Tangible#getRoomId
* @returns {String}
*/
p.getRoomId = function Tangible_getRoomId() {
var room = null;
var child = this;
while (null === room) {
if ("undefined" === typeof child.place) {
// if it doesn't have a place property, it's not Tangible
break;
}
var parent = child.getPlaceAsset();
if (!parent) {
break;
}
if (parent instanceof AdventureJS.Assets.Room) {
room = parent.id;
} else {
child = parent;
}
}
return room;
};
})();