Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
// setAspectAt.js
(function () {
  /*global adventurejs A*/
  "use strict";
  var p = adventurejs.Tangible.prototype;
  /**
   * Add an aspect at the specified aspect on this asset.
   * @memberOf adventurejs.Tangible
   * @method adventurejs.Tangible#setAspectAt
   * @param {string} aspect - The aspect to add.
   * @return {Array}
   */
  p.setAspectAt = function Tangible_setAspectAt(aspect, params) {
    if (this.hasAspectAt(aspect)) {
      if (params) this.aspects[aspect].set(params);
    } else {
      if (!params) params = {};
      if (!params.parent_id) params.parent_id = this.id;
      this.aspects[aspect] = new adventurejs.Aspect(aspect, this.game_name).set(
        params
      );
    }
    return this.getAspectAt(aspect);
  };
})();