// canPutThisInThatOrParent.js
(function () {
/* global AdventureJS A */
var p = AdventureJS.Assets.Entity.prototype;
/**
* <strong>canPutThisInThatOrParent</strong>
* checks to see if one asset can be placed within
* the specified aspect of another specified asset,
* and if it fails, tries to put the asset inside
* the other asset's room.
* @memberOf AdventureJS.Dictionary.Verb
* @method AdventureJS.Dictionary.Verb#canPutThisInThatOrParent
* @param {String} target_aspect
* @param {Object} target_asset
* @returns {Object}
*/
p.canPutThisInThatOrParent = function Entity_canPutThisInThatOrParent(
target_aspect,
target_asset
) {
var results = { fail: true };
while (results.fail) {
if (target_asset.hasClass("Room")) {
return {
target_aspect: "in",
target_asset: target_asset,
};
}
results = this.canPutThisInThat(target_aspect, target_asset);
if (results.fail) {
target_asset = target_asset.getPlaceAsset();
target_aspect = target_asset.getPlacePreposition();
}
}
return {
target_aspect: target_aspect,
target_asset: target_asset,
};
}; // canPutThisInThatOrParent
})();