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

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

  var p = adventurejs.Game.prototype;

  /**
   * Convenience method to get the current room's floor.
   * @method adventurejs.Game#getRoomFloor
   * @memberOf adventurejs.Game
   * @returns {Object}
   */
  p.getRoomFloor = function Game_getCurrentRoomFloor(
    room = this.world[this.world._room]
  ) {
    //return this.getAsset( this.world._room );
    var floor;
    var floors = room.findNestedAssetsWithClass("Floor");
    if (floors.length) {
      floor = floors[0];
    } // otherwise use the global floor
    else {
      floor = this.game.getAsset("global_floor");
    }
    return floor || null;
  };
})();