Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// getNest.js
(function () {
  /* global adventurejs A */
  var p = adventurejs.Character.prototype;
  /**
   * If Character is nested, returns the Nest object
   * of the asset containing the character, ex:
   * <code>asset.aspects[nest_aspect].nest</code>
   * <br>Returns null
   * if Character is not nested.
   * @memberOf adventurejs.Character
   * @method adventurejs.Character#getNest
   * @return {object|null}
   */
  p.getNest = function Character_getNest() {
    if (
      "undefined" === typeof this.nest ||
      Object.keys(this.nest).length === 0
    ) {
      return null;
    }
    const asset = this.game.getAsset(this.nest[Object.keys(this.nest)[0]]);
    const aspect = Object.keys(this.nest)[0];
    return asset.aspects[aspect].nest || null;
  };
})();