// isAttached.js
(function () {
/*global adventurejs A*/
var p = adventurejs.Tangible.prototype;
/**
* <strong>isAttached</strong> tests whether
* one asset is specifically in the <code>behind</code> aspect of another asset.
* This is a one-to-one check that doesn't take nesting into consideration.
* <pre class="display"><code class="language-javascript">if( MyGame.$('trophy').$isAttached('plaque') ){ // do stuff }
* </code></pre>
* @memberOf adventurejs.Tangible
* @method adventurejs.Tangible#isAttached
* @param {Object|String} asset Can be string or object.
* @returns {boolean}
*/
p.isAttached = p.$isAttached = function Tangible_isAttached(asset) {
if ("undefined" === typeof asset) {
return this.getPlacePreposition() === "attached";
}
if ("string" === typeof asset) asset = this.game.getAsset(asset);
if (!asset || !asset.id || !asset.hasClass("Tangible")) return false;
if (this.getPlacePreposition() !== "attached") return false;
if (this.getPlaceAsset().id !== asset.id) return false;
return true;
};
})();