Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// removeThatFromThis.js
(function () {
  /* global adventurejs A */
  var p = adventurejs.Tangible.prototype;
  /**
   * Removes an asset from another asset. It's not meant to be
   * called directly, but is the last piece, or bedrock, of the
   * removal process after checking for custom logic.
   * @memberOf adventurejs.Tangible
   * @method adventurejs.Tangible#removeThatFromThis
   * @param {Object} asset
   */
  p.removeThatFromThis = function Tangible_removeThatFromThis(asset) {
    if ("string" === typeof asset) asset = this.game.getAsset(asset);
    if (!asset) return;
    this.game.log(
      "L1575",
      "log",
      "high",
      `${this.id}.removeThatFromThis(${asset.name})`,
      "Tangible"
    );
    for (var aspect in this.aspects) {
      if (!this.hasAspectAt(aspect)) {
        continue;
      }
      if (-1 < this.aspects[aspect].contents.indexOf(asset.id)) {
        this.aspects[aspect].contents.splice(
          this.aspects[aspect].contents.indexOf(asset.id),
          1
        );
      }
    }
    return;
  };
})();