// getAspectWithVessel.js
(function () {
/*global adventurejs A*/
"use strict";
var p = adventurejs.Tangible.prototype;
/**
* Get this asset's substance location. This is somewhat
* ambiguous because in theory an asset can have multiple
* substance locations but in practice we clearly prefer 'in'.
* @memberOf adventurejs.Tangible
* @method adventurejs.Tangible#getAspectWithVessel
* @returns {String}
*/
p.getAspectWithVessel = function Tangible_getAspectWithVessel() {
var keys = Object.keys(this.aspects);
var vessels = [];
for (var i = 0; i < keys.length; i++) {
var aspect = keys[i];
if (!this.aspects[aspect].vessel.class) continue;
vessels.push(aspect);
}
switch (vessels.length) {
case 0:
return "";
case 1:
return vessels[0];
default:
// if more than one vessels are found and 'in' is one return 'in'
// otherwise just return the first one found
if (vessels.indexOf("in") !== -1) return "in";
else return vessels[0];
}
};
})();