Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// onIngestThat.js
(function () {
  /* global adventurejs A */
  var p = adventurejs.Tangible.prototype;
  /**
   * Called when an asset is ingested by a character.
   * Provides opportunities to override default behavior
   * through the use of
   * <a href="/doc/Scripting_VerbReactions.html">verb reactions</a>
   * doIngestThis and doIngestThat.
   * @memberOf adventurejs.Tangible
   * @method adventurejs.Tangible#onIngestThat
   * @param {Object} asset
   * @returns {*}
   */
  p.onIngestThat = function Tangible_onIngestThat(asset) {
    if ("string" === typeof asset) asset = this.game.getAsset(asset);
    if (!asset) return;
    this.game.log(
      "L1512",
      "log",
      "high",
      `[onIngestThat.js] ${this.id} ingest ${asset.id} `,
      "Tangible"
    );
    var results;

    // check this asset for verb hook
    results = this.doVerbAction({
      action: "doIngestThat",
      asset2: asset.name,
      params: {},
      type: "VerbReaction",
    });
    if ("undefined" !== typeof results) return results;

    // check ingested asset for verb hook
    results = asset.doVerbAction({
      action: "doIngestThis",
      asset2: this.name,
      type: "VerbReaction",
    });
    if ("undefined" !== typeof results) return results;

    return results;
  }; // onIngestThat.js
})();