Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
// addAssetAt.js
(function () {
  /*global adventurejs A*/
  "use strict";
  var p = adventurejs.Tangible.prototype;
  /**
   * Add specified asset id to the contents of
   * specified aspect on this asset.
   * Returns contents if aspect exists, or null.
   * @memberOf adventurejs.Tangible
   * @method adventurejs.Tangible#addAssetAt
   * @return {Array}
   */
  p.addAssetAt = function Tangible_addAssetAt(id, aspect) {
    this.game.log(
      "log",
      "medium",
      "addAssetAt " + id + " " + aspect + " " + this.id,
      "Tangible"
    );
    if (this.hasAspectAt(aspect)) {
      if (-1 === this.aspects[aspect].contents.indexOf(id)) {
        this.aspects[aspect].contents.push(id);
      }
      return this.aspects[aspect].contents;
    }
    return null;
  };
})();