Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// getAsset.js

(function () {
  /* global adventurejs A */

  var p = adventurejs.Game.prototype;

  /**
   * <strong>getAsset</strong> or shortcut <strong>get</strong>
   * takes a string representing an asset name or id and tries
   * to return an asset object.
   * @memberOf adventurejs.Game
   * @method adventurejs.Game#getAsset
   * @param {String} identifier Name or ID of a game object.
   * @param {Object} params Used to check for 'prefer_substance' in cases of looking for substances in containers.
   * @returns {String} An object ID.
   */
  p.$ = function Game_$(identifier, params) {
    let asset = this.getAsset(identifier, params);

    if (!asset) {
      this.game.log(
        "L1576",
        "warn",
        "high",
        `Game_$ received invalid identifier: ${identifier}, returning Null `,
        "Game"
      );
      asset = this.world["null"];
    }

    return asset;
  };
})();